p2 / OAuth2

OAuth2 framework for macOS and iOS, written in Swift.
Other
1.15k stars 277 forks source link

Swift Package Manager #315

Closed hansen-m closed 4 years ago

hansen-m commented 5 years ago

Is the Swift package manager supported for installing and linking into our project? If so, could an example be added?

With this line added to my Package.swift file:

dependencies: [ .package(url: "https://github.com/p2/OAuth2.git", from: "3.0.0"), ]

I'm getting this error:

Updating https://github.com/p2/OAuth2.git
error: dependency graph is unresolvable; found these conflicting requirements:

Dependencies: 
    https://github.com/p2/OAuth2.git @ 3.0.0..<4.0.0
ossus-lib commented 5 years ago

The Package.swift has been updated for version 5, can you try again if it works now?

hansen-m commented 5 years ago

Thanks for the quick response. Unfortunately, no I'm seeing this error now when running swift build:

error: no such module 'OAuth2'
import OAuth2

For what it's worth, I'm also using SwiftyJSON within the project and with the package manager and am not seeing any issues with it but it may be that it's not getting far enough to fail there as well.

// swift-tools-version:5.0

import PackageDescription

let package = Package(
    name: "Demo",
    platforms: [
        .macOS(.v10_11)
    ],
    products: [
        // Products define the executables and libraries produced by a package, and make them visible to other packages.
        .library(
            name: "Demo",
            targets: ["Demo"]),
    ],
    dependencies: [
        // Dependencies declare other packages that this package depends on.
        // .package(url: /* package url */, from: "1.0.0"),
        .package(url: "https://github.com/SwiftyJSON/SwiftyJSON.git", from: "5.0.0"),
        .package(url: "https://github.com/p2/OAuth2.git", from: "5.0.0"),
    ],
    targets: [
        // Targets are the basic building blocks of a package. A target can define a module or a test suite.
        // Targets can depend on other targets in this package, and on products in packages which this package depends on.
        .target(
            name: "Demo",
            dependencies: ["SwiftyJSON", "OAuth2"],
            path: "Demo")
    ]
)
ossus-lib commented 5 years ago

I think you now need to import the target names that are present in OAuth2's Package.swift, e.g. "Flows", have you tried that? Maybe you also need to declare that under "dependencies".

Conwyn commented 5 years ago

Hi

SWIFT under Google Colab

%install '.package(url: "https://github.com/p2/OAuth2", from: "5.0.0")' OAuth2

The following missing variables appear to be in SecItem.h kSecReturnAttributes kCFBooleanTrue kSecAttrAccessGroup kSecClass kSecAttrAccessible kSecAttrService kSecAttrAccount

Installing packages: .package(url: "https://github.com/p2/OAuth2", from: "5.0.0") OAuth2 With SwiftPM flags: [] Working in: /tmp/tmp61dtna82/swift-install [1/2] Compiling SwiftKeychain Keychain.swift /content/swift-install/package/.build/checkouts/OAuth2/Sources/SwiftKeychain/Keychain.swift:120:52: error: use of undeclared type 'OSStatus' internal func errorForStatusCode(_ statusCode: OSStatus) -> NSError { ^~~~ /content/swift-install/package/.build/checkouts/OAuth2/Sources/SwiftKeychain/Keychain.swift:35:23: error: use of unresolved identifier 'kSecAttrAccessibleWhenUnlocked' return String(kSecAttrAccessibleWhenUnlocked) ^~~~~~~~~~ Can you investigate please.

Regards Conwyn

Conwyn commented 5 years ago

Hi

In your dependencies you have a note which might be the clue.

Regards Conwyn

dependencies: [ // SwiftKeychain is not yet available as a Package, so we symlink to /Sources and make it a Target //.package(url: "https://github.com/yankodimitrov/SwiftKeychain.git", majorVersion: 1), ],

ossus-lib commented 4 years ago

Starting with Version 5.1, SPM should now work.