Xcodebuild: simulator or device?

How can I tell xcodebuild (command line tool) if I want to build for a simulator or device?

+54
ios iphone xcode xcodebuild
Feb 15 '11 at 22:03
source share
2 answers

A line from Xcode from the command line looks like this:

 xcodebuild -configuration ${BUILD_TYPE} -target ${TARGET_NAME} -arch ${CPU_ARCHITECTURE} -sdk ${SIMULATOR_OR_IOS_SDK} 

BUILD_TYPE is something like "Release" or "Debug" (these are the default values, maybe you added others to the project)

TARGET_NAME - the name of the goal you are building (defaults to the name of your project)

CPU_ARCHITECTURE is the processor for which you are building, one of:

i386 , armv6 , armv7

Use i386 to build a simulator and use armv6 or armv7 to build devices - note that some other devices cannot run armv7 code, so it is usually recommended to create all these architectures when creating libraries and then gluing them together using lipo .

SIMULATOR_OR_IOS_SDK is what you are looking for, it is either iphoneos or iphonesimulator . These values ​​use the latest version of the SDK that the installed Xcode supports, you can get a list of supported SDKs with:

 xcodebuild -showsdks 

Which returns a list, for example:

 Mac OS X SDKs: Current Mac OS -sdk 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 

xcodebuild contains more flags, but the ones you usually use after using Xcode to set build properties. You don’t have to use all of them, but it would probably be nice to understand what you are building - otherwise I think your latest settings are being used.

+121
Feb 15 '11 at 23:18
source share

I found the -xcconfig flag quite useful. this parameter allows you to specify the path to xcconfig (build settings file). inside xcconfig you can #include other xcconfig files.

+1
Feb 16 2018-11-11T00:
source share



All Articles