Skip to content

fix: run target with and without hyphens#1596

Open
GitToTheHub wants to merge 10 commits intomasterfrom
pr-fix-run
Open

fix: run target with and without hyphens#1596
GitToTheHub wants to merge 10 commits intomasterfrom
pr-fix-run

Conversation

@GitToTheHub
Copy link
Copy Markdown
Contributor

@GitToTheHub GitToTheHub commented Dec 24, 2025

  • Under some circumstances the run on an identifiers like cordova run ios --target="iPhone-16-Pro, 18.5" did not work
  • Support identifiers with and without hypens, like iPhone-16-Pro, 18.5 and iPhone 16 Pro, 18.5
  • Prioritize booted devices to run on
  • Use UDID to handle cases with duplicate simulators
  • Generated-By: Visual Studio Code Copilot, GPT-5, GPT-5.1-Codex-Max

Platforms affected

Motivation and Context

I wanted to test in two simulators:

  • iPhone 16 Pro, iOS 18.5
  • iPhone 17 Pro, iOS 26.2

When I do cordova run ios --list, I get:

Available iOS Devices:
Available iOS Simulators:
	iPhone-17-Pro, 26.2
	iPhone-17-Pro-Max, 26.2
	iPhone-Air, 26.2
	iPhone-17, 26.2
	iPhone-16e, 18.5
	iPhone-16e, 26.2
	iPad-Pro-13-inch-M5-12GB, 26.2
	iPad-Pro-11-inch-M5-12GB, 26.2
	iPad-Pro-11-inch-M4-8GB, 18.5
	iPad-Pro-13-inch-M4-8GB, 18.5
	iPad-mini-A17-Pro, 18.5
	iPad-mini-A17-Pro, 26.2
	iPad-Air-13-inch-M3, 18.5
	iPad-Air-13-inch-M3, 26.2
	iPad-Air-11-inch-M3, 18.5
	iPad-Air-11-inch-M3, 26.2
	iPhone-16-Pro, 18.5
	iPhone-16-Pro-Max, 18.5
	iPhone-16, 18.5
	iPhone-16-Plus, 18.5
	iPhone-16-Plus, 26.2
	iPad-A16, 18.5
	iPad-A16, 26.2

When I tried to run

cordova run ios --target="iPhone-16-Pro, 18.5"

it always failed with this log:

Building for "iPhone 16 Pro" Simulator (com.apple.CoreSimulator.SimDeviceType.iPhone-16-Pro, iPhone-16-Pro).
Building project: /Users/manuelbeck/Projekte/Cordova/inappbrowser-test/platforms/ios/App.xcworkspace
	Configuration: Debug
	Platform: emulator
	Target: iPhone 16 Pro
Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace App.xcworkspace -scheme App -configuration Debug -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 16 Pro" build

Build settings from command line:
    SDKROOT = iphonesimulator26.2

Resolve Package Graph


Resolved source packages:
  Cordova: /Users/manuelbeck/Projekte/Cordova/inappbrowser-test/platforms/ios/packages/cordova-ios @ local
  CordovaPlugins: /Users/manuelbeck/Projekte/Cordova/inappbrowser-test/platforms/ios/packages/cordova-ios-plugins @ local

