Xcodebuild: Unable to find a destination matching the provided destination specifier
Asked Answered
A

5

6

I want to test same unit test on various platform versions. However, I can't due to a xcodebuild error.

I built my project

 xcodebuild build-for-testing \
     -configuration Debug \
     -scheme UnitTest \
     -sdk iphonesimulator \
     -enableCodeCoverage YES \
     -derivedDataPath "derivedData"

and test project executed successfully with the following command:

xcodebuild test-without-building \
    -configuration Debug \
    -derivedDataPath "derivedData" \
    -resultBundlePath TestResultsA \
    -project UTSSampleSwift.xcodeproj \
    -scheme UnitTest \
    -sdk iphonesimulator \
    -destination 'platform=iOS Simulator,OS=13.5,name=iPhone SE (2nd generation)' \
    -enableCodeCoverage YES

I want to test on OS=12.2 and I already installed the simulators for 12.2 However, the following command fails

xcodebuild test-without-building \
    -configuration Debug \
    -derivedDataPath "derivedData" \
    -resultBundlePath TestResultsE \
    -project UTSSampleSwift.xcodeproj \
    -scheme UnitTest \
    -sdk iphonesimulator \
    -destination 'platform=iOS Simulator,OS=12.2,name=iPhone 8' \
    -enableCodeCoverage YES

With error message:

Build settings from command line:
    SDKROOT = iphonesimulator13.5

xcodebuild: error: Unable to find a destination matching the provided destination specifier:
                { platform:iOS Simulator, OS:12.2, name:iPhone 8 }

        Available destinations for the "UnitTest" scheme:
                { platform:macOS, arch:x86_64, variant:Mac Catalyst, id:521A4BA2-C8DB-50F6-9112-FA4FB75F8B5D }
                { platform:iOS Simulator, id:FB9D6640-64BC-48D2-869F-2D8AE3D10984, OS:13.5, name:iPad (7th generation) }
                { platform:iOS Simulator, id:2327E5B6-8073-4DA7-BB2C-4D9F29E8A74F, OS:13.5, name:iPad Air (3rd generation) }
                { platform:iOS Simulator, id:176CD5F5-F59D-401F-8D9C-2567C97BF14F, OS:13.5, name:iPad Pro (9.7-inch) }
                { platform:iOS Simulator, id:50CDB544-EB94-494D-BA02-2A387F49C36A, OS:13.5, name:iPad Pro (11-inch) (2nd generation) }
                { platform:iOS Simulator, id:2D39CA24-88E5-4012-A461-63404BBF8DD5, OS:13.5, name:iPad Pro (12.9-inch) (4th generation) }
                { platform:iOS Simulator, id:CEC5D35B-9038-4557-ABD8-414290716B84, OS:13.5, name:iPhone 8 }
                { platform:iOS Simulator, id:A375FB0B-6F1C-4249-95B8-EC71D9FB6144, OS:13.5, name:iPhone 8 Plus }
                { platform:iOS Simulator, id:81EFCF5E-372A-4CB4-94D5-409D23237392, OS:13.5, name:iPhone 11 }
                { platform:iOS Simulator, id:884192AD-0156-4E86-87F7-BFC24D451D33, OS:13.5, name:iPhone 11 Pro }
                { platform:iOS Simulator, id:A2F32AF0-CE1E-47F3-9D5A-D3E906B7977B, OS:13.5, name:iPhone 11 Pro Max }
                { platform:iOS Simulator, id:0EB5214D-201F-405F-BDAF-E77089398CA9, OS:13.5, name:iPhone SE (2nd generation) }

        Ineligible destinations for the "UnitTest" 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 }

What should I do?

Additional information

xcodebuild -version

Xcode 11.5
Build version 11E608c

xcodebuild -showsdks

iOS SDKs:
    iOS 13.5                        -sdk iphoneos13.5
iOS Simulator SDKs:
    Simulator - iOS 13.5            -sdk iphonesimulator13.5
Audley answered 6/7, 2020 at 7:51 Comment(0)
M
4

I had a similar issue and the issue was my project deployment target was too high. Double check your deployment target is iOS 12.2 or lower.

Mining answered 28/5, 2021 at 20:27 Comment(0)
C
1

For me the following worked when using React Native 0.68.1.

From the ios directory:

$ pod deintegrate
$ pod install
Copyholder answered 9/6, 2022 at 1:18 Comment(0)
K
0

This error may occur when an older project is used in a newer version of Xcode. It is strange, that the error is shown, although the destination clearly exists.

The actual step, which fixed it for me was to enable Test Plans (after increasing the deployment target to the smallest supported value for the Xcode version).

To do that, edit the main scheme and select the section "Test". Likely there is a button "Convert to use Test Plans...":

Scheme editor in Test section

When you click it, a confirmation appears:

Confirmation dialog

After I adjusted the test plan, the command line test command succeeded.

EDIT:

It turns out, that if the testplan has no tests at all, the error occurs. If the testplan has tests, but they are disabled, the error does not occur.

Khalilahkhalin answered 24/7, 2023 at 20:36 Comment(0)
O
-1

i downgraded all iOS deployment targets in Xcode from 12.0 to 10.0 and in the Podfile decreased the platform from 12.0 to 10.0 and i was finally able to resolve this deployment error.

Obsequious answered 26/7, 2022 at 3:30 Comment(0)
B
-1

This issue may arise when you attempt to run a product in Xcode under a release configuration rather than Debug one. It's worth noting that the error is displayed even when the destination is clearly defined. The problem might be related to attempting to execute a release build on a simulator, which is not a valid operation. To resolve this issue, you can consider the following steps:

To address this, -Open Xcode, -Go to "Product" -Select "Scheme" -Choose "Edit Scheme." Then, make sure to set the build configuration to "Debug."

hopefully it should solve this,

Scheme

Battue answered 24/10, 2023 at 17:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.