Swift package generate-xcodeproj and binaryTargets in Package.swift

Will it ever be possible to generate an Xcode project from a Package.swift which contains a reference to binaryTarget?

Currently it fails silently, and in the code it has this:

Is there any timeline to get this supported, or should generate-xcodeproj be avoided by developers that work with binary targets in their packages?

1 Like

I have this exact same issue. I extracted some C/C++ dependencies that I used to compile and had to vendor through my source repo into a binary Swift Package and now I'm unable to generate Xcode Projects that depend on it. It also prevents me from running tests for Apple platform targets since SPM itself can only run tests against macOS and Linux.

I ended up opening an issue SR-13615

You can use xcodebuild directly on a Package.swift without needing to generate a project first. That uses Xcode's built in SwiftPM support which should solve your issue

Sometimes it’s necessary to generate frameworks, especially given the fact that directly using xcodebuild sometimes does not see all public headers that some packages I use define. It is also important to be able to build frameworks directly because it’s faster to distribute in comparison to having bare .o files with bare swift modules. Also, it’s very important that sometimes direct xcodebuild does not generate swift modules for C targets in packages even though it does that when generate-xcodeproj is used.

In the SR ticket I linked I actually mentioned in my case xcodebuild is not working either. I get this issue:
multiple configured targets of <Generated_Scheme> are being created for iOS Simulator

They may be unrelated but unfortunately isn’t a workaround in my case.

Terms of Service

Privacy Policy

Cookie Policy