Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#107: Swift Package Manager support #109

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,10 @@ fastlane/test_output

## VS Code
.vscode

## Swift Package Manager
Packages/
Package.pins
Package.resolved
.swiftpm
.build/
3 changes: 1 addition & 2 deletions Example/ReCaptcha_Tests/Core/ReCaptcha__Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@

import AppSwizzle
@testable import ReCaptcha
import RxSwift
import XCTest

import XCTest

class ReCaptcha__Tests: XCTestCase {
fileprivate struct Constants {
Expand Down
4 changes: 4 additions & 0 deletions Example/ReCaptcha_Tests/RxSwift/ReCaptcha+Rx__Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// Copyright © 2018 ReCaptcha. All rights reserved.
//

#if canImport(RxSwift) && canImport(RxBlocking) && canImport(RxCocoa)

@testable import ReCaptcha

import RxBlocking
Expand Down Expand Up @@ -263,3 +265,5 @@ class ReCaptcha_Rx__Tests: XCTestCase {
}
}
}

#endif
54 changes: 54 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "ReCaptcha",
platforms: [
.iOS(.v9)
],
products: [
.library(
name: "ReCaptcha",
targets: ["ReCaptcha"]),
.library(
name: "ReCaptchaRx",
targets: ["ReCaptchaRx"])
],
dependencies: [
.package(url: "https://github.com/ReactiveX/RxSwift.git", from: "6.0.0"),
.package(url: "https://github.com/JakubMazur/AppSwizzle.git", from: "1.3.3")
],
targets: [
.target(
name: "ReCaptcha",
dependencies: [],
path: "ReCaptcha",
exclude: ["Classes/Rx"],
resources: [
.process("Assets/recaptcha.html")
],
linkerSettings: [
.linkedFramework("UIKit")
]
),
.target(
name: "ReCaptchaRx",
dependencies: [
"ReCaptcha", "RxSwift"
],
path: "ReCaptcha/Classes/Rx",
linkerSettings: [
.linkedFramework("UIKit")
]),
.testTarget(
name: "ReCaptcha_Tests",
dependencies: ["ReCaptcha", "AppSwizzle"],
path: "Example/ReCaptcha_Tests",
exclude: ["Info.plist"],
resources: [
.copy("mock.html")
])
]
)
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,17 @@ pod "ReCaptcha"
pod "ReCaptcha/RxSwift"
```

#### Swift Package Manager

```swift
https://github.com/fjcaetano/ReCaptcha
```

Adding this in project dependency in Xcode will show option to add `ReCaptcha` and `ReCaptchaRx`, the latter containing
internal dependency for ReCaptcha framework.

#### Carthage

``` ruby
github "fjcaetano/ReCaptcha"
```
Expand Down
11 changes: 1 addition & 10 deletions ReCaptcha/Classes/ReCaptcha.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,7 @@ public class ReCaptcha {
let baseURL: URL

/// The Bundle that holds ReCaptcha's assets
private static let bundle: Bundle = {
let bundle = Bundle(for: ReCaptcha.self)
guard let cocoapodsBundle = bundle
.path(forResource: "ReCaptcha", ofType: "bundle")
.flatMap(Bundle.init(path:)) else {
return bundle
}

return cocoapodsBundle
}()
private static let bundle: Bundle = Bundle.module

/**
- parameters:
Expand Down
17 changes: 17 additions & 0 deletions ReCaptcha/Classes/Rx/SPM_exported.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// SPM_exported.swift
//
//
// Created by Jakub Mazur on 15/07/2021.
//

/*

Since Swift Package Manager have directory structure and folders cannot override
this module import is needed to use internal dependency in ReCaptcha+Rx.swift file.

This file should NOT be included in Cocoapods and Carthage build

*/

@_exported import ReCaptcha