如何在带有手表扩展的Xcode 7中使用xcodebuild

Jas*_*ker 6 xcodebuild ios9 xcode7 watchos-2 xcode7-beta3

我们的命令曾经是这样的

xcodebuild -configuration Release -target "xxx" -sdk iphoneos9.0 -scheme "xxx" archive
Run Code Online (Sandbox Code Playgroud)

现在在Xcode 7中,我们收到此错误:

Build settings from command line:
    SDKROOT = iphoneos9.0

=== BUILD TARGET xxx WatchKit Extension OF PROJECT Mobile WITH CONFIGURATION Release ===

Check dependencies
target specifies product type 'com.apple.product-type.watchkit2-extension', but there's no such product type for the 'iphoneos' platform
Run Code Online (Sandbox Code Playgroud)

我们如何指定使用iOS 9.0 SDK和watchos 2.0 SDK?

Nek*_*kto 23

如果你需要一个模拟器构建运行这个:

xcodebuild -workspace WorkspaceName.xcworkspace -scheme SchemeWithWatchOS2Target -destination 'name=iPhone 6' build
Run Code Online (Sandbox Code Playgroud)

如果你需要一个设备构建运行这个:

xcodebuild -workspace WorkspaceName.xcworkspace -scheme SchemeWithWatchOS2Target build
Run Code Online (Sandbox Code Playgroud)

诀窍是,对于任何构建,您需要删除-sdk选项.对于模拟器构建,您需要指定-destination哪个应该是iPhone 6iPhone 6 Plus.对于设备构建,您可以跳过-destination.

  • 删除-sdk参数也是我的诀窍.很棒的提示.+1 (8认同)