React native link Ejecting

1.6k Views Asked by At

I tried searching in previous questions, but I did not find it. I made the mistake of using Create React Native App projects. I am trying to do react native link. I did npm i --save. I get an error

react-native link can not be used in Create React Native App projects. If you need to include a library that relies on custom native code, you might have to eject first. See https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md for more information.

I read this and sadly I am completely at a lost. I am using visual studio code and not xcode.

1

There are 1 best solutions below

0
On

The error is exactly as it states. You cannot link assets and libraries that require linking unless you eject the project from Create React App and get the native project files. Ejecting gives you the native code and with that, you can use Xcode to link libraries with native code.

Create React App is built on Expo, which aims to allow you to develop apps, especially iOS apps, on any platform. But Expo comes with its restrictions due to the very nature of what it accomplishes.

Thus, the problem arises when you want to link platform dependent libraries that require Xcode in iOS's case. Xcode is the proprietary - and really, the only way, to build Apple-based projects that require external libraries because they require APIs and environments only available with it. This was one the huge reasons Expo arose, to allow people to build apps with React Native without having Xcode, but it has its limitations.

So, you cannot use a library that requires linking with native code if you do not have Mac OS because APIs and tools needed for it are only offered on Mac OS.