XcodeGen icon indicating copy to clipboard operation
XcodeGen copied to clipboard

Adding a swift package with multiple products was confusing

Open brandtdaniels opened this issue 3 years ago • 3 comments

I've been trying to migrate Firebase from a Cocoapod to a Swift package for the longest time. I finally decided to not give up this time and was constantly using this syntax and it never added the package/product to the target

        - package: Firebase
          product: FirebaseAnalytics
          product: FirebaseCrashlytics
          product: FirebaseMessaging
          product: FirebasePerformance
          product: FirebaseInAppMessaging
          product: FirebaseRemoteConfig

Finally I decided to try this nonsense and it worked adding the products to the target

        - package: Firebase
          product: FirebaseAnalytics
        - package: Firebase
          product: FirebaseCrashlytics
        - package: Firebase
          product: FirebaseMessaging
        - package: Firebase
          product: FirebasePerformance
        - package: Firebase
          product: FirebaseInAppMessaging
        - package: Firebase
          product: FirebaseRemoteConfig

This was very unintuitive....please improve!

brandtdaniels avatar Feb 23 '22 22:02 brandtdaniels

Wow... I just wasted so much time trying to figure this out... of course now that I know the answer I easily found it mentioned in the documentation but passed over it several times. ughh...

From the Project Spec:

Package dependency

[ ] product: String - The product to use from the package. This defaults to the package name, so is only required if a Package has multiple libraries or a library with a differing name

packages:
  Yams:
    url: https://github.com/jpsim/Yams
    majorVersion: 2.0.0
  SwiftPM:
    url: https://github.com/apple/swift-package-manager
    branch: swift-5.0-branch
targets:
  App:
    dependencies:
      - package: Yams 
      - package: SwiftPM
        product: SPMUtility

chrisg123 avatar Mar 28 '22 20:03 chrisg123

I'm happy to accept a PR that adds a products array, but otherwise this is how Xcode models it.

yonaskolb avatar Mar 31 '22 04:03 yonaskolb

Updated documentation would be nice. It took me forever to find this but I'm not sure it necessarily warrants a change.

tyten avatar May 12 '22 21:05 tyten

https://github.com/yonaskolb/XcodeGen/pull/1395 has been merged which allows for specifying multiple products at once for each package

yonaskolb avatar Sep 11 '23 01:09 yonaskolb