2025-12-24 08:24:27.323 xcodebuild[67011:3890314] Writing error result bundle to /var/folders/dd/pn74z8g12134x2j32447spch0000gn/T/ResultBundle_2025-24-12_08-24-0027.xcresult
xcodebuild: error: Unable to find a device matching the provided destination specifier:
		{ platform:iOS Simulator, OS:latest, name:iPhone 16 Pro }

	The requested device could not be found because no available devices matched the request.

	Available destinations for the "App" scheme:
		{ platform:macOS, arch:arm64, variant:Mac Catalyst, id:00008132-000479040283001C, name:My Mac }
		{ platform:macOS, arch:x86_64, variant:Mac Catalyst, id:00008132-000479040283001C, name:My Mac }
		{ platform:iOS, arch:arm64, id:00008030-001A09410213802E, name:iPhone von Manuel }
		{ 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 }
		{ platform:iOS Simulator, arch:arm64, id:A6F204F6-2F93-467E-BDB4-4E2CBA240808, OS:18.5, name:iPad (A16) }
		{ platform:iOS Simulator, arch:x86_64, id:A6F204F6-2F93-467E-BDB4-4E2CBA240808, OS:18.5, name:iPad (A16) }
		{ platform:iOS Simulator, arch:arm64, id:7DC45C5B-6156-4019-A4B7-37FF5DDEFADA, OS:26.2, name:iPad (A16) }
		{ platform:iOS Simulator, arch:arm64, id:85505E96-F4D2-45B5-A200-778A7BF15F8F, OS:18.5, name:iPad Air 11-inch (M3) }
		{ platform:iOS Simulator, arch:x86_64, id:85505E96-F4D2-45B5-A200-778A7BF15F8F, OS:18.5, name:iPad Air 11-inch (M3) }
		{ platform:iOS Simulator, arch:arm64, id:EE79BC7E-07B0-4B74-B69F-12D6F57F6E9B, OS:26.2, name:iPad Air 11-inch (M3) }
		{ platform:iOS Simulator, arch:arm64, id:5A217808-545F-411B-9A98-BB0EC01E6ADA, OS:18.5, name:iPad Air 13-inch (M3) }
		{ platform:iOS Simulator, arch:x86_64, id:5A217808-545F-411B-9A98-BB0EC01E6ADA, OS:18.5, name:iPad Air 13-inch (M3) }
		{ platform:iOS Simulator, arch:arm64, id:AA7145A2-84DB-4458-9C22-30E3C7D9DD74, OS:26.2, name:iPad Air 13-inch (M3) }
		{ platform:iOS Simulator, arch:arm64, id:3438A97D-4024-4361-B2E2-BF99573F7B16, OS:18.5, name:iPad Pro 11-inch (M4) }
		{ platform:iOS Simulator, arch:x86_64, id:3438A97D-4024-4361-B2E2-BF99573F7B16, OS:18.5, name:iPad Pro 11-inch (M4) }
		{ platform:iOS Simulator, arch:arm64, id:2D2B63DC-75C6-4522-92CF-4B325CA0479D, OS:26.2, name:iPad Pro 11-inch (M5) }
		{ platform:iOS Simulator, arch:arm64, id:5EE77EED-19BD-4E3E-954E-EC3F5154E78A, OS:18.5, name:iPad Pro 13-inch (M4) }
		{ platform:iOS Simulator, arch:x86_64, id:5EE77EED-19BD-4E3E-954E-EC3F5154E78A, OS:18.5, name:iPad Pro 13-inch (M4) }
		{ platform:iOS Simulator, arch:arm64, id:E433B1A5-B48E-4C87-9441-7DE569ED1E3E, OS:26.2, name:iPad Pro 13-inch (M5) }
		{ platform:iOS Simulator, arch:arm64, id:80A03BC4-A1B5-438A-BF53-9986E77E6742, OS:18.5, name:iPad mini (A17 Pro) }
		{ platform:iOS Simulator, arch:x86_64, id:80A03BC4-A1B5-438A-BF53-9986E77E6742, OS:18.5, name:iPad mini (A17 Pro) }
		{ platform:iOS Simulator, arch:arm64, id:ED8B3655-AA3B-426D-8F95-9A7BB744B0AE, OS:26.2, name:iPad mini (A17 Pro) }
		{ platform:iOS Simulator, arch:arm64, id:0FD83FF6-8CD4-4007-BF1F-A7803E8A35BA, OS:18.5, name:iPhone 16 }
		{ platform:iOS Simulator, arch:x86_64, id:0FD83FF6-8CD4-4007-BF1F-A7803E8A35BA, OS:18.5, name:iPhone 16 }
		{ platform:iOS Simulator, arch:arm64, id:E8DF4860-A689-418F-A524-90AA745E9406, OS:18.5, name:iPhone 16 Plus }
		{ platform:iOS Simulator, arch:x86_64, id:E8DF4860-A689-418F-A524-90AA745E9406, OS:18.5, name:iPhone 16 Plus }
		{ platform:iOS Simulator, arch:arm64, id:3073BB72-7CAD-45BA-8F60-A295C4523654, OS:26.2, name:iPhone 16 Plus }
		{ platform:iOS Simulator, arch:arm64, id:92928C2A-AB2B-44BE-9B8E-C29DF36B7A55, OS:18.5, name:iPhone 16 Pro }
		{ platform:iOS Simulator, arch:x86_64, id:92928C2A-AB2B-44BE-9B8E-C29DF36B7A55, OS:18.5, name:iPhone 16 Pro }
		{ platform:iOS Simulator, arch:arm64, id:E4D9D5C2-661E-4AA7-B31D-0D5079C002BD, OS:18.5, name:iPhone 16 Pro }
		{ platform:iOS Simulator, arch:x86_64, id:E4D9D5C2-661E-4AA7-B31D-0D5079C002BD, OS:18.5, name:iPhone 16 Pro }
		{ platform:iOS Simulator, arch:arm64, id:3FCD7184-4A9B-40E4-BAFF-C3F48AA82640, OS:18.5, name:iPhone 16 Pro Max }
		{ platform:iOS Simulator, arch:x86_64, id:3FCD7184-4A9B-40E4-BAFF-C3F48AA82640, OS:18.5, name:iPhone 16 Pro Max }
		{ platform:iOS Simulator, arch:arm64, id:575A39F0-5337-4007-BE51-946674FD8F96, OS:18.5, name:iPhone 16e }
		{ platform:iOS Simulator, arch:x86_64, id:575A39F0-5337-4007-BE51-946674FD8F96, OS:18.5, name:iPhone 16e }
		{ platform:iOS Simulator, arch:arm64, id:AA649FC2-8E71-4B18-930F-E85EA5E903A2, OS:26.2, name:iPhone 16e }
		{ platform:iOS Simulator, arch:arm64, id:D6357C05-0F08-46F7-8EEE-43026BEFEA92, OS:26.2, name:iPhone 17 }
		{ platform:iOS Simulator, arch:arm64, id:555DFD28-C8E6-47F0-AC47-7EE2D5FCC22F, OS:26.2, name:iPhone 17 Pro }
		{ platform:iOS Simulator, arch:arm64, id:E07B36A6-6876-4E54-8ED1-74AB96359D71, OS:26.2, name:iPhone 17 Pro Max }
		{ platform:iOS Simulator, arch:arm64, id:A20D9094-170E-4187-AD43-C5DEEF8F5B52, OS:26.2, name:iPhone Air }

	Ineligible destinations for the "App" scheme:
		{ platform:visionOS, id:dvtdevice-DVTiOSDevicePlaceholder-xros:placeholder, name:Any visionOS Device, error:visionOS 26.2 is not installed. Please download and install the platform from Xcode > Settings > Components. }
