1
votes

I'm trying to build several targets and I already have Build Settings per target in Xcode. I also have a scheme per target. What I'm trying to do is issue one command line instruction to build each target, something like:

xcodebuild -project MyProject.xcodeproj -scheme PRODScheme archive -archivePath /Users/myUser/Documents/PRODApps/archives/"${PRODUCT_NAME}".xcarchive -configuration Release

Here, ${PRODUCT_NAME} is the Build Setting variable defined by XCode. I'm thinking on how xcodebuild can make use of the bunch of already defined settings.

Is there a way of reusing those settings in xcodebuild?

1
As a side note, the quotes in the archive path are incorrect. The proper line would be: -archivePath "/Users/myUser/Documents/PRODApps/archives/${PRODUCT_NAME}.xcarchive" You would place the quotes around the whole path. - Black Frog
@BlackFrog - I already tried what's Vincent has in his blog. Running the suggested command: xcodebuild -target "${PROJECT_NAME}" -sdk "${TARGET_SDK}" -configuration Release I get xcodebuild: error: The project 'MyProject.xcodeproj' does not contain a target named ''. because ${PROJECT_NAME} gets not value from the Build Settings... my whole point in my question above. BTW, changing quotes as suggested, didn't do much difference, no error, no gain either. In both cases the result is the same: empty/null values for the ${FOO} settings. - carlos_ms
Try removing the { }, i.e. "$PROJECT_NAME" - l'L'l
been there, done that... doesn't bring the build setting value either. - carlos_ms

1 Answers

1
votes

Typically you would use the scheme, which would contain the other information you are trying to include:

xcodebuild -scheme PRODScheme build

To use with a configuration file you would use:

xcodebuild -target MyProject.xcodeproj -xcconfig configuration.xcconfig

To build all targets use -alltargets


Command Line tech notes: https://developer.apple.com/library/ios/technotes/tn2339/_index.html

Man xcodebuild: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/xcodebuild.1.html