Frank Andrew
Frank Andrew

Reputation: 917

How solve 'Undefined symbols for architecture armv7' in React Native iOS?

I get a problem to build release react native ios, I try to look for many examples, but fail all.

This is the error message :

Undefined symbols for architecture armv7:
  "_RCTDefaultLogFunction", referenced from:
      -[momsindonesiaTests testRendersWelcomeScreen] in momsindonesiaTests.o
  "_RCTSharedApplication", referenced from:
      -[momsindonesiaTests testRendersWelcomeScreen] in momsindonesiaTests.o
  "_RCTSetLogFunction", referenced from:
      -[momsindonesiaTests testRendersWelcomeScreen] in momsindonesiaTests.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I don't know how to solve this error again, please help me to solve this problem.

Thanks.

Upvotes: 5

Views: 4846

Answers (2)

iUrii
iUrii

Reputation: 13758

armv7 architecture is stopped supporting by iOS devices from iPhone 5s and today you might not support it as well but the latest iOS SDK still can compile armv7 for backward compatibility.

To exclude armv7 from your compilation process you can set ONLY_ACTIVE_ARCH to YES for all your and React Native targets. This settings enables compiling arm64 arch for devices and x86_64 arch for simulators only. For instance, you can add next code to your Podfile to set this settings automatically on pod install:

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['ONLY_ACTIVE_ARCH'] = 'YES'
        end
    end
end

Upvotes: 0

Faddablack
Faddablack

Reputation: 145

I had the same issue with Xcode 10.1 and react native 0.61.5. To fix try this.

  1. Go to project navigator in Xcode
  2. Click on the project and go to Build Settings
  3. Select 'yourappname'Tests and under Build active Architecture Only select 'Yes' under Release. By default it is set to 'No'.
  4. Try to rebuild and it should build this time round.

Hope this solution works for you as well.

Upvotes: 1

Related Questions