1

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?

7
  • 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. Commented Jan 5, 2015 at 17:56
  • possible duplicate of Xcode "Build and Archive" from command line Commented Jan 5, 2015 at 17:56
  • @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. Commented Jan 5, 2015 at 20:23
  • Try removing the { }, i.e. "$PROJECT_NAME" Commented Jan 5, 2015 at 20:58
  • been there, done that... doesn't bring the build setting value either. Commented Jan 5, 2015 at 21:00

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

I tried before your suggested solution but it won't do what I'm looking for either. That puts the archive in the path set in Xcode and uses the TARGET_NAME. If you see my question, you'll see that what I'm trying to do is to use PRODUCT_NAME build setting's value -from Xcode- and use that as the path to my xcarchive file. If this is possible, then my next command-line would be xcodebuild -exportArchive -exportFormat ipa -archivePath "/Users/myUser/Documents/PRODApps/archives/${PRODUCT_NAME}.xcarchive" -exportPath "/Users/myUser/Documents/PRODApps/ipas/${PRODUCT_NAME}.ipa"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.