March 18, 2023
2

[SOLUTION] library not found for -lRNSVG on XCode with React Native

What's the issue?

I've been dealing with this horrific bug recently on a react-native project trying to get the app running on an iOS Simulator.

It's worth mentioning, it's an existing project with dependencies, packages etc and it works just fine on Android by running

npx react-native run-android

When running on iOS however, I would get the following error:

library not found for -lRNSVG

With another error following:

error: linker command failed with exit code 1

I've spent days researching and trying to find a solution, and finally found a fix for my case, so hopefully this will help you too.

What's the fix?

In reflection, it makes perfect sense; although my XCode knowledge is lacking.

In my travels of debugging the issue I came across many people saying "Library Search Paths" had something to do with the issue (which makes sense as that's where you declare the modules (i think).

So to fix the issue, i simply added the module in the library search paths, just like the rest of the modules... I assumed it would've been done by default, but i guess not!

What's the process?

  • Click on your workspace
  • Click on your target
  • Click on Build Settings
  • Locate Search Paths, Library Search Paths and then Double click on Multiple Values
  • Double click on any of the entries, copy the value. Then press the + button in the bottom corner, and paste the value you copied. Finally, replace the package name at the end with the RNSVG package name.
  • Finally clean your build and run it again!

Closing Comments

And there you go! Hopefully, it should be working for you.

I'm assuming this process would work for any libraries not found in react-native on xcode.

Hopefully I'll save you guys some time, and happy coding! :)