Command failed with exit code 70: xcodebuild -workspace App.xcworkspace -scheme App -configuration Debug -sdk iphonesimulator -destination platform=iOS Simulator,name=iPhone 16 Pro build

When I tried to use the UUID like the following:

cordova run ios --target=E4D9D5C2-661E-4AA7-B31D-0D5079C002BD 

it says:

Select last emulator from list as default.
No simulator found for "E4D9D5C2-661E-4AA7-B31D-0D5079C002BD". Falling back to the default target.

than it builds, but saying at the end

Deploying to simulator
Error: Device type "com.apple.CoreSimulator.SimDeviceType.E4D9D5C2-661E-4AA7-B31D-0D5079C002BD" could not be found.

I asked Copilot in Visual Studio Code, what's happening and it changed the two files added to this PR. After that, the following do work:

cordova run ios --target=E4D9D5C2-661E-4AA7-B31D-0D5079C002BD
cordova run ios --target="iPhone-16-Pro, 18.5"
cordova run ios --target="iPhone 16 Pro, 18.5"

I noticed that I had iPhone 16 Pro, 18.5 two times installed in XCode, but think, this was not the root cause of the problem. When I run this PR with two iPhone 16 Pro, 18.5 installed:

cordova run ios --target="iPhone-16-Pro, 18.5"   

I get the following natural error:

xcodebuild: error: Unable to find a device matching the provided destination specifier:
		{ platform:iOS Simulator, OS:18.5, name:iPhone 16 Pro }

	The requested device could not be found because multiple devices matched the request. (
    "<DVTiPhoneSimulator: 0x83286c000> {\n\t\tSimDevice: iPhone 16 Pro (E4D9D5C2-661E-4AA7-B31D-0D5079C002BD, iOS 18.5, Booted)\n}",
    "<DVTiPhoneSimulator: 0x83286c280> {\n\t\tSimDevice: iPhone 16 Pro (0C7B1CB0-BED0-4DE2-A6CC-FC4CD471A114, iOS 18.5, Shutdown)\n}"
)

It shows the error because of multiple devices matched the request. I reviewed my console history and didn't find this error, before applying the changes.

Description

Testing

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

