skip to Main Content

I’ve moved to Macbook Pro M1, and my Xcode version is 12.5.1

When running my app, I’m getting below error:

ld: library not found for -lBVLinearGradient
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I’m also using react-native-linear-gradient (version 2.5.6) library, for which this error is related to.

2

Answers


  1. I could fix this issue with amend my Podfile by adding this:

    post_install do |installer|
      ## Fix for XCode 12.5
      find_and_replace("../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm",
     "_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules")
     find_and_replace("../node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm",
     "RCTBridgeModuleNameForClass(module))", "RCTBridgeModuleNameForClass(Class(module)))")
    end
    
    def find_and_replace(dir, findstr, replacestr)
      Dir[dir].each do |name|
          text = File.read(name)
          replace = text.gsub(findstr,replacestr)
          if text != replace
              puts "Fix: " + name
              File.open(name, "w") { |file| file.puts replace }
              STDOUT.flush
          end
      end
      Dir[dir + '*/'].each(&method(:find_and_replace))
    end
    
    Login or Signup to reply.
  2. When I did the following steps, I was able to build without any errors

    1. Paste these lines at the bottom of the pod file

    post_install do |installer|
      find_and_replace("../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm",
     "_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules")
     find_and_replace("../node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm",
     "RCTBridgeModuleNameForClass(strongModule))", "RCTBridgeModuleNameForClass(Class(strongModule)))")
    
     installer.pods_project.build_configurations.each do |config|
      config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
     end
    end
    
    def find_and_replace(dir, findstr, replacestr)
     Dir[dir].each do |name|
         text = File.read(name)
         replace = text.gsub(findstr,replacestr)
         if text != replace
             puts "Fix: " + name
             File.open(name, "w") { |file| file.puts replace }
             STDOUT.flush
         end
     end
     Dir[dir + '*/'].each(&method(:find_and_replace))
    end
    

    2. You have to exclude arm64 for simulator architecture both from your main project and the Pod project

    Main Project
    enter image description here

    Pod Project
    enter image description here

    3. Delete DerivedData

    rm -rf ~/Library/Developer/Xcode/DerivedData/
    

    4. Rebuild node_modules and pod install

    rm -rf node_modules/ && rm -rf ios/Podfile.lock && rm -rf package-lock.json && rm -rf yarn.lock
    yarn
    cd ios/ && pod install && cd ..
    

    If there is nothing I forgot, everything was working when I did all these. It took me a long time to put these pieces together but it turned out nice

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search