tuist / XcodeProj

📝 Read, update and write your Xcode projects
https://xcodeproj.tuist.io
MIT License
2.03k stars 309 forks source link

Switching SPM products #690

Closed arielelkin closed 1 year ago

arielelkin commented 2 years ago

I have a Swift package with two library products:

let package = Package(
    name: "IRIS",
    platforms: [.macOS(.v10_10)],
    products: [
        .library(
            name: "MySDK-release",
            targets: ["sdk-release"]
        ),
        .library(
            name: "MySDK-debug",
            targets: ["sdk-debug"]
        )
    ],
    targets: [
        .binaryTarget(
            name: "sdk-release",
            url: "https://api.github.com/bar.zip",
            checksum: "..."
        ),
        .binaryTarget(
            name: "sdk-debug",
            url: "https://api.github.com/foo.zip",
            checksum: "..."
        )
    ]
)

I need to link against MySDK-debug in the debug version of my app, and against MySDK-release in the release version of my app. SPM doesn't support this, so I'm trying to find a way to do it with XcodeProj (on CI I'd run a script which uses XcodeProj to switch the product). I unfortunately can't add both products to the xcode project as they have the same symbol names, and that produces "Multiple commands produce foo.h" errors. Is there a way to do this?

pepicrft commented 1 year ago

Hey @arielelkin, Unfortunately XcodeProj is not a tool to workaround limitations of the Swift Package Manager. If you want to do something that Swift Package Manager support, I'd recommend starting a discussion in the community forum. Alternatively, you might consider: