Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS CLI Run Fails with Incorrect Device ID in 10.1.x #1807

Closed
brianlenz opened this issue Jan 23, 2023 · 8 comments · Fixed by #1823
Closed

iOS CLI Run Fails with Incorrect Device ID in 10.1.x #1807

brianlenz opened this issue Jan 23, 2023 · 8 comments · Fixed by #1823

Comments

@brianlenz
Copy link

Environment

$ yarn react-native info
info Fetching system and libraries information...
System:
    OS: macOS 13.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 1.39 GB / 64.00 GB
    Shell: 5.2.15 - /opt/homebrew/bin/bash
  Binaries:
    Node: 19.4.0 - /private/var/folders/fq/d3nyh22d32j20vxw03_hl5gh0000gn/T/xfs-b0210ea0/node
    Yarn: 3.2.2 - /private/var/folders/fq/d3nyh22d32j20vxw03_hl5gh0000gn/T/xfs-b0210ea0/yarn
    npm: 9.3.0 - /opt/homebrew/bin/npm
    Watchman: 2023.01.09.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /Users/brian/.rbenv/shims/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
    Android SDK:
      API Levels: 29, 30, 31, 33
      Build Tools: 26.0.2, 26.0.3, 28.0.3, 29.0.2, 30.0.2, 30.0.3, 31.0.0, 31.0.0, 31.0.0, 33.0.0
      System Images: android-31 | Google Play ARM 64 v8a
      Android NDK: Not Found
  IDEs:
    Android Studio: 2022.1 AI-221.6008.13.2211.9477386
    Xcode: 14.2/14C18 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.11 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0 
    react-native: 0.71.1 => 0.71.1 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Description

react-native run-ios (in cli-platform-ios) seems to fail with versions 10.1.x. I've tested with @react-native-community/cli-platform-ios versions 10.1.0 and 10.1.1. The command only works when fixing the resolution to 10.0.0.

We have custom scripts to run different configs + schemes. Here's an example of one that is failing:

"ios:staging": "react-native run-ios --configuration Debug-staging --scheme staging",

On 10.1.x, it fails with:

$ yarn ios:staging
info Found Xcode workspace "TTW3.xcworkspace"
info Found booted Living Room Apple TV, iPhone 14
info Building (using "xcodebuild -workspace TTW3.xcworkspace -configuration Debug-staging -scheme staging -destination id=3542d5b87c1a194be3554b3e9743676d9937011c")
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 70. To debug build logs further, consider building your app with Xcode.app, by opening TTW3.xcworkspace.

When running against 10.0.0, the output is different:

$ yarn ios:staging
info Found Xcode workspace "TTW3.xcworkspace"
info Building (using "xcodebuild -workspace TTW3.xcworkspace -configuration Debug-staging -scheme staging -destination id=874EC276-8C56-413E-888B-1CA8D783E64D")

And from there, it builds and runs successfully.

I suspect the issue has to do with identifying the device/simulator to run on? See the -destination difference in the output between the two. The id that is found in 10.1.x doesn't correspond to any device ID.

It's worth noting that running from Xcode works without issue in all cases, so this is clearly a CLI issue.

Reproducible Demo

I'm not sure the best way to share a reproducible test case right now. Hopefully the above is information sufficient to investigate, but if you need more details, let me know 🙏

@adamTrz
Copy link
Collaborator

adamTrz commented Jan 23, 2023

Hi @brianlenz thanks for reporting.

From the logs it looks like cli wanted to launch your app both on AppleTV and iPhone 14, one being I'm guessing physical device and the other a simulator? Was that your intention?

According to this SO answer

xcodebuild error 70 means that the target for the build was not found. It could be due to a mismatch of iOS versions, parameters, or (if using a real device) the UDID being wrong, or the device was not connected, switched off or locked.

Also, could you please check if passing udid or device params works for you?

@brianlenz
Copy link
Author

@adamTrz, thanks for the quick response!

The intent is to launch on the iOS simulator (iPhone 14), which is the default run-ios behavior. Definitely not trying to launch on the Apple TV 😁

I have a feeling the Apple TV is throwing things off, but I don't understand how..

If I use --device, it works half the time. It seems like every other run it either picks my iPhone device (and works) or the Apple TV (and fails with the same error message).

Does that help?

@adamTrz
Copy link
Collaborator

adamTrz commented Jan 23, 2023

So to clarify it bit more - both iPhone and Apple TV are physical devices? Not emulators?

We're getting the list of available devices by running xcrun xctrace list devices. Could you run it for me please?

If I use --device, it works half the time. It seems like every other run it either picks my iPhone device (and works) or the Apple TV (and fails with the same error message).

Strange! Are you passing device name correctly?

@brianlenz
Copy link
Author

So to clarify it bit more - both iPhone and Apple TV are physical devices? Not emulators?

For this:

info Found booted Living Room Apple TV, iPhone 14

The Apple TV is a physical device, and the iPhone 14 is a simulator. That's the message when doing run-ios without --device (which should cause it to use the simulator).

In the case of using --device, we don't actually specify the name so that it picks the first connected device (and thus will work with anyone on the team). When using --device (without specifying a name), it switches back and forth between:

info Using first available device named "Living Room Apple TV" due to lack of name supplied.

and:

info Using first available device named "Brian Lenz’s iPhone 12" due to lack of name supplied.

I've noticed that sometimes it will pick the same device twice in a row, but it seems mostly to be evenly distributed between the two devices on which it picks.

Here's the output of xcrun xctrace list devices:

$ xcrun xctrace list devices
== Devices ==
Brian's MacBook Pro (**redacted**)
Brian Lenz’s iPhone 12 (16.2) (**redacted**)
Living Room Apple TV (16.2) (3542d5b87c1a194be3554b3e9743676d9937011c)

== Simulators ==
iPad (10th generation) Simulator (16.2) (03AAE46A-80B4-499D-A1D8-3E372988A5C4)
iPad (9th generation) Simulator (15.5) (DBFC4134-8378-4A24-8240-60F15260A514)
iPad Air (5th generation) Simulator (15.5) (BA0B3B4A-6D82-40F3-A489-2441B3E97D2F)
iPad Air (5th generation) Simulator (16.2) (65E41AD9-AD11-486D-9B9B-EAC9EE88BEB5)
iPad Pro (11-inch) (3rd generation) Simulator (15.5) (4F2D4922-4112-491F-9339-AAB0188A6777)
iPad Pro (11-inch) (4th generation) Simulator (16.2) (36CA6F7D-5A37-4919-AADD-054CDBECB1C5)
iPad Pro (12.9-inch) (5th generation) Simulator (15.5) (27C04B10-C525-49A5-AE15-92091D98AE82)
iPad Pro (12.9-inch) (6th generation) Simulator (16.2) (6C8DBCBE-342D-4770-94E4-C27000AD1030)
iPad Pro (9.7-inch) Simulator (15.5) (8A3376E5-58C5-4F05-BA54-CFAFD59943D7)
iPad mini (6th generation) Simulator (15.5) (2FBC56EE-6B16-4AF3-9DC4-C104191DFC17)
iPad mini (6th generation) Simulator (16.2) (14CAEE42-18E4-4F6D-9986-B71E801A34F4)
iPhone 11 Simulator (15.5) (EFF68720-26A2-46D5-B0E1-2FE2D7D0349D)
iPhone 11 Pro Simulator (15.5) (C5B92E43-D392-42F7-AA9B-300975F6D429)
iPhone 11 Pro Max Simulator (15.5) (EFEB774A-D7CE-4AAC-90D0-ECBA8C9598E5)
iPhone 12 Simulator (15.5) (80122C0E-FBB8-484C-ADC3-80E1C6CB34A5)
iPhone 12 Pro Simulator (15.5) (7D2C4E37-DDBD-4D87-8E79-74637F80B325)
iPhone 12 Pro Max Simulator (15.5) (09009822-0516-4A8F-B4E9-2A9D78794AEF)
iPhone 12 mini Simulator (15.5) (20AC5D0B-C9F6-4A4E-8530-5BF081267840)
iPhone 13 Simulator (15.5) (B7ED4D68-6BC8-4E47-8D02-2B98E08FC732)
iPhone 13 Pro Simulator (15.5) (BA08DA25-D2AF-4264-8349-B8D6F38F4F9C)
iPhone 13 Pro Max Simulator (15.5) (332AD2A4-728E-4764-AEC5-146CA8586F01)
iPhone 13 mini Simulator (15.5) (AD558EDF-7C18-4EC6-95FF-D30BBCA2D056)
iPhone 14 Simulator (16.2) (874EC276-8C56-413E-888B-1CA8D783E64D)
iPhone 14 Plus Simulator (16.2) (4314F0AB-16B4-44CF-8059-6821E6F4C956)
iPhone 14 Pro Simulator (16.2) (4A87223E-E0A7-4E8A-B0E3-8220EF70C51C)
iPhone 14 Pro Max Simulator (16.2) (537BD36D-C293-47A9-AC14-994E00DDBD0D)
iPhone 8 Simulator (15.5) (17765CEC-7B07-48B8-9AEA-B89F619E4CF9)
iPhone 8 Plus Simulator (15.5) (950A5D42-4CFC-4035-93C3-C8924DC48B33)
iPhone SE (3rd generation) Simulator (15.5) (D5B82959-845E-4B28-A68C-C308CF6993B3)
iPhone SE (3rd generation) Simulator (16.2) (949D77A6-E058-4ECA-AF32-AEFDCA18AD22)
iPod touch (7th generation) Simulator (15.5) (97FBD207-1D00-44FB-B09B-6C75E8F5E1AF)

You can see from this that when the CLI is failing (the main issue here), run-ios has picked the ID of the Living Room Apple TV to run on. So, the regression seems to be that it's just not identifying the proper device / simulator to run on.

Let me know if I can provide anything else that might help!

@brianlenz
Copy link
Author

@adamTrz, it's worth noting that on 10.0.0, run-ios never picks or even mentions the Apple TV. I'm guessing that's why it never had any issues. Something new in 10.1.x seems to be identifying and using the Apple TV when it should not be. Further, on 10.0.0, I don't see any physical devices listed in the output (the Found booted line) unless I'm using --device, which also seems to be contributing to the issue.

@johnryan
Copy link

I'm seeing a similar issue where the cli is trying to run on my mac rather than an iOS device. The build subsequently fails with error:

xcodebuild: error: Unable to find a destination matching the provided destination specifier:
		{ id:2A87A82B-A607-5981-BAD2-624064FA583F }

where the id corresponds to:

== Devices ==
MacBook Pro (4) (2A87A82B-A607-5981-BAD2-624064FA583F)

@adamTrz
Copy link
Collaborator

adamTrz commented Jan 26, 2023

Sorry for that.
We're working on the fix and a way to remove unsupported devices from run-ios command 🤞

@brianlenz
Copy link
Author

Thanks much, @adamTrz! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants