gpt4 book ai didi

ios - 使用 xcodebuild 创建 watchOS2 模拟器构建

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:14:03 26 4
gpt4 key购买 nike

我想使用终端和 xcodebuild 构建一个模拟器。到目前为止,传递类似于“-sdk iphonesimulator9.0”的东西是有效的。现在 watch 扩展正在 watch 上运行,我收到此错误:

=== 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 的模拟器版本的应用吗?

谢谢!

最佳答案

我刚刚找到了解决方案:要从终端构建胖模拟器,我必须执行以下步骤:基本上,解决方案是使用 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 }"

为了能够从中找出设备 ID,我必须将此 stderr 输出重定向到此命令的标准输入

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

在我的 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 "$SIMULATOR_TARGET_DESTINATION"ONLY_ACTIVE_ARCH=NO

关于“ONLY_ACTIVE_ARCH=NO”:

这样我就可以生成胖构建,而不仅仅是针对一种架构(i386 或 x86_64)的构建。

关于ios - 使用 xcodebuild 创建 watchOS2 模拟器构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32355513/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com