ios xcodebuild:模拟器还是设备?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5010062/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
xcodebuild: simulator or device?
提问by Steven Fisher
How do I specify to xcodebuild
(the command line tool) whether I want to build for the simulator or device?
如何指定xcodebuild
(命令行工具)是要为模拟器还是设备构建?
回答by Kendall Helmstetter Gelner
An XCode build from the command line looks like:
从命令行构建的 XCode 如下所示:
xcodebuild -configuration ${BUILD_TYPE} -target ${TARGET_NAME} -arch ${CPU_ARCHITECTURE} -sdk ${SIMULATOR_OR_IOS_SDK}
BUILD_TYPE
is something like "Release" or "Debug" (those are the defaults, you may have added others to the project)
BUILD_TYPE
类似于“发布”或“调试”(这些是默认值,您可能已将其他人添加到项目中)
TARGET_NAME
is the name of the target you are building (by default the same name as your project)
TARGET_NAME
是您正在构建的目标的名称(默认情况下与您的项目名称相同)
CPU_ARCHITECTURE
is the CPU you are building for, one of:
CPU_ARCHITECTURE
是您正在构建的 CPU,以下之一:
i386, armv6, armv7
i386、armv6、armv7
Use i386 for simulator builds, and use either armv6 or armv7 for device builds - note that some other devices cannot run armv7 code, so usually when building libraries it's a good idea to build all of these architectures and then glue them together using lipo
.
将 i386 用于模拟器构建,并使用 armv6 或 armv7 进行设备构建 - 请注意,某些其他设备无法运行 armv7 代码,因此通常在构建库时,最好构建所有这些架构,然后使用lipo
.
SIMULATOR_OR_IOS_SDK
is what you are looking for, it's either iphoneos
or iphonesimulator
. Those values use the latest version of the SDK that the installed XCode supports, you can get a list of supported SDK's with:
SIMULATOR_OR_IOS_SDK
是您要查找的内容,它是iphoneos
或iphonesimulator
。这些值使用已安装的 XCode 支持的最新版本的 SDK,您可以使用以下命令获取受支持的 SDK 列表:
xcodebuild -showsdks
Which returns a list like:
它返回一个列表,如:
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
has more flags than that, but those are the ones you'd commonly use after using XCode to set up the build properties. You don't have to use all of them, but it's probably a good idea to be clear about what you are building - otherwise I believe your last settings are used.
xcodebuild
有比这更多的标志,但这些是您在使用 XCode 设置构建属性后通常使用的标志。您不必全部使用它们,但清楚您正在构建的内容可能是一个好主意 - 否则我相信您的最后设置已被使用。
回答by justin
i find the -xcconfig
flag quite useful. this option allows you to specify a path to an xcconfig (build settings file). within an xcconfig, you may #include
other xcconfig files.
我觉得这个-xcconfig
标志很有用。此选项允许您指定 xcconfig(构建设置文件)的路径。在 xcconfig 中,您可以使用#include
其他 xcconfig 文件。