- Under some circumstances the run on an identifiers like `iPhone-16-Pro, 18.5" did not work
- Support identifiers with and without hypens
- Support targeting a simulator UDID
- Generated-By: Visual Studio Code Copilot, GPT-5, GPT-5.1-Codex-Max
- GitHub actions was giving an error about this variable: `'val' is never reassigned. Use 'const' instead`
@GitToTheHub GitToTheHub requested a review from dpogue December 24, 2025 08:44
Copy link
Copy Markdown
Member

@dpogue dpogue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are running on an Apple Silicon-based Mac, I think you will have double versions of older simulators because they used to be universal builds with both the arm64 and x86_64 versions. Xcode 26 (on Apple Silicon) will only pull down the arm64 simulators going forward.

Unfortunately, I don't know if there's a good way to differentiate when trying to launch one...

Comment thread lib/build.js Outdated
Comment thread lib/build.js Outdated
Comment thread lib/build.js Outdated
Comment thread lib/simctlHelper.js Outdated
@GitToTheHub
Copy link
Copy Markdown
Contributor Author

If you are running on an Apple Silicon-based Mac, I think you will have double versions of older simulators because they used to be universal builds with both the arm64 and x86_64 versions. Xcode 26 (on Apple Silicon) will only pull down the arm64 simulators going forward.

Do you think, this is why I had iPhone 16 Pro double?
The interesting is, when I run this PR without hypens in the identifier, it works:

cordova run ios --target="iPhone 16 Pro, 18.5"

But gives a warning:

--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:iOS Simulator, arch:arm64, id:E8DF4860-A689-418F-A524-90AA745E9406, OS:18.5, name:iPhone 16 Plus }
{ platform:iOS Simulator, arch:x86_64, id:E8DF4860-A689-418F-A524-90AA745E9406, OS:18.5, name:iPhone 16 Plus }

But when I run with hypens, it will not work. Command:

 cordova run ios --target="iPhone-16-Pro, 18.5"

Error:

xcodebuild: error: Unable to find a device matching the provided destination specifier:
		{ platform:iOS Simulator, OS:18.5, name:iPhone 16 Pro }

	The requested device could not be found because multiple devices matched the request. (
    "<DVTiPhoneSimulator: 0xa8c898000> {\n\t\tSimDevice: iPhone 16 Pro (E4D9D5C2-661E-4AA7-B31D-0D5079C002BD, iOS 18.5, Booted)\n}",
    "<DVTiPhoneSimulator: 0xa8c898280> {\n\t\tSimDevice: iPhone 16 Pro (0C7B1CB0-BED0-4DE2-A6CC-FC4CD471A114, iOS 18.5, Shutdown)\n}"
)

@GitToTheHub
Copy link
Copy Markdown
Contributor Author

If you are running on an Apple Silicon-based Mac, I think you will have double versions of older simulators because they used to be universal builds with both the arm64 and x86_64 versions. Xcode 26 (on Apple Silicon) will only pull down the arm64 simulators going forward.

You are completely right, I see now in the warning, that the arch is one time listed with arm64 and one time with x86_64. Ok so this is the thing :)

@dpogue
Copy link
Copy Markdown
Member

dpogue commented Dec 24, 2025

the arch is one time listed with arm64 and one time with x86_64

I guess the "correct" way to do this would be to detect the architecture we're currently running on and try to find a simulator that matches that architecture, but I don't know for sure if that's always going to be better.

I am confused about why you get different results with spaces vs dashes, because it should be translating them to the same thing...

@GitToTheHub
Copy link
Copy Markdown
Contributor Author

I am confused about why you get different results with spaces vs dashes, because it should be translating them to the same thing...

Me too, but I saw now, when running a target without hyphens:

cordova run ios --target="iPhone 16 Pro, 18.5"

The warning was about iPhone 16 Plus not Pro. In the console log I also see at the beginning:

No simulator found for "iPhone 16 Pro". Falling back to the default target.

I will fix this.

- Enhance simulator build process by resolving device UDID and updating xcodebuild arguments
- GitHub actions complained about trailing spaces
@GitToTheHub
Copy link
Copy Markdown
Contributor Author

GitToTheHub commented Dec 24, 2025

I changed 3 things:

  • Booted devices are prioritized
  • Spaces in target is replaced with hyphens
  • UDID is determined to handle duplicate simulators

@GitToTheHub GitToTheHub changed the title fix: run fix: run target with and without hyphens Jan 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants