Marco Weber
Marco Weber

Reputation: 839

xCode Cocoapods build fails "Undefined symbols for architecture x86_64"

I want to build my Xcode project (react native & swift) for the simulator and on a real device.

The simulator worked great. Today I tried to build it for my device, I selected my device in the Xcode bar and added the scheme to release (I had to do this because I'm using react native and otherwise the bundle is not packed)

Then an error during the build occurs (in this case for the dependency RNPurchases, but this is completely random. sometimes it's Expo-Keep-Awake or Facebook)

Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_RCPurchases", referenced from:
  objc-class-ref in RNPurchases.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Even switching the back to Build Configuration Debug in my scheme has no effect anymore.

I already tried several things:

nothing works.

This problem is pretty new to me, it already occurred twice within the last 2 months. Somehow I got the build for the simulator running again, but never for a device. I didn't have the problems like this half a year ago ...

My Setup


    require_relative '../node_modules/react-native/scripts/react_native_pods'
    require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
    require_relative '../node_modules/react-native-unimodules/cocoapods.rb' # expo uni modules

    use_frameworks!

    install! 'cocoapods', :deterministic_uuids => false, :warn_for_unused_master_specs_repo => false


    target 'TrainUrTeam' do
      platform :ios, '12.0'

      # ... pods xyz

      use_unimodules!

      config = use_native_modules!
      use_react_native!(:path => config["reactNativePath"])

    end


    post_install do |installer| # src: https://stackoverflow.com/a/64139830/6003494
      installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
          config.build_settings["ONLY_ACTIVE_ARCH"] = "YES"
        end
      end
    end

Upvotes: 5

Views: 11285

Answers (4)

d8en
d8en

Reputation: 41

I got these errors and just restarted my macbook, clean, then build and they disappeared. Magic.

Upvotes: 2

jeadonara
jeadonara

Reputation: 1311

If use_frameworks! :linkage => :static is not an option for you, you may try to use:

pre_install do |installer|
 installer.pod_targets.each do |pod|
   if pod.name.eql?('RNPurchases')
     def pod.build_type;
     Pod::BuildType.static_library # pods version >= 1.9
     # Pod::Target::BuildType.static_library #  pods version < 1.9
    end
   end
  end
end

Upvotes: 2

Marco Weber
Marco Weber

Reputation: 839

After 2 weeks of googling I could finally find a working solution according to this Post adding this to the Podfile:

use_frameworks! :linkage => :static

Upvotes: 9

jatin fl
jatin fl

Reputation: 177

Go to xcode project -> Build setting -> Architecture -> Excluded architecture -> (arm64)set

Try to build & run

Upvotes: -1

Related Questions