为 iOS 模拟器构建发布版本?

Posted

技术标签:

【中文标题】为 iOS 模拟器构建发布版本?【英文标题】:Building a Release build for iOS Simulator? 【发布时间】:2020-11-04 17:28:36 【问题描述】:

我正在尝试使用xcodebuild CLI 来构建我的应用程序,其中包含“发布配置”(-c Release) 和 ios 模拟器的目标 (-destination "platform: iOS Simulator")。但是,xcodebuild 似乎不支持这种行为,因为它的响应是:

$ xcodebuild -workspace Y.xcworkspace -scheme X -configuration Release -destination 'platform=iOS Simulator'
                           
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 "X" scheme:
         platform:iOS Simulator, id:E01124DF-3E66-490B-BD28-351FF6CD3D1A, OS:14.1, name:iPad (8th generation) 
         platform:iOS Simulator, id:40233395-556F-4A5B-A499-A238C4FA159A, OS:14.1, name:iPad Air (4th generation) 
         platform:iOS Simulator, id:FE1018BD-4128-4E1F-9FE8-FEA4054DD8A8, OS:14.1, name:iPad Pro (9.7-inch) 
         platform:iOS Simulator, id:88F79AD4-1F96-48B8-897B-D74DB4D6BBC2, OS:14.1, name:iPad Pro (11-inch) (2nd generation) 
         platform:iOS Simulator, id:54BA4991-5C8D-41E4-9615-AEFDFAF167ED, OS:14.1, name:iPad Pro (12.9-inch) (4th generation) 
         platform:iOS Simulator, id:2BEF87F9-5F1A-4339-B2C4-B9E634D03DB4, OS:14.1, name:iPhone 8 
         platform:iOS Simulator, id:E9CFA859-26B4-4009-A2FB-80161792FA30, OS:14.1, name:iPhone 8 Plus 
         platform:iOS Simulator, id:DA1BE525-88B4-46F9-BE22-2EE2F46B669E, OS:14.1, name:iPhone 11 
         platform:iOS Simulator, id:5C658068-B26A-4265-9D49-D84084BFBB4F, OS:14.1, name:iPhone 11 Pro 
         platform:iOS Simulator, id:455801A6-11F7-473B-97EB-FFE991C0CF48, OS:14.1, name:iPhone 11 Pro Max 
         platform:iOS Simulator, id:7FC46741-BE28-4FA1-9921-6D341EAC5A36, OS:14.1, name:iPhone 12 
         platform:iOS Simulator, id:F5321E54-6500-4349-9175-C9715F3E230B, OS:14.1, name:iPhone 12 Pro 
         platform:iOS Simulator, id:B3F46645-5380-4566-9070-DA25817B88D2, OS:14.1, name:iPhone 12 Pro Max 
         platform:iOS Simulator, id:EBA39463-9D2E-40AB-B2E7-E802D8AE8680, OS:14.1, name:iPhone 12 mini 
         platform:iOS Simulator, id:16F15877-230B-46FC-A36C-C984DFE12E66, OS:14.1, name:iPhone SE (2nd generation) 
         platform:iOS Simulator, id:1588FB27-6FD2-4970-9D55-FF430006C766, OS:14.1, name:iPod touch (7th generation) 

    Ineligible destinations for the "X" scheme:
         platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device 
         platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Any iOS Simulator Device 
         platform:macOS, variant:Mac Catalyst, name:Any Mac 

TLDR:

    为什么将 Any iOS Simulator Device 选项列为不合格?

    有没有办法为模拟器创建发布风格的构建?

注意:我也尝试使用 -sdk iphonesimulator 选项而不是 -destination ...,但我的 iOS 应用程序包含一个 WatchKit 应用程序,当它尝试构建该依赖项时会混淆 xcode。

【问题讨论】:

“为什么将任何 iOS 模拟器设备选项列为不合格”因为它没有任何意义。没有任何 iOS 模拟器之类的东西。您为特定的模拟设备构建。 【参考方案1】:

啊,想通了。我只是错过了“通用”说明符。所以应该是:

-destination "generic/platform=iOS Simulator"

【讨论】:

以上是关于为 iOS 模拟器构建发布版本?的主要内容,如果未能解决你的问题,请参考以下文章

如何在模拟器上安装 iOS 应用发布版本

为 iOS 编译 Flutter 项目时的 Xcode 构建问题

无法为颤振模拟器构建应用程序

为 iOS 模拟器构建,但链接框架“****.framework”是为 iOS 构建的

Flutter - 为 iOS 模拟器构建

Siphon 为 iOS 模拟器构建,但在设备构建时出现链接器错误