Cli: Getting "No iOS devices connected" for MacOS target on 4.4.0

Created on 28 Mar 2020  Ā·  27Comments  Ā·  Source: react-native-community/cli

Environment

% npx react-native --version
4.4.0

% npx react-native info
info Fetching system and libraries information...
System:
    OS: macOS 10.15.4
    CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
    Memory: 2.89 GB / 32.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 13.9.0 - /usr/local/bin/node
    Yarn: 1.22.0 - ~/.yarn/bin/yarn
    npm: 6.14.2 - ~/.npm-packages/bin/npm
    Watchman: Not Found
  SDKs:
    iOS SDK:
      Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK: Not Found
  IDEs:
    Android Studio: Not Found
    Xcode: 11.4/11E146 - /usr/bin/xcodebuild
  Languages:
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: ^16.12.0 => 16.12.0 
    react-native: 0.62.0-rc.5 => 0.62.0-rc.5 
  npmGlobalPackages:
    *react-native*: Not Found

Description

When I run react-native run-ios --device XXX I get:

$ react-native run-ios --device "XXX"
info Found Xcode workspace "XXX.xcworkspace"
error No iOS devices connected.

Where XXX can be found in:

% xcrun instruments -s devices
Known Devices:
XXX [XXX-XXX-XXX-XXX-XXX]

Mac target is enabled:

image

bug ios

Most helpful comment

Running ios-deploy -c I can see my connected device:

[....] Waiting up to 5 seconds for iOS device to be connected
[....] Found b0cecc07f4565a0c254bcd20f0c051129a0d5982 (D22AP, iPhone X, iphoneos, arm64, 14.5.1, 18E212) a.k.a. 'Kasra’s iPhone' connected through USB.

But running npx react-native run-ios --udid b0cecc07f4565a0c254bcd20f0c051129a0d5982:

error Could not find a device with udid: "b0cecc07f4565a0c254bcd20f0c051129a0d5982". Available devices:

Xcode 12.5
React Native 0.64.1
BigSur 11.3
ios 14.5.1
```

All 27 comments

cc @alloy

It’s quite weird why the error is happening because release 4.4.0 had the note ā€œsupport run-ios on Mac target (Catalyst) (#1024)ā€ :)

Cc @robertying

It’s quite weird why the error is happening because release 4.4.0 had the note ā€œsupport run-ios on Mac target (Catalyst) (#1024)ā€ :)

Cc @robertying

The device name should be the same with what you set in System Preferences Bluetooth sharing panel.

For example, mine is Rui’s Mac mini. And I can feed —device with ā€œRui’s Mac miniā€

But be aware the single quote for ā€˜s may be slightly different. Better just copy and paste the Mac device name and wrap it in double quotes.

Let me know if this works for you. :)

@robertying yes, that's exactly what I've set there... also xcrun instruments -s devices gives me that same name. Yet I still get No iOS devices connected...

Can you console.log(devices) here to debug?

https://github.com/react-native-community/cli/blob/5503369b3b454580818d89e9c832e6bdfd292b9f/packages/platform-ios/src/commands/runIOS/index.ts#L85

Add the code to the corresponding place in node_modules.

@robertying here you go:

devices [ { udid: 'XXX-XXX-XXX-XXX-XXX', name: 'XXX' } ]
error No iOS devices connected.

Name equals to what I see in xcrun instruments -s devices and in bluetooth as you suggested.

No wonder why it fails: condition is if (devices.length <= 1) {

šŸ˜… yeah I just realized this too. The original PR worked as expected. We must have got lost during the review process.

Do you mind submitting another PR to fix this properly? Thank you!

@robertying I don't mind, but I don't quite know what to put there :))) logic should be — if it's true iOS target, then >=1 otherwise list will never be empty... I presume another target like run-mac would be a better option to distinguish...

Or we could just remove this condition check, since on any Mac, there is at least one device connected (Mac).

Hmm but this could cause confusion if people haven’t started to implement Catalyst...šŸ¤”

I don’t really like the idea to separate it with run-mac because Catalyst uses iOS’s UIKit and not Mac’s AppKit.

Maybe we can just drop the check only if the device name passed is the host Mac. If not, we return no iOS device connected.

Hmm but this could cause confusion if people haven’t started to implement Catalyst...

Exactly.

Maybe we can just drop the check only if the device name passed is the host Mac. If not, we return no iOS device connected.

Makes sense. Just check if device name in args matches the first in the list and go on. Otherwise check if there are more than one.

@robertying One more problem, when I commented out the check I got this: error Failed to install the app on the device because we couldn't execute the "ios-deploy" command. Please install it by running "npm install -g ios-deploy" and try again. Run CLI with --verbose flag for more details. I assume we need to add it to readme for mac targets...

Yeah you need to.

You didn’t see this note probably because you used to deploy only to simulators?

For real device, this seems a must.

Yep. But maybe then this tool can be shipped together with cli package? Does not seem to be an overhead...

Yep. But maybe then this tool can be shipped together with cli package? Does not seem to be an overhead...

Yeah but that's another topic. Let's focus on this missing feature first :)

@robertying @kirill-konshin Have you checked https://github.com/react-native-community/cli/issues/1078#issuecomment-605436219? In my testing it solves the initial issue. Please give it a try and let us know

@thymikee this looks neat. I think it's more thorough. šŸ‘

$ npx react-native --version 
4.5.0

$ react-native run-ios --udid XXX  # my Mac UDID
info Found Xcode workspace "XXX.xcworkspace"
error No iOS devices connected.

$ react-native run-ios --device XXX  # my Mac device name from Bluetooth section etc
info Found Xcode workspace "XXX.xcworkspace"
error No iOS devices connected.

@thymikee @robertying Did not work for me...

@kirill-konshin can you run

yarn list --pattern @react-native-community/cli

and make sure that cli-platform-ios is on 4.5 as well?

If it's up-to-date, then I'll need your help in debugging this, e.g. by throwing around some console.logs around this code:
https://github.com/react-native-community/cli/blob/a4a0f784910c6cc7f6418ee987965778266f8d1c/packages/platform-ios/src/commands/runIOS/parseIOSDevicesList.ts#L24-L42
and seeing why it doesn't match your device

@thymikee thank you, you're right, I should have bumped those too.

I did it with resolutions section of package.json:

{
  "resolutions": {
    "@react-native-community/*": "4.5.0",
  }
}

It was just @react-native-community/cli and I just changed it to asterisk: @react-native-community/*.

It does start the compilation but I got a whole bunch of different errors for mac target... that's a separate issue though. Should I post it in this repo or in main React Native repo?

If there's no difference running through command line and Xcode directly, then file an issue in main RN Repo please

Running ios-deploy -c I can see my connected device:

[....] Waiting up to 5 seconds for iOS device to be connected
[....] Found b0cecc07f4565a0c254bcd20f0c051129a0d5982 (D22AP, iPhone X, iphoneos, arm64, 14.5.1, 18E212) a.k.a. 'Kasra’s iPhone' connected through USB.

But running npx react-native run-ios --udid b0cecc07f4565a0c254bcd20f0c051129a0d5982:

error Could not find a device with udid: "b0cecc07f4565a0c254bcd20f0c051129a0d5982". Available devices:

Xcode 12.5
React Native 0.64.1
BigSur 11.3
ios 14.5.1
```

me too

Xcode 12.5
React Native 0.64
BigSur 11.4
ios 14.3

For anyone having issues deploying on a device from command line: https://github.com/react-native-community/cli/issues/1404

For anyone having issues deploying on a device from command line: #1404

5.0.1-alpha.2 not working for me. Which version are you using?

same, I run this command react-native run-ios --configuration Release --device with the changes mentioned in the link that I posted

Was this page helpful?
0 / 5 - 0 ratings