Search code examples
iosxcodereact-nativereact-native-iosxcode10

Getting error in Xcode no such file or directory found with libReactNativeLocalization.a during build and archive


I am having issue in Xcode while I try to build or archive my react-native project. Xcode throwing error like no such file or directory: '/Users/...../DerivedData/myproject/Build/Products/Debug-iphonesimulator/libReactNativeLocalization.a'.

when I run react-native run-ios or in release mode react-native run-ios --configuration Release then it is working perfectly fine but when I try to build or archive it from Xcode then it is throwing error.

  1. I am using Xcode version 10
  2. My react-native version is 0.57.4
  3. iOS development target is 9.0
  4. react-native-localization version is 2.0.3

Tried things which didn't worked for me

  1. Removed node_modules and pods completely and run npm install and pod install didn't worked for me .

  2. In menue File --> workspace setting changed build system from Use Shared System to Legacy build system. in this particular case app is build and archived successfully but when I lunch my app then it crashes after splash screen.

  3. Removed Derived Data completely and rebuild again still getting this error.

  4. If I remove react-native-localization completely from my project then all the things are working fine and I am able to build and archive the project.


Solution

  • When we run react-native link react-native-localization command then it also applies the changes on ios app too which creates an issue in our case. So due to this command, it creates an entry in project_name → ios → podfile (podfile)

    Here ReactNativeLocalization is pointing to project_name/node_modules/react-native-localization directory due to this line when we run pod install command then there is one dependence React in this package is going to reinstall in your pods as you can see in this image.(as you can see here)

    Follow the following steps to overcome form this issue

    • After react-native link react-native-localization command navigate to project_name → ios → podfile and remove or comment pod ‘ReactNativeLocalization’, :path => ‘../node_modules/react-native-localization’
    • Now its time to link react-native-localization library manually from Xcode. So to link this library manually open project_name → ios → project_name.xcworksace file in Xcode and select your target.
    • After that in project navigator right click on library and select Add Files to “...” and after that navigate to project_name → node_modules → react-native-localization and select ReactNativeLocalization.xcodeproj file.
    • Now navigate to project Target → Build Phase and expand Link Binary With Library after that click on plus icon and add libReactNativeLocalization.a library