Integrate the react-native-watch-connectivity library, directly with expo

How to integrate the react-native-watch-connectivity library, directly with expo, since currently it only detects the library if it is used with react CLI, and when doing it with expo I get the error: “Could not find RNWatch native module. On RN 0.60+ you can autolink by running pod install.In RN <0.60 you need to run react-native link or else link manually”.

I agree, the autolink part should work on a modern RN / Expo project.

However, you still need to eject the project and work in the Bare Workflow, because in the Managed Workflow, you don’t have an ios folder with an Xcode project inside. You need the Xcode workspace to be able to add an Apple Watch project.

You cannot develop the Apple Watch app in RN / Expo, you need Xcode / Swift for that.

While you can run npx expo prebuild to generate the ios and android directories, you may not need to. Based on the installation instructions it looks like it should just work in the Expo Managed workflow… as long as you do not use Expo Go. You would have to create a development build and use that instead of Expo Go.

If you need to add a target for some reason then the following might help with that:

But how would you write code for the Watch? You need an Apple Watch Xcode project for that.

The workflow for the library is, you eject an Expo project, this gives you an Xcode workspace, and in that, you add the Apple Watch project, then you have a coupled Watch/Phone apps that can communicate.

I see. Then maybe you would need to prebuild

Just saw your other answer. Wow, expo eject does not exist anymore. I did know that the “Managed Workflow” now supports custom native libraries, but I didn’t realize this also means custom Xcode projects.

Do you know of an example project that uses prebuild and then adds a separate Xcode project (with Swift or ObjC code), such that you have Swift and React Native / Expo side-by-side?

npx expo prebuild is the replacement for expo eject. It’s similar, but better.

Sorry, I don’t know. But maybe this project has something you can use:

2 Likes