It’s been a while since my webpage is up and haven’t made a post yet, so I guess it’s time to make the first one and it happens that I have just ran into a perfect topic, an issue that made me crazy for 2 whole days (more or less 14 effective debbuging hours).
DISCLAIMER: I’m kinda noob in mobile development and I’m pretty sure there is a better solution for this but I didn’t ran into one, so I’m going to recreate my solution with an explanation “for dummies”. If you are an experienced mobile developer, I’m sorry, don’t judge me (this will be completely boring ). BUT IT WORKS!!! LOL 😀
Preconditions: I started a mobile development with Expo SDK 33 (It uses React 16.8.3 and react-native 0.59.8), when suddenly I remember that I needed to implement react-native-bluetooth-escpos-printer. What’s the issue?, you may think… Well, Expo is so nicely done for mobile developer dummies like me that you can implement A LOT of very nice features that requiere linking a Xcode/Android project to react-native in order to make them possible, with out actually linking them. The problem is, you don’t have in your project the iOS or Android folders so if you want to link a feature by yourself you’re not able to. In these cases you have to make an Expo eject. This was my case I followed the guide to eject it. (At this point I want to be very clear in the fact that if you are not an experienced developer you may want to avoid and think twice before you eject your project from Expo, since your development can, in fact, become a nightmare)
After Ejecting the project everything worked just fine (it’s important to state that I ejected it with Expo Kit since I want to still be able to use some Expo features). I started the integration guide in react-native-bluetooth-escpos-printer and the nightmare started when I tried to run the project the error just prompted: ‘React/RCTBridgeModule.h file not found’.
After hours of search and trying different solutions I managed to solve that error by following this solution
- Disable the parallel builds:
- Xcode menu -> Product -> Scheme -> Manage Shemes…
- Double click on your application
- Build tab -> uncheck Parallelize Build
2. Add react as a project dependecy
- Xcode Project Navigator -> drag React.xcodeproj from your project to root tree (You can drag it from finder, it is in <your React app path>/node_modules/react_native/React
- Build Phases Tab -> Target Dependencies -> + -> add React
After doing this FINALLY the error was solved but a new one prompted Apple Match-O Linker (id) Error: “_OBJC_CLASS_$_RCTSRWebSocket”, referenced from:
These error is similar to the first one so I just have to add that files (those files are generated after a build, so first I had to build those libraries) In the case of RCTWebSocket you can find it in <your React app path>/node_modules/react_native/Libraries/WebSocket. You open it as a project by it’s own and you build it (You’ll have the same error as in the first Step, so now you know what you can do, exact the same steps). Once that project is built you can reopen your original project and Drag and drop the library:
- Build Phases Tab -> Link binary with Libraries -> + -> add
As you can see in my case I had to link that library and some others, the steps are exactly the same.
After this I was able to run the App and use the NPM library that I needed.
Conclusions: As I mentioned earlier, I’m pretty sure there’s a better way to accomplish this (Pretty sure it can be automated with pods) but after hours of search I didn’t find how and I was happy to be able to solve it.
Hope this helps