yonaskolb / XcodeGen

A Swift command line tool for generating your Xcode project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Adding a swift package with multiple products was confusing

brandtdaniels opened this issue · 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!

commented

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

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

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

#1395 has been merged which allows for specifying multiple products at once for each package