Post

Replies

Boosts

Views

Activity

xcodebuild for non-macOS target with macOS tool dependencies
I have a fun problem. I have a Catalyst app which builds for iOS, macOS and tvOS. The app target in Xcode depends on a command line tool target, also in Xcode. The command line tool target is actually kind of a dummy, but it pulls in some other dependencies via SPM, which causes SPM to build the real command line tool am using. The Xcode target mostly just exists to cause this build to happen, but also does a bit of other stuff via a run script phase. When I build (or archive) this for a non-macOS architecture in Xcode, it does the right thing. The main application builds using the sdk for the selected architecture (eg iOS), but the dependent tool builds with the sdk for macOS. The SPM dependencies inherit this sdk and do TheRightThing™. As part of my automated release process, I archive using xcodebuild. To get the iOS version of the application to build, I am using -sdk iphoneos. Unfortunately, the dependent tool target chooses to honour this setting too, and attempts to build itself for iOS. This in turn causes the SPM dependencies to try to build for iOS - and fail. Is there a better way to tell xcodebuild which architecture to build? I'm not sure if it's strictly speaking a build that all of the targets are trying to use the sdk I passed in on the command line, but it feels as though it probably is. Either way, can anyone think of a workaround. I am seeing this behaviour with Xcode 12b1. Unfortunately I can't go back to try it on 11.6 right now because the SPM package is using some Swift 5.3 features (specifically, resources).
6
0
4.8k
Jun ’20