【问题标题】:How to specify Cordova build target in build.json如何在 build.json 中指定 Cordova 构建目标
【发布时间】:2020-02-10 22:13:07
【问题描述】:

我在执行cordova build 时出错。

xcodebuild: 错误:找不到与提供的目标说明符匹配的目标:

  { platform:iOS Simulator, OS:latest, name:iPhone 11 Pro Max }

由于我的应用仅在 iPad 上构建,我想我需要为 iPad 设置构建目标,但我不确定如何执行此操作。

版本

  • XCode:版本 11.1 (11A1027)
  • 科尔多瓦:cordova@9.0.0
  • MacOS:10.15 卡特琳娜

我的 config.xml 有这些标签来指定 iPad:

    <preference name="target-device" value="tablet" />
    <preference name="deployment-target" value="10.3" />

完整的错误:

Reading build config file:
No simulator found for ". Falling back to the default target.
Building for "iPhone 11 Pro Max" Simulator (com.apple.CoreSimulator.SimDeviceType.iPhone-11-Pro-Max, iPhone-11-Pro-Max).
Building project: /Users/lucaban/.ghq/github.com/mesqueeb/sokketsu/src-cordova/platforms/ios/Sokketsu.xcworkspace
    Configuration: Debug
    Platform: emulator
    Target: iPhone 11 Pro Max
Running command: xcodebuild -workspace Sokketsu.xcworkspace -scheme Sokketsu -configuration Debug -sdk iphonesimulator -destination platform=iOS Simulator,name=iPhone 11 Pro Max build CONFIGURATION_BUILD_DIR=/Users/lucaban/.ghq/github.com/mesqueeb/sokketsu/src-cordova/platforms/ios/build/emulator SHARED_PRECOMPS_DIR=/Users/lucaban/.ghq/github.com/mesqueeb/sokketsu/src-cordova/platforms/ios/build/sharedpch
Build settings from command line:
    CONFIGURATION_BUILD_DIR = /Users/lucaban/.ghq/github.com/mesqueeb/sokketsu/src-cordova/platforms/ios/build/emulator
    SDKROOT = iphonesimulator13.1
    SHARED_PRECOMPS_DIR = /Users/lucaban/.ghq/github.com/mesqueeb/sokketsu/src-cordova/platforms/ios/build/sharedpch

xcodebuild: error: Unable to find a destination matching the provided destination specifier:
        { platform:iOS Simulator, OS:latest, name:iPhone 11 Pro Max }

    Available destinations for the "Sokketsu" scheme:
        { platform:iOS Simulator, id:B90FC025-F8EB-40B3-90C5-E9094C0FFD17, OS:13.1, name:iPad Air (3rd generation) }
        { platform:iOS Simulator, id:3131A6AD-3C4E-4CEA-8889-9C7E22EAF816, OS:13.1, name:iPad Pro (9.7-inch) }
        { platform:iOS Simulator, id:A8055BC4-F95C-43FA-8B28-7FACBD3D57B6, OS:13.1, name:iPad Pro (11-inch) }
        { platform:iOS Simulator, id:7FAD7B1C-70DD-407A-AC99-3ACAD2670726, OS:13.1, name:iPad Pro (12.9-inch) (3rd generation) }

    Ineligible destinations for the "Sokketsu" scheme:
        { platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Generic iOS Device }
        { platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Generic iOS Simulator Device }
xcodebuild: Command failed with exit code 70

【问题讨论】:

  • 我遇到了同样的问题,找不到任何可以清楚地解释如何处理的文档。 Cordova 的文档看起来需要更新。

标签: ios xcode cordova


【解决方案1】:

您需要将target-device 设置为universal,然后在完成后将其更改回Xcode 中的平板电脑。

config.xml

<preference name="target-device" value="universal" />

PS:在运行 cordova build ios 命令时,此问题可能始于 cordova-ios 版本 5.0.1。

【讨论】:

    【解决方案2】:

    您可以通过将设备名称发送为buildFlag 来解决此问题

    如果您使用的是 cordova,请使用以下命令

    cordova build ios --buildFlag="-destination platform=iOS Simulator,name=iPad Pro (11-inch)"
    

    对我来说,我在 Ionic 项目中使用它。

    ionic cordova build ios -- --buildFlag="-destination platform=iOS Simulator,name=iPad Pro (11-inch)"
    

    您可以从错误中列出的可用目的地列表中选择所需的任何设备名称

    【讨论】:

    • 谢谢!这个是为我做的?
    【解决方案3】:

    正如您在终端中看到的那样: xcodebuild:错误:找不到与提供的目标说明符匹配的目标:

    { 平台:iOS 模拟器,操作系统:最新,名称:iPhone 11 Pro Max }

    您可以按照以下步骤操作:

    1. 转到 Xcode

    2. 在模拟器目标下单击“添加其他模拟器”

    3. 弹出此屏幕后,单击左下角的 + 图标

    4. 它将显示一个添加新模拟器的屏幕:添加构建失败的模拟器,在这种情况下:iPhone 11 Pro Max,选择设备类型为(iPhone 11 Pro Max)和最新的操作系统版本。

    5. 转到终端并再次尝试构建命令。

    【讨论】:

      猜你喜欢
      • 2019-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-01
      • 2016-09-19
      • 2021-04-17
      • 2017-05-06
      相关资源
      最近更新 更多