parameter for xcodebuild for using latest sdk.

XcodeAntIosBuildHudson

Xcode Problem Overview


I using ant exec task to execute xcodebuild to build some iOS projects hudson. I would like to be able to crate script that way that allows not to specify sdk version, because after updating sdk on hudson slave or my iOS projects all my projects failing....

There is is nice option in xcode since sdk 4.2 in target setup Base SDK - Latest iOS

and I don't have to provide -sdk param in xcodebuild command, but then (i think) it's taken from xcode project and it's bad because then some one can change target from simulator to device accidentally during commit.

I need something that is constant. I will prefer not to use env variable because I would like to be able to run this ant task also on dev machines and would like not have to renember about setting it on all machines.

Unfortunately xcodebuild -showsdks gives only:

Mac OS X SDKs:
	Mac OS X 10.4                 	-sdk macosx10.4
	Mac OS X 10.5                 	-sdk macosx10.5
	Mac OS X 10.6                 	-sdk macosx10.6

iOS SDKs:
	iOS 4.2                       	-sdk iphoneos4.2

iOS Simulator SDKs:
	Simulator - iOS 3.2           	-sdk iphonesimulator3.2
	Simulator - iOS 4.0           	-sdk iphonesimulator4.0
	Simulator - iOS 4.1           	-sdk iphonesimulator4.1
	Simulator - iOS 4.2           	-sdk iphonesimulator4.2

I need something like -sdk iphoneosLatest. My only idea is to pare output of xcodebuild -showsdks with some script, but I don't like this idea.

Xcode Solutions


Solution 1 - Xcode

You can use xcodebuild with the latest SDK using :

  • xcodebuild -sdk iphoneos, for Device
  • xcodebuild -sdk iphonesimulator, for Simulator.

We use these options for our automated builds and it's been working since XCode 3.2.5

Solution 2 - Xcode

I believe you can use xcodebuild -sdk iphoneos (no version number) to accomplish this.

Solution 3 - Xcode

I tried @jenningj 's solution and it worked for me. Maciek Sawicki, if this works for you, you should mark it as the right solution.

Also, xcodebuild -showsdk should be xcodebuild -showsdks.

Solution 4 - Xcode

You can try: xcodebuild -showsdks | grep -Eo "iphoneos([0-9]{1,}\.)+[0-9]{1,}"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMaciek SawickiView Question on Stackoverflow
Solution 1 - XcodeDavid LacourtView Answer on Stackoverflow
Solution 2 - XcodeJames JView Answer on Stackoverflow
Solution 3 - XcodeThomasWView Answer on Stackoverflow
Solution 4 - Xcodeelectronix384128View Answer on Stackoverflow