Skip to content

Getting "No iOS devices connected" for MacOS target on 4.4.0 #1078

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

Closed
kirill-konshin opened this issue Mar 28, 2020 · 32 comments · Fixed by #1068
Closed

Getting "No iOS devices connected" for MacOS target on 4.4.0 #1078

kirill-konshin opened this issue Mar 28, 2020 · 32 comments · Fixed by #1068
Labels
bug Something isn't working platform: ios

Comments

@kirill-konshin
Copy link

kirill-konshin commented Mar 28, 2020

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

@thymikee
Copy link
Member

cc @alloy

@thymikee
Copy link
Member

Should be fixed by #1068

@kirill-konshin
Copy link
Author

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

@robertying
Copy link
Contributor

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. :)

@kirill-konshin
Copy link
Author

@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...

@robertying
Copy link
Contributor

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

Add the code to the corresponding place in node_modules.

@kirill-konshin
Copy link
Author

@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) {

@robertying
Copy link
Contributor

😅 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!

@kirill-konshin
Copy link
Author

@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...

@robertying
Copy link
Contributor

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.

@kirill-konshin
Copy link
Author

kirill-konshin commented Mar 29, 2020

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.

@kirill-konshin
Copy link
Author

kirill-konshin commented Mar 29, 2020

@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...

@robertying
Copy link
Contributor

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.

@kirill-konshin
Copy link
Author

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

@robertying
Copy link
Contributor

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 :)

@thymikee
Copy link
Member

@robertying @kirill-konshin Have you checked #1078 (comment)? In my testing it solves the initial issue. Please give it a try and let us know

@robertying
Copy link
Contributor

@thymikee this looks neat. I think it's more thorough. 👍

@kirill-konshin
Copy link
Author

kirill-konshin commented Mar 30, 2020

$ 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...

@thymikee
Copy link
Member

@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:

function parseIOSDevicesList(text: string): Array<Device> {
const devices: Array<Device> = [];
text.split('\n').forEach(line => {
const device = line.match(
/(.*?) (\(([0-9\.]+)\) )?\[([0-9A-F-]+)\]( \(Simulator\))?/i,
);
if (device) {
const [, name, , version, udid, isSimulator] = device;
const metadata: Device = {name, udid};
if (version) {
metadata.version = version;
metadata.type = isSimulator ? 'simulator' : 'device';
} else {
metadata.type = 'catalyst';
}
devices.push(metadata);
}
});

and seeing why it doesn't match your device

@kirill-konshin
Copy link
Author

@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/*.

@kirill-konshin
Copy link
Author

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?

@thymikee
Copy link
Member

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

@ghasemikasra39
Copy link

ghasemikasra39 commented May 10, 2021

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

@naka98
Copy link

naka98 commented Jun 1, 2021

me too

Xcode 12.5
React Native 0.64
BigSur 11.4
ios 14.3

@ferdicus
Copy link

ferdicus commented Jun 1, 2021

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

@ghasemikasra39
Copy link

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?

@ferdicus
Copy link

ferdicus commented Jun 1, 2021

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

@chrisarts
Copy link

chrisarts commented Jul 2, 2021

@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/*.

This works for me doing:

"resolutions": {
    "@react-native-community/cli": "4.5.0",
    "@react-native-community/cli-platform-android": "4.5.0",
    "@react-native-community/cli-platform-ios": "4.5.0"
  }

@amma-dev
Copy link

just update the cli-platform-ios inside @react-native-community/
try this
npm i @react-native-community/cli-platform-ios

hope it works

@wasif-balol
Copy link

just update the cli-platform-ios inside @react-native-community/ try this npm i @react-native-community/cli-platform-ios

hope it works

Still not working.

@SaintDude
Copy link

just update the cli-platform-ios inside @react-native-community/ try this npm i @react-native-community/cli-platform-ios

hope it works

Yup, this did the trick for me.

@hugows
Copy link

hugows commented Jul 31, 2023

In my case, bad USB cable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working platform: ios
Projects
None yet
Development

Successfully merging a pull request may close this issue.