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: support run-ios on Mac target (Catalyst) #1024

Merged
merged 5 commits into from
Mar 11, 2020
Merged

feat: support run-ios on Mac target (Catalyst) #1024

merged 5 commits into from
Mar 11, 2020

Conversation

robertying
Copy link
Contributor

@robertying robertying commented Feb 27, 2020

Summary:

Close #998

Since Mac Catalyst won't be popular for RN projects anytime soon (I assume), I only changed the code to make it work when specifying a device name. If not, run-ios will still fall back to the default iOS simulator.

It seems that Mac will always be the first in the xcrun listed devices.

Test Plan:

  1. Run react-native run-ios --device "Rui’s Mac"
  2. Now it does not return "No iOS devices connected" anymore

@robertying
Copy link
Contributor Author

Hi @thymikee! Any idea when this can be merged and released? Thanks!

@thymikee
Copy link
Member

thymikee commented Mar 9, 2020

@grabbou mind taking a look?

* Expected text looks roughly like this:
* Known Devices:
* this-mac-device [ID]
* Some Apple Simulator (Version) [ID]
*/
function parseIOSDevicesList(text: string): Array<Device> {
Copy link
Member

Choose a reason for hiding this comment

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

BTW, xcrun intruments -s devices returns all simulators + connected devices, it's kinda confusing that we run xcrun simctl few lines earlier in runOnIOSSimulator.

I think this code could be simplified to just rely on a single code path, now that we're at it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I just realized there is another parser. I could try to simplify the code.

There is a small difference between the output of two commands on my Mac:

It seems instruments are a broader concept for Xcode where we can have iPhone paired with Apple Watch, compared to simctl. Host mac only exists in instruments.

I will try to see if output from instruments is enough for booting any simulator.


xcrun instruments -s devices

Known Devices:
Rui’s Mac mini [A0428EFA-59EC-5E72-9612-5A4BAA8FE444]
Apple TV (13.3) [FF38ADAA-77F3-4F14-BF8F-EF90C2AA9129] (Simulator)
Apple TV 4K (13.3) [EC61B31B-1D91-4F3A-AD10-B18515342C0E] (Simulator)
Apple TV 4K (at 1080p) (13.3) [45EB9736-C847-40B1-9819-0D901FD1D730] (Simulator)
Apple Watch Series 4 - 40mm (6.1.1) [66383905-DCC7-4A1C-8BA5-B7365871687E] (Simulator)
Apple Watch Series 4 - 44mm (6.1.1) [E7AB1388-0235-4548-BC15-8C55B60C136F] (Simulator)
iPad (7th generation) (13.3) [C774831B-9DBC-46AD-857B-AA839F190EBD] (Simulator)
iPad Air (3rd generation) (13.3) [806B6284-AD20-4EBA-898E-488A055FC7A3] (Simulator)
iPad Pro (11-inch) (13.3) [0CFC0D8D-BB12-4BEF-A770-67F9D457C186] (Simulator)
iPad Pro (12.9-inch) (2nd generation) (13.3) [626DC537-EC7B-4474-A6DF-54B8F637D85F] (Simulator)
iPad Pro (12.9-inch) (3rd generation) (13.3) [FED06957-8E7E-4BA5-ACAB-4C0F0F6EF14C] (Simulator)
iPad Pro (9.7-inch) (13.3) [25D30125-2F67-4ABA-B63E-F7F3A86605D6] (Simulator)
iPhone 11 (13.3) [4540B5C1-F7F3-4A91-8E79-1971DD5D98BA] (Simulator)
iPhone 11 Pro (13.3) [9AAF3C5C-9CC4-4ED5-963A-269C8BE3D0FF] (Simulator)
iPhone 11 Pro (13.3) + Apple Watch Series 5 - 40mm (6.1.1) [BE7CF341-61F8-42B6-8D7D-19036226B673] (Simulator)
iPhone 11 Pro Max (13.3) [A1A44D6C-F87C-487A-AF81-319F569FE252] (Simulator)
iPhone 11 Pro Max (13.3) + Apple Watch Series 5 - 44mm (6.1.1) [0D801CF9-8489-4149-9806-5CC6EDA94481] (Simulator)
iPhone 8 (13.3) [EC2C0447-130D-4EA8-8D04-FF288F9EACFE] (Simulator)
iPhone 8 Plus (13.3) [F3D5F572-351D-4975-93D4-70320731CD2F] (Simulator)

xcrun simctl list devices

== Devices ==
-- iOS 13.3 --
    iPhone 8 (EC2C0447-130D-4EA8-8D04-FF288F9EACFE) (Shutdown) 
    iPhone 8 Plus (F3D5F572-351D-4975-93D4-70320731CD2F) (Shutdown) 
    iPhone 11 (4540B5C1-F7F3-4A91-8E79-1971DD5D98BA) (Shutdown) 
    iPhone 11 Pro (9AAF3C5C-9CC4-4ED5-963A-269C8BE3D0FF) (Shutdown) 
    iPhone 11 Pro Max (A1A44D6C-F87C-487A-AF81-319F569FE252) (Shutdown) 
    iPad Pro (9.7-inch) (25D30125-2F67-4ABA-B63E-F7F3A86605D6) (Shutdown) 
    iPad Pro (12.9-inch) (2nd generation) (626DC537-EC7B-4474-A6DF-54B8F637D85F) (Shutdown) 
    iPad (7th generation) (C774831B-9DBC-46AD-857B-AA839F190EBD) (Shutdown) 
    iPad Pro (11-inch) (0CFC0D8D-BB12-4BEF-A770-67F9D457C186) (Shutdown) 
    iPad Pro (12.9-inch) (3rd generation) (FED06957-8E7E-4BA5-ACAB-4C0F0F6EF14C) (Shutdown) 
    iPad Air (3rd generation) (806B6284-AD20-4EBA-898E-488A055FC7A3) (Shutdown) 
-- tvOS 13.3 --
    Apple TV (FF38ADAA-77F3-4F14-BF8F-EF90C2AA9129) (Shutdown) 
    Apple TV 4K (EC61B31B-1D91-4F3A-AD10-B18515342C0E) (Shutdown) 
    Apple TV 4K (at 1080p) (45EB9736-C847-40B1-9819-0D901FD1D730) (Shutdown) 
-- watchOS 6.1 --
    Apple Watch Series 4 - 40mm (66383905-DCC7-4A1C-8BA5-B7365871687E) (Shutdown) 
    Apple Watch Series 4 - 44mm (E7AB1388-0235-4548-BC15-8C55B60C136F) (Shutdown) 
    Apple Watch Series 5 - 40mm (BE7CF341-61F8-42B6-8D7D-19036226B673) (Shutdown) 
    Apple Watch Series 5 - 44mm (0D801CF9-8489-4149-9806-5CC6EDA94481) (Shutdown) 
-- Unavailable: com.apple.CoreSimulator.SimRuntime.iOS-13-4 --
    iPhone 8 (FA0FFDDD-1BB2-4DC8-8D5F-07CB981AD925) (Shutdown) (unavailable, runtime profile not found)
    iPhone 8 Plus (0DCC89C1-7DBF-48F2-95A5-88A0ECEFBB38) (Shutdown) (unavailable, runtime profile not found)
    iPhone 11 (F8BBF4A8-CD30-41D3-9438-524EF189B834) (Shutdown) (unavailable, runtime profile not found)
    iPhone 11 Pro (F358A003-BB9D-4B3A-8818-97372218B6FC) (Shutdown) (unavailable, runtime profile not found)
    iPhone 11 Pro Max (68FD3CCD-217E-41FC-BAAA-B93EA059254E) (Shutdown) (unavailable, runtime profile not found)
    iPad Pro (9.7-inch) (A26909EE-3B1F-4AFD-A5F0-93379AB8D904) (Shutdown) (unavailable, runtime profile not found)
    iPad (7th generation) (F32861D8-F194-47D1-ADE7-EA9DD8B51442) (Shutdown) (unavailable, runtime profile not found)
    iPad Pro (11-inch) (E5548F17-8342-47FE-81B3-22828E96C9F7) (Shutdown) (unavailable, runtime profile not found)
    iPad Pro (12.9-inch) (3rd generation) (07DDB8C8-8D6C-41FF-A5AB-DE20226C743D) (Shutdown) (unavailable, runtime profile not found)
    iPad Air (3rd generation) (25514C3D-8ECB-4333-A231-D5B968404B03) (Shutdown) (unavailable, runtime profile not found)
-- Unavailable: com.apple.CoreSimulator.SimRuntime.tvOS-13-4 --
    Apple TV (9F1A1F62-D1FA-40EF-93B8-411AF949311F) (Shutdown) (unavailable, runtime profile not found)
    Apple TV 4K (569553B7-2C58-4054-ABA2-7E5237A3F2CB) (Shutdown) (unavailable, runtime profile not found)
    Apple TV 4K (at 1080p) (97018EA9-58AA-49F3-BB41-A60CADB73226) (Shutdown) (unavailable, runtime profile not found)
-- Unavailable: com.apple.CoreSimulator.SimRuntime.watchOS-6-2 --
    Apple Watch Series 4 - 40mm (35033F4F-D7CD-4E9F-9A93-30166CA9F3D2) (Shutdown) (unavailable, runtime profile not found)
    Apple Watch Series 4 - 44mm (C4A1BB0D-EA96-44A9-82F1-91DD866194D0) (Shutdown) (unavailable, runtime profile not found)
    Apple Watch Series 5 - 40mm (18786B66-28E8-4A64-B52C-32BBC35B6784) (Shutdown) (unavailable, runtime profile not found)
    Apple Watch Series 5 - 44mm (92220F14-4647-4BA0-9F41-3CAAFFE70C87) (Shutdown) (unavailable, runtime profile not found)

Copy link
Member

Choose a reason for hiding this comment

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

I think it would be safer to tackle refactoring as a separate PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I looked at the code and realized xcrun simctl list devices is commonly used because the output of it indicates the simulator availability and state. However, the output does not contain real devices as xcrun instruments -s does.

For now, I'm afraid those two commands will have to co-exist.

Copy link
Member

Choose a reason for hiding this comment

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

Sure, thanks for investigation. If you have any ideas on how to further simplify the code, please do :)

Copy link
Member

@grabbou grabbou left a comment

Choose a reason for hiding this comment

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

The code looks good, but reviewing this code made me a bit confused with the logic and I think there's an opportunity to simplify it a bit.

Let me know what you think.

@robertying
Copy link
Contributor Author

I may do the refactoring in another PR as @thymikee suggested.

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.

[Feature request] run-ios supports mac catalyst target
3 participants