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

WIP feat!: SPM support #196

Closed
wants to merge 2 commits into from
Closed

WIP feat!: SPM support #196

wants to merge 2 commits into from

Conversation

jcesarmobile
Copy link
Member

@jcesarmobile jcesarmobile commented Apr 27, 2024

This is just a test for converting the plugin to a Swift Package Manager so apache/cordova-ios#1430 can be tested with something.
I had a local copy that didn't have the privacy manifest so I didn't add that to the Package.swift, if we go with this approach we should add it.

It removes header-file and source-file to prevent cordova plugin add from adding those files to the cordova app since they will be added by Swift Package Manager.

Using this approach plugins that want to add Swift Package Manager dependencies will have to be converted to be Swift Package Manager compatible and add dependences as they would to a regular Swift Package instead of relying in a new tag in plugin.xml

It's a breaking change because if converted, it will only work in the cordova-ios version that adds SPM plugins support (apache/cordova-ios#1430) since this change removes the header-file and source-file.
Maybe apache/cordova-ios#1430 could be tweaked to conditionally respect the header-file and source-file, etc. tags and copy them only if there is no Package.swift in the plugin, but would require a ton more work.

@jcesarmobile jcesarmobile changed the title WIP: SPM support WIP feat!: SPM support Apr 27, 2024
Package.swift Outdated
targets: ["cordova-plugin-device"])
],
dependencies: [
.package(url: "https://github.com/apache/cordova-ios.git", branch: "master")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could potentially be an issue since we can't distribute stuff pointing to the development branch, and it's probably bad if this doesn't match the version of CordovaLib being used in the app.

I guess SwiftPM has no concept of anything like "peer dependencies"? 😕

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed it since by keeping CordovaLib in the app project, having the dependency is not needed.

We will miss having plugins that are "standalone" so the source code can be built with xcodebuild without adding them to an app, but that is not possible at the moment neither, so not a big miss.

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

Successfully merging this pull request may close these issues.

2 participants