-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Description
Allow Capacitor plugin consumers to enable/disable SPM package traits on plugin dependencies
Platforms
- iOS
- Android
- Web
Request or proposed solution
Swift 6.1 introduced Package Traits (SE-0450) which allow package authors to define conditional dependencies that consumers can toggle via a traits parameter:
// Plugin's Package.swift
let package = Package(
name: "CapacitorFirebaseAnalytics",
traits: [
.trait(name: "AdIdSupport", description: "Include IDFA collection support"),
],
targets: [
.target(
name: "FirebaseAnalyticsPlugin",
dependencies: [
.product(name: "FirebaseAnalyticsCore", package: "firebase-ios-sdk"),
.product(name: "FirebaseAnalyticsIdentitySupport", package: "firebase-ios-sdk",
condition: .when(traits: ["AdIdSupport"])),
]),
]
)// Consumer's Package.swift
dependencies: [
.package(url: "https://github.com/example/some-plugin.git", from: "1.0.0", traits: ["AdIdSupport"])
]Since Capacitor manages SPM dependency resolution on behalf of the app developer, there is currently no way for a Capacitor app to pass traits to plugin dependencies. It would be great if Capacitor supported this, e.g. via capacitor.config.ts:
const config: CapacitorConfig = {
ios: {
packageTraits: {
'@capawesome-team/capacitor-firebase-analytics': ['AdIdSupport'],
},
},
};A concrete use case is capawesome-team/capacitor-firebase#942: the Firebase Analytics plugin needs to offer a choice between FirebaseAnalytics (with IDFA) and FirebaseAnalyticsCore (without IDFA). CocoaPods handles this via subspecs, but SPM has no equivalent mechanism — package traits are the intended solution.
Alternatives
No response