ionic-team / capacitor

Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚡️
https://capacitorjs.com
MIT License
12.26k stars 1.01k forks source link

[Bug]: SPM - capacitor-swift-pm.git Version declared to branch main #7735

Closed 7-plus-t closed 4 days ago

7-plus-t commented 4 weeks ago

Capacitor Version

Latest Dependencies:

@capacitor/cli: 6.1.2 @capacitor/core: 6.1.2 @capacitor/android: 6.1.2 @capacitor/ios: 6.1.2

Installed Dependencies:

@capacitor/cli: 6.1.2 @capacitor/core: 6.1.2 @capacitor/ios: 6.1.2 @capacitor/android: 6.1.2

Other API Details

> npm --version
10.9.0

> node --version
v22.10.0

Platforms Affected

Current Behavior

Using the SPM beta for iOS: In the Package.swift of CapApp-SPM, generated by npx cap sync, the dependency on Capacitor and Cordova is declared as follows: .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", branch: "main"),

This causes SPM to use the latest commit of https://github.com/ionic-team/capacitor-swift-pm.git and therefore always the newest Capacitor version is used. This cannot be overridden by the parent app, as the branch: "main" overrules other constraintes like exact or from when there is a conflict.

A similar problem exists in all the Capacitor plugins that have been converted to the SPM structure, where in Package.swift the dependency to Capacitor is declared with branch: "main".

Expected Behavior

The Package.swift of CapApp-SPM and the plugins should be changed, so it states: .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "6.0.0"), (or 7.0.0 for the upcoming Capacitor release). This allows the parent app to declare the version of Capacitor to be used, without SPM resolution conflicts.

Project Reproduction

Use any plugin example app

Additional Information

No response

flgubler-ergon commented 4 weeks ago

We have faced the same problem in our project: the build suddenly started using the capacitor 7 alpha version which obviously is unacceptable for a productive app.

A reproduction can be found here: https://github.com/ionic-team/capacitor-ios-spm-template/blob/main/template/App/CapApp-SPM/Package.swift - it is apparently a different dependency, but uses branch: "main" as well.

ionitron-bot[bot] commented 4 weeks ago

This issue has been labeled as type: bug. This label is added to issues that that have been reproduced and are being tracked in our internal issue tracker.

7-plus-t commented 4 weeks ago

Thanks @jcesarmobile :)

For the readers: see https://github.com/ionic-team/capacitor-plugins/pull/2221 for fix in plugins

7-plus-t commented 4 weeks ago

see https://github.com/ionic-team/capacitor-plugins/pull/2221 for fix in plugins

flgubler-ergon commented 3 weeks ago

Cool, thanks

jcesarmobile commented 4 days ago

fixed in https://github.com/ionic-team/capacitor/pull/7737