Ios 使用xcodebuild创建watchOS2模拟器构建

Ios 使用xcodebuild创建watchOS2模拟器构建,ios,build,simulator,xcodebuild,watchos-2,Ios,Build,Simulator,Xcodebuild,Watchos 2,我想使用Terminal和xcodebuild构建一个模拟器构建。到目前为止,通过类似于“-sdk iphonesimulator9.0”的程序仍然有效。现在手表扩展正在手表上运行,我收到以下错误: === BUILD TARGET appName WatchKit Extension OF PROJECT appName WITH CONFIGURATION Debug === Check dependencies target specifies product type 'com

我想使用Terminal和xcodebuild构建一个模拟器构建。到目前为止,通过类似于“-sdk iphonesimulator9.0”的程序仍然有效。现在手表扩展正在手表上运行,我收到以下错误:

=== BUILD TARGET appName WatchKit Extension OF PROJECT appName WITH     CONFIGURATION Debug ===

Check dependencies
target specifies product type 'com.apple.product-type.watchkit2-extension',     but there's no such product type for the 'iphonesimulator' platform
你知道一个人如何为自己的应用程序构建一个支持watchOS2的模拟器版本吗


谢谢

我刚刚找到了解决方案: 要从终端构建fat模拟器构建,我必须执行以下步骤: 基本上,解决方案是使用xcodebuild的-destination选项

我必须找到一个模拟器目标,将其配置为目标:

    SIMULATOR_TARGET_DESTINATION=$("/xcode_7/Xcode.app/Contents/Developer/usr/bin/xcodebuild" -workspace MyApp.xcworkspace -scheme MyApp -configuration MyConfiguration -derivedDataPath My/DerivedData/Path clean build -destination 'platform=iOS Simulator' 2>&1 >/dev/null | grep id: | head -n 1 | awk '{print $4}' | tr ":" "=" | tr -d ",")
关于“2>&1>/dev/null”部分: 上一个命令的第一部分:

"/xcode_7/Xcode.app/Contents/Developer/usr/bin/xcodebuild" -workspace MyApp.xcworkspace -scheme MyApp -configuration MyConfiguration -derivedDataPath My/DerivedData/Path clean build -destination 'platform=iOS Simulator'
将如下内容打印到stderr:

xcodebuild: error: Unable to find a destination matching the provided destination specifier:
    { platform:iOS Simulator }

Missing required device specifier option.
The device type “iOS Simulator” requires that either “name” or “id” be specified.
Please supply either “name” or “id”.

Available destinations for the "MyApp" scheme:
    { platform:iOS Simulator, id:3B706D94-89BE-46A3-81C7-34CA2F91B823, OS:9.1, name:iPad 2 }
    { platform:iOS Simulator, id:BE272A9F-4653-4633-9C51-2524AE6AE7D1, OS:9.1, name:iPad 2 }
    { platform:iOS Simulator, id:830CDD58-FF1C-4436-BDF8-0F05452317C7, OS:9.1, name:iPad Air }
    { platform:iOS Simulator, id:B36B366A-A993-4C92-BADC-8C0772320067, OS:9.1, name:iPad Air }
    { platform:iOS Simulator, id:71A801F9-E5CD-4E3A-B46B-882F6ECC7209, OS:9.1, name:iPad Air 2 }
    { platform:iOS Simulator, id:A314088B-2CA5-4F73-B528-9F82C2689156, OS:9.1, name:iPad Air 2 }
    { platform:iOS Simulator, id:0BD94515-1DBE-4A79-B618-FC077539A581, OS:9.1, name:iPad Pro }
    { platform:iOS Simulator, id:471B94A3-67EE-4A4C-BB41-86DB2EE2F11A, OS:9.1, name:iPad Pro }
    { platform:iOS Simulator, id:D39DDDC0-0A1E-4A7E-B9A0-449FD1FE129C, OS:9.1, name:iPad Retina }
    { platform:iOS Simulator, id:F716E5A4-93F7-43B1-94EE-9BE358E4670C, OS:9.1, name:iPad Retina }
    { platform:iOS Simulator, id:5458CA06-BBAE-46E8-9A3E-90E4AE5FEA87, OS:9.1, name:iPhone 4s }
    { platform:iOS Simulator, id:92C98913-F79D-420F-B79B-5387C12B017D, OS:9.1, name:iPhone 4s }
    { platform:iOS Simulator, id:576A754E-3421-4254-A9E9-692844FDFD02, OS:9.1, name:iPhone 5 }
    { platform:iOS Simulator, id:EE446826-3BB6-4081-B28F-8DF115C33776, OS:9.1, name:iPhone 5 }
    { platform:iOS Simulator, id:D4CF7855-9C77-481B-A6CF-68BE8C736695, OS:9.1, name:iPhone 5s }
    { platform:iOS Simulator, id:E332A751-0F8E-4F2A-B27B-35C904300029, OS:9.1, name:iPhone 5s }
    { platform:iOS Simulator, id:0B30A782-0D6F-4398-8F73-F2FCB72F0F31, OS:9.1, name:iPhone 6 }
    { platform:iOS Simulator, id:FD042A1E-2A44-4803-8D01-093E63AECBF9, OS:9.1, name:iPhone 6 }
    { platform:iOS Simulator, id:D0530464-F20E-4BA4-BA49-681B057362E2, OS:9.1, name:iPhone 6 Plus }
    { platform:iOS Simulator, id:F7D70F71-BA90-4F14-9935-BE5447997D8E, OS:9.1, name:iPhone 6 Plus }
    { platform:iOS Simulator, id:B157D201-9673-49A6-9D8A-F6CC43F9350F, OS:9.1, name:iPhone 6s }
    { platform:iOS Simulator, id:B9600BC7-EFE5-4A83-9916-9042B8609A14, OS:9.1, name:iPhone 6s }
    { platform:iOS Simulator, id:69254BE7-1F54-4AA7-8484-B270FF059A57, OS:9.1, name:iPhone 6s Plus }
    { platform:iOS Simulator, id:7F39C8DC-1582-4273-AA3E-5FEE19D4B3B0, OS:9.1, name:iPhone 6s Plus }"
为了能够从中grep出一个设备id,我必须将这个stderr输出重定向到这个命令的stdin

现在我有了这样的东西:
id=3B706D94-89BE-46A3-81C7-34CA2F91B823

在我的模拟器\目标\目标变量中,我可以使用它来实际创建构建:
“/xcode\u 7/xcode.app/Contents/Developer/usr/bin/xcodebuild”-workspace MyApp.xcworkspace-scheme MyApp-配置MyConfiguration-derivedDataPath My/DerivedData/Path clean build-destination“$SIMULATOR\u TARGET\u destination”ONLY\u ACTIVE\u ARCH=NO

关于“仅活动拱门=否”: 通过这种方式,我可以生成一个fat构建,而不仅仅是一个架构(i386或x86_64)的构建。

很好的方法

有时,我的Jenkins构建由于复制的模拟器而失败(主要是在使用
快照重置\u模拟器之后)

长话短说,我需要获得第一个可用的模拟器UUID,并将其作为参数传递给
xcodebuild
。根据你的回答,我的结局是这样的:

# Finds the UUID of the first "iPhone" simulator available
# (sometimes the simulators get duplicated, which can break the build)
#
# instruments -s devices    // Shows list of known devices
# grep "iPhone"             // Self explanatory. May return more than one currence.
# head -1                   // Displays only the first line of the previous grep
# awk '{print $4}'          // Displays the fourth argument of the previous line, which represent the UUID
# tr -d '[]'                // Removes the following characters of the returned UUID "[" and "]"
#
SIM_ID=$(instruments -s devices | grep "iPhone" | head -1 | awk '{print $4}' | tr -d '[]')

# Builds and runs tests
xcodebuild -workspace MyWorkspace.xcworkspace -sdk iphonesimulator -destination id=$SIM_ID -scheme MyScheme test

效果很好。谢谢分享。

这篇文章应该能回答你的问题:我相信你可以通过
-destination'platform=iOS模拟器,name=iphone6'
简化这个问题,并跳过提取
id