r/reactnative • • Oct 20 '19

Got my react-native app running on macOS via Apple's Project Catalyst

292 Upvotes

20 comments sorted by

39

u/brunolemos Oct 20 '19 edited Oct 30 '19

Here's some details:

This is a react-native app that has nested scrolling and swipe gestures using react-native-gesture-handler. Both of this worked great when running on macOS, which is amazing.

What didn't work for me:

  • Development mode (only Release mode, because I had to disable the WebSocket module for the build to work)

  • Firebase

  • Deep linking

Overall impression:

  • Working surprisingly well without any code changes

  • 100% of the layout looks correct, didn't notice anything broken compared to the iPad version

  • Performance is bad, but I'm not sure if it's a Catalyst problem or something on my app, need to investigate

  • Everything looks smaller than it should, I'll probably need to handle the device PixelRatio

  • Bundle size: 9,1MB (20x smaller than the Electron version: 181,1MB)

Steps:

  • Upgrade your macOS to Catalina

  • Upgrade Xcode to v11.1+

  • Upgrade your app to react-native 0.61.2+

  • On Xcode, at the General tab, enable the "Mac" device target

  • Build

  • You will get some build errors. Read the error and disable the failing module (Go to the Pods project, search for the failing Target, tap Build Phases > Compile Sources and choose only "iOS" instead of "macOS + iOS") (temporary fix)

  • If some non-critical native code is failing the build due to some unsupported api you can temporarily disable it by wrapping on a #if TARGET_OS_UIKITFORMAC condition

Tweet link: https://twitter.com/brunolemos/status/1185636022346043392?s=20

5

u/IAmNotASkycap Oct 20 '19

Great detail, thank you!

1

u/cutecoder Oct 24 '19

Does hardened runtime work?

0

u/[deleted] Oct 20 '19

[deleted]

5

u/janithaR Oct 20 '19

shhh... don't jinx it :P

2

u/orta Oct 20 '19

Congrats, looks cool!

2

u/TheJulian Oct 21 '19

Looks great. I recently got both firebase and deep linking working for an app. I might be able to help.

2

u/KingThereus Oct 30 '19

How did you get that working? I'm currently getting:

'fetchAssetsWithALAssetURLs:options:' is unavailable: not available on macCatalyst

2

u/KingThereus Jan 29 '20

u/TheJulian, did you also encounter this issue? fetchAssetsWithALAssetURLs:options:' is unavailable: not available on macCatalyst

1

u/pie6k Mar 31 '20

I'm also getting `'fetchAssetsWithALAssetURLs:options:' is unavailable: not available on macCatalyst`

2

u/solrflow Oct 28 '19

Looks fantastic. Any chance you'd make a guide on doing this?

3

u/BushBakedBeanDeadDog Oct 20 '19

I know it's not but it'd be hilarious if apple's 'bridge' code to make this work was written in JavaScript...

1

u/kbcool iOS & Android Oct 20 '19

Wow. I will have to try it. Bit wary of upgrading Xcode as it seems to break existing projects half the time but will have to bite the bullet for this.

I wonder if things like location, camera, webviews etc work fine and if there's a way forward on third party libs like firebase.

I have an app I desperately want to make available on desktop but it has so much custom native code in it everytime I look at porting it I freak out.

1

u/Inaniloquent26 Oct 21 '19

It looks great, congrats!

-20

u/[deleted] Oct 20 '19

Oh shit.

Is This slack, I mean Discord, I mean IRC - I mean Jabber, I mean Pidgeon, I mean Skype, I mean text messaging, chat for devs? I can’t wait to install it.

3

u/Nemeesiis68 Oct 20 '19

It isn't a chat but yeah.

More like twittdeck for GitHub / manage notifications / follow organization activity etc.

1

u/[deleted] Nov 20 '19

No, it looks like something someone built to learn useful new cross-platform technologies that helps improve their workflow and isn't meant to impress you (dick) or replace anything.

8

u/[deleted] Oct 20 '19

[removed] — view removed comment

1

u/10halec Oct 20 '19

What discord server do you guys use?