Onesignal-ios-sdk: SwiftPM support

Created on 8 Feb 2017  ·  17Comments  ·  Source: OneSignal/OneSignal-iOS-SDK

Hi,
SwiftPM is Swift's official package manager. In the near future it will replace Carthage and CocoaPods.

Here some articles about SwiftPM:

When your component is compatible with SwiftPM add on your README.md SwiftPM Compatible badge on top and add a section for the installation with SwiftPM.

Enhancement / Feature

Most helpful comment

Looking forward to seeing SwiftPM support added.

We're working to end the use of Cocoapods on our end and migrate all of both our own and 3rd party code to SPM packages whenever possible. The Xcode 11 integration is very slick.

Is this something OneSignal plans to add soon, @jkasten2?

All 17 comments

@TofPlay Thanks for the suggestion. We will look into it in the future.

@TofPlay I took a look but Apple doesn't support iOS with their SwiftPM. This is noted on their gihub page.
https://github.com/apple/swift-package-manager#swift-package-manager-project

Feel free to reopen this issue if Apple added support for iOS.

@jkasten2 Now that it's the official dependency manager, will this be implemented soon?

@michael-mckenna Thanks for the update, it looks like Xcode 11 adds support for the Swift package Manager for iOS.
https://github.com/apple/swift-package-manager#swift-package-manager-project

Looking forward to seeing SwiftPM support added.

We're working to end the use of Cocoapods on our end and migrate all of both our own and 3rd party code to SPM packages whenever possible. The Xcode 11 integration is very slick.

Is this something OneSignal plans to add soon, @jkasten2?

+1

+1

+1

+1

Hi everyone,
We're working hard on many new features, products, etc... so thanks so much for your patience!

I've begun attempts to do this but I'm struggling to find good resources on how to add SPM support to an existing library, so my efforts are hitting a wall. Most content I've found is around creating a brand new package from scratch (which is quite straight forward).

I've tried adding a Package.swift file to the repo but get "Package Resolution Failed" when trying to add it to an example project. Our project structure is unique enough that wiring everything together is more involved. Any suggestions from the community would be great to start making progress on this project.

Feel free to open a Pull Request for bonus points!

Any updates?

My guess is that this is waiting on support for embedded binaries in Swift Package Manager (as OneSignal probably doesn't want to open-source all their code), which are not supported by SPM at this time.

If that's the case, it's unlikely they'll be able to add SPM support until after this is added. I wouldn't expect that until some time after the WWDC timeframe - probably late summer or early fall.

That said, I'd love it if @rgomezp could give an update on where things stand on their end. Like a lot of people I'd really like to move to SPM for all of my dependencies.

@jeffc-dev On our first pass we didn't find a straightforward to adapt our current Xcode project to work as Swift package. We are looking at taking a more detailed pass in the next month or two.

All our SDKs are fully open source, any help form the community would be appreciated. Even an incremental change or providing additional details.

Any updates? We're also migrating from CocoaPods to SPM.

I don't know if it's helpful, but Facebook recently added SwiftPM support to their iOS SDK. Perhaps their integration may be similar to yours.
https://github.com/facebook/facebook-ios-sdk

We are still interested in supporting SwiftPM, however we are also looking at changing other aspects of our SDK that are not currently supported by SwiftPM, namely better modularization, transitioning to Swift, and using an XCFramework. SwiftPM does not supported mixed Swift and Objective-C targets, but we could duplicate our files as we transition to Swift and have them excluded from the SwiftPM target. However since it seems that Binary targets in the form of XCFrameworks are coming to SwiftPM in the near future we are looking to use that solution instead. We expect that WWDC 2020 should provide information on Swift 5.3 and SwiftPM binary dependencies.

We are still interested in supporting SwiftPM, however we are also looking at changing other aspects of our SDK that are not currently supported by SwiftPM, namely better modularization, transitioning to Swift, and using an XCFramework. SwiftPM does not supported mixed Swift and Objective-C targets, but we could duplicate our files as we transition to Swift and have them excluded from the SwiftPM target. However since it seems that Binary targets in the form of XCFrameworks are coming to SwiftPM in the near future we are looking to use that solution instead. We expect that WWDC 2020 should provide information on Swift 5.3 and SwiftPM binary dependencies.

To be fair, SPM actually does support mixed targets by supporting a target of one set of language files that imports a set of dependencies from another language source. So to accomplish this task, you're going to have to set up your obj-c/c code in traunches. Xcode offers interoperability between Swift and Obj-c under the same model using the bridging header. With SPM, the concept is nearly the same. So if the top layer is Swift, and the lower level operations are Obj-c, then you need an obj-c target, and you need to set that target for your Swift files.

Btw, my company has already begun the migration to SPM because of the fantastic integration we're seeing with Xcode. This pretty much represents the future of Swift so I don't think it can be reasonably ignored for very long.

Was this page helpful?
0 / 5 - 0 ratings