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

feat: allow selection of iOS sim with --udid #1068

Merged

Conversation

alloy
Copy link
Member

@alloy alloy commented Mar 24, 2020

Summary:

This makes it possible to be very specific about what simulator to use in the same way you’d interact with tooling such as simctl.

Fixes #1078

Test Plan:

Given a device list like:

/t/RNTestProject » xcrun instruments -s
Known Devices:
Eloy’s iMac [E163381F-C94E-5B5E-922E-DBB59B685FA6]
Eloy’s iPhone (13.3.1) [00008030-000D19512210802E]
iPhone 11 (13.3) [60E7F277-DC13-46B8-ADFB-7C5C9BC01274] (Simulator)
iPhone 8 (12.4) [0F518318-4C9B-49BA-89B9-1D0E325681BB] (Simulator)

Simulator

Default

/t/RNTestProject » ./node_modules/.bin/react-native run-ios
info Found Xcode workspace "RNTestProject.xcworkspace"
info Launching iPhone 11 (iOS 13.3)
info Building (using "xcodebuild -workspace RNTestProject.xcworkspace -configuration Debug -scheme RNTestProject -destination id=60E7F277-DC13-46B8-ADFB-7C5C9BC01274")

By UDID

/t/RNTestProject » ./node_modules/.bin/react-native run-ios --udid 0F518318-4C9B-49BA-89B9-1D0E325681BB
info Found Xcode workspace "RNTestProject.xcworkspace"
info Launching iPhone 8 (iOS 12.4)
info Building (using "xcodebuild -workspace RNTestProject.xcworkspace -configuration Debug -scheme RNTestProject -destination id=0F518318-4C9B-49BA-89B9-1D0E325681BB")

Device

Default without iOS device connected

/t/RNTestProject » ./node_modules/.bin/react-native run-ios --device
info Found Xcode workspace "RN062rc3.xcworkspace"
error No iOS devices connected.

Default with iOS device connected

/t/RNTestProject » ./node_modules/.bin/react-native run-ios --device
info Found Xcode workspace "RNTestProject.xcworkspace"
info Using first available device named "Eloy’s iPhone" due to lack of name supplied.
info Building (using "xcodebuild -workspace RNTestProject.xcworkspace -configuration Debug -scheme RNTestProject -destination id=00008030-000D19512210802E")

By UDID

/t/RNTestProject » ./node_modules/.bin/react-native run-ios --udid 00008030-000D19512210802E
info Found Xcode workspace "RNTestProject.xcworkspace"
info Building (using "xcodebuild -workspace RNTestProject.xcworkspace -configuration Debug -scheme RNTestProject -destination id=00008030-000D19512210802E")

Catalyst

By name

/t/RNTestProject » ./node_modules/.bin/react-native run-ios --device 'Eloy’s iMac'
info Found Xcode workspace "RN062rc3.xcworkspace"
info Building (using "xcodebuild -workspace RN062rc3.xcworkspace -configuration Debug -scheme RN062rc3 -destination id=E163381F-C94E-5B5E-922E-DBB59B685FA6")

By UDID

/t/RNTestProject » ./node_modules/.bin/react-native run-ios --udid E163381F-C94E-5B5E-922E-DBB59B685FA6
info Found Xcode workspace "RN062rc3.xcworkspace"
info Building (using "xcodebuild -workspace RN062rc3.xcworkspace -configuration Debug -scheme RN062rc3 -destination id=E163381F-C94E-5B5E-922E-DBB59B685FA6")

Copy link
Member

@thymikee thymikee left a comment

Choose a reason for hiding this comment

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

👍

@@ -8,36 +8,24 @@
import {Device} from '../../types';

/**
* Parses the output of `xcrun simctl list devices` command
* Parses the output of `xcrun instruments -s` command
Copy link
Member

Choose a reason for hiding this comment

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

good catch

packages/platform-ios/src/commands/runIOS/index.ts Outdated Show resolved Hide resolved
@alloy
Copy link
Member Author

alloy commented Mar 25, 2020

Alright, added Catalyst support back and made it a bit more clear that that’s a supported target.

Copy link
Member

@thymikee thymikee left a comment

Choose a reason for hiding this comment

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

Like it 👍

@thymikee
Copy link
Member

@grabbou mind having a look?

});
text.split('\n').forEach(line => {
const device = line.match(
/(.*?) (\(([0-9\.]+)\) )?\[([0-9A-F-]+)\]( \(Simulator\))?/i,
Copy link
Member

@thymikee thymikee Mar 28, 2020

Choose a reason for hiding this comment

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

Added lowercase flag, because some UUIDs may be lower-cased (discovered while local testing). Included test

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, good catch; thanks! Was it an iPhone?

Copy link
Member

Choose a reason for hiding this comment

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

yup, iPhone 8 to be exact

@thymikee thymikee changed the title feat: Allow selection of iOS sim with --udid feat: allow selection of iOS sim with --udid Mar 30, 2020
@thymikee thymikee merged commit 2d575b0 into react-native-community:master Mar 30, 2020
@alloy alloy deleted the platform-ios-accept-sim-udid branch March 30, 2020 10:42
@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

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.

Getting "No iOS devices connected" for MacOS target on 4.4.0
3 participants