swift-server-community / APNSwift

📱HTTP/2 Apple Push Notification Service built with swift - send push notifications to iOS, iPadOS, tvOS, macOS, watchOS, visionOS, and Safari!
Apache License 2.0
695 stars 105 forks source link

[Question] - SwiftPM seems to hang when i include this dependency in a new vapor project #30

Closed eito closed 5 years ago

eito commented 5 years ago

Wasn't sure where else to post this, but including this as a dependency causes SwiftPM to hang. If I include the dependency it hangs on explicitly, it hangs on a different one... I'm not sure where to look to see what's going on, the best I can do is use --verbose when updating vapor.

╰─❱ vapor update --verbose
Updating ...
Updating https://github.com/vapor/vapor.git
Updating https://github.com/kylebrowning/APNSwift.git
Updating https://github.com/vapor/service.git
Updating https://github.com/vapor/url-encoded-form.git
Updating https://github.com/vapor/template-kit.git
Updating https://github.com/vapor/routing.git
Updating https://github.com/vapor/multipart.git
Updating https://github.com/vapor/crypto.git
Updating https://github.com/vapor/core.git
Updating https://github.com/vapor/console.git
Updating https://github.com/vapor/database-kit.git
Updating https://github.com/vapor/http.git
Updating https://github.com/vapor/websocket.git
Updating https://github.com/vapor/validation.git
Updating https://github.com/apple/swift-nio.git
Updating https://github.com/apple/swift-nio-zlib-support.git
Updating https://github.com/apple/swift-nio-ssl-support.git
Updating https://github.com/apple/swift-nio-ssl.git
Updating https://github.com/apple/swift-nio-http2.git

Here is my package.swift

// swift-tools-version:4.0
import PackageDescription

let package = Package(
    name: "hackathon",
    products: [
        .library(name: "hackathon", targets: ["App"]),
    ],
    dependencies: [
        // 💧 A server-side Swift web framework.
        .package(url: "https://github.com/vapor/vapor.git", from: "3.0.0"),
        .package(url: "https://github.com/kylebrowning/APNSwift.git", from: "1.0.0")
//        .package(url: "https://github.com/apple/swift-nio-http2.git", from: "1.3.0"),
    ],
    targets: [
        .target(name: "App", dependencies: ["Vapor", "APNSwift"]),
        .target(name: "Run", dependencies: ["App"]),
        .testTarget(name: "AppTests", dependencies: ["App"])
    ]
)

If I uncomment the latter package, it hangs on a different package:

╰─❱ vapor update --verbose
Updating ...
Updating https://github.com/vapor/vapor.git
Updating https://github.com/kylebrowning/APNSwift.git
Updating https://github.com/apple/swift-nio-http2.git
Updating https://github.com/vapor/template-kit.git
Updating https://github.com/vapor/routing.git
Updating https://github.com/vapor/http.git
Updating https://github.com/vapor/url-encoded-form.git
Updating https://github.com/vapor/service.git
Updating https://github.com/vapor/console.git
Updating https://github.com/vapor/database-kit.git
Updating https://github.com/vapor/multipart.git
Updating https://github.com/vapor/core.git
Updating https://github.com/vapor/crypto.git
Updating https://github.com/vapor/websocket.git
Updating https://github.com/vapor/validation.git
Updating https://github.com/apple/swift-nio.git
Updating https://github.com/apple/swift-nio-zlib-support.git
Updating https://github.com/apple/swift-nio-ssl-support.git
Updating https://github.com/apple/swift-nio-ssl.git

I'm willing to dig in to resolve this, just not sure where I should look at this point

NOTE: it completes fine if I remove APNSwift

kylebrowning commented 5 years ago

It looks like you’re using swift tools version 4. This only works with swift tools version 5

kylebrowning commented 5 years ago

I’ll paste a vapor alpha package.swift momentarily.

eito commented 5 years ago

Thanks for the quick response. I'm past the hang but am getting some compilation errors related to the generated shim.h

// swift-tools-version:5.0
import PackageDescription

let package = Package(
    name: "hackathon",
    products: [
        .library(name: "hackathon", targets: ["App"]),
    ],
    dependencies: [
        // 💧 A server-side Swift web framework.
        .package(url: "https://github.com/vapor/vapor.git", from: "4.0.0-alpha"),
        .package(url: "https://github.com/kylebrowning/APNSwift.git", from: "1.0.0"),

        .package(url: "https://github.com/apple/swift-nio.git", from: "2.0.0"),
        .package(url: "https://github.com/apple/swift-nio-ssl.git", from: "2.0.0"),
        .package(url: "https://github.com/apple/swift-nio-extras.git", from: "1.0.0"),
        .package(url: "https://github.com/apple/swift-nio-http2.git", from: "1.0.0"),
        .package(url: "https://github.com/apple/swift-nio-transport-services.git", from: "1.0.0")
    ],
    targets: [
        .target(name: "App", dependencies: ["Vapor"]),
        .target(name: "Run", dependencies: ["App"]),
        .testTarget(name: "AppTests", dependencies: ["App"])
    ]
)

image

kylebrowning commented 5 years ago

Brew install openssl@1.1

kylebrowning commented 5 years ago

You can also type, pkg-config openssl --cflags To see which openssl would be linked when compiling.

eito commented 5 years ago

thanks, got past the first issue, now I am wading through CryptoKit compilation errors... 🎉

kylebrowning commented 5 years ago

@eito I believe those are related to which openssl version is being pulled in.

eito commented 5 years ago

yeah, the errors are all related to OpaquePointer/UnsafePointer conversion issues, which I saw some mention of in APNSwiftPointerTricks.swift... trying to wrap my head around that all

kylebrowning commented 5 years ago

What do you see when you type pkg-config openssl --cflags

eito commented 5 years ago
╰─❱ pkg-config openssl --cflags
Package openssl was not found in the pkg-config search path.
Perhaps you should add the directory containing `openssl.pc'
to the PKG_CONFIG_PATH environment variable
No package 'openssl' found
eito commented 5 years ago

It looks like it's getting symbols from

image

Instead of CNIOBoringSSL's versions.. not sure if that's expected

kylebrowning commented 5 years ago

SO when you did brew install openssl, it should have told you about the CFLAGS to export into your path for pkg-config.

kylebrowning commented 5 years ago

double check pkg-config is installed, and then you can do

For pkg-config to find openssl@1.1 you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"

Then clean build, and regenerate xcode-proj and you should be good.

kylebrowning commented 5 years ago

@eito ^

eito commented 5 years ago

cool, thanks @kylebrowning will try it out

kylebrowning commented 5 years ago

Im going to close this as the original problem seems to be resolved.

If something else comes up, don't hesitate to reach out!