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

Add Swift Package Manager Support for iOS Plugins #1089

Open
msmtamburro opened this issue Mar 10, 2021 · 7 comments
Open

Add Swift Package Manager Support for iOS Plugins #1089

msmtamburro opened this issue Mar 10, 2021 · 7 comments
Milestone

Comments

@msmtamburro
Copy link
Contributor

Feature Request

With recent versions of Xcode, including frameworks became problematic due to the introduction of the M1 Mac and the inclusion of certain simulator architectures within frameworks. To address this, framework consumers use Lipo to strip architectures, or (better) framework providers moved to XCFramework. Other framework providers jumped directly to offering their projects as Swift Packages to overcome this challenge. It would be nice to add a way for plugins to specify Swift Package Manager dependencies, just like they currently can specify frameworks.

Motivation Behind Feature

There are complicated or manually intensive ways to add Swift Packages to a Cordova project, so it would make sense to add real support, as this does appear the direction things are going.

https://swift.org/package-manager/
https://developer.apple.com/documentation/xcode/adding_package_dependencies_to_your_app

Feature Description

Plugins would be able to add a line something like this:

<package src="https://github.com/ReactiveX/RxSwift.git" branch="optional" version="6.0.0" revision="3920840923809482309482039"/>

Alternatives or Workarounds

You could write a hook that calls something on the command line to add this, or (worse) manually add the package each time through Xcode.

@NiklasMerz NiklasMerz transferred this issue from apache/cordova Mar 11, 2021
@jpike88
Copy link

jpike88 commented Apr 19, 2021

Cocoapods needs to be a thing of the past, downloading of the cocopaods repo step is pure lunacy and anything that improves on that is massive step forward.

@j3k0
Copy link

j3k0 commented Oct 27, 2022

@msmtamburro - I'm stuck with a project where I need to use an SDK distributed only with SPM. What would be the "complicated way" to install this SDK until proper support is added to Cordova?

@msmtamburro
Copy link
Contributor Author

@j3k0 one approach would be to look at the Package.swift file, which is human readable, and then write yourself a similar plugin.xml.

@j3k0
Copy link

j3k0 commented Nov 2, 2022

Thanks, for later reference, the SDK being open source I included all source files and assets and packaged them with the plugin.xml as suggested. This solution works but does require some effort. Everything isn't possible with plugin.xml like bundling assets, which I had to do manually.

@dpogue
Copy link
Member

dpogue commented Nov 2, 2022

I think we're definitely interested in Cordova-iOS and Cordova plugins supporting a way to add dependencies using Swift Package Manager.

Probably, we'd want dependencies declared in plugin.xml similar to how Android declares Gradle package dependencies:

<framework src="com.google.firebase:firebase-core:$FCM_VERSION" />

Swift packages are handled as git URLs with references to branches or tags, so we'd either need to take a complete package spec URL or a package URL and a version spec.

There are a few pre-requisites to this work:

  1. We probably need the flexibility provided by feat(PluginInfo): pass through XML attributes cordova-common#181 to more easily support parsing the dependency declarations from plugin.xml
  2. We're going to need to add the necessary support to https://github.com/apache/cordova-node-xcode to understand how to add the Swift Package references to the Xcode project and associate them with targets
  3. We're going to need to add code here to cordova-ios to glue all those pieces together

@agoncalvesos
Copy link

Hi team! Is this going to happen?
Thanks!

@jcesarmobile
Copy link
Member

A simpler alternative to point 2 could be to create a local SPM package as local dependency to the default iOS template and add it by default so no Xcode project modification is needed. Then make the Cordova CLI modify that local package's Package.swift file to add the plugins dependencies there.

@dpogue dpogue added this to the 8.0.0 milestone Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants