diff --git a/.gitignore b/.gitignore index 8cf9e54..7471d46 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,10 @@ fastlane/test_output ## VS Code .vscode + +## Swift Package Manager +Packages/ +Package.pins +Package.resolved +.swiftpm +.build/ diff --git a/Example/ReCaptcha_Tests/Core/ReCaptcha__Tests.swift b/Example/ReCaptcha_Tests/Core/ReCaptcha__Tests.swift index 232b508..e132277 100644 --- a/Example/ReCaptcha_Tests/Core/ReCaptcha__Tests.swift +++ b/Example/ReCaptcha_Tests/Core/ReCaptcha__Tests.swift @@ -8,9 +8,8 @@ import AppSwizzle @testable import ReCaptcha -import RxSwift -import XCTest +import XCTest class ReCaptcha__Tests: XCTestCase { fileprivate struct Constants { diff --git a/Example/ReCaptcha_Tests/RxSwift/ReCaptcha+Rx__Tests.swift b/Example/ReCaptcha_Tests/RxSwift/ReCaptcha+Rx__Tests.swift index 9e6c43c..fc8104d 100644 --- a/Example/ReCaptcha_Tests/RxSwift/ReCaptcha+Rx__Tests.swift +++ b/Example/ReCaptcha_Tests/RxSwift/ReCaptcha+Rx__Tests.swift @@ -6,6 +6,8 @@ // Copyright © 2018 ReCaptcha. All rights reserved. // +#if canImport(RxSwift) && canImport(RxBlocking) && canImport(RxCocoa) + @testable import ReCaptcha import RxBlocking @@ -263,3 +265,5 @@ class ReCaptcha_Rx__Tests: XCTestCase { } } } + +#endif diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..28dcf07 --- /dev/null +++ b/Package.swift @@ -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") + ]) + ] +) diff --git a/README.md b/README.md index d0fd1c9..da04e62 100644 --- a/README.md +++ b/README.md @@ -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" ``` diff --git a/ReCaptcha/Classes/ReCaptcha.swift b/ReCaptcha/Classes/ReCaptcha.swift index d552175..5bede10 100644 --- a/ReCaptcha/Classes/ReCaptcha.swift +++ b/ReCaptcha/Classes/ReCaptcha.swift @@ -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: diff --git a/ReCaptcha/Classes/Rx/SPM_exported.swift b/ReCaptcha/Classes/Rx/SPM_exported.swift new file mode 100644 index 0000000..6daefe3 --- /dev/null +++ b/ReCaptcha/Classes/Rx/SPM_exported.swift @@ -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