bona912
bona912

Reputation: 639

Undefined symbols for architecture arm64: Xcode 12

Im trying to build a project after adding 3rd party framework, however I can't compile the project after adding the framework, I get Undefined symbols for architecture arm64: error when I try to compile on a device, but I can compile on a simulator. I have tried all other solutions I found on stackoverflow. any help is appreciated!

Here is what I have tried:

None of the solutions I tried worked for me.

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

Upvotes: 17

Views: 39495

Answers (6)

anon12345
anon12345

Reputation: 21

I found it help to set the target membership of file that has this error to target. click on a file that produced this error, on the right of Xcode there is the inspector. in inspector It shows target membership. if file is currently not of any target membership select what you want.

Upvotes: 0

kakaiikaka
kakaiikaka

Reputation: 4477

There are many possible reasons, last armv7 version stays in iOS 10. So for me:

I tried to use "Valid Architectures" without 'armv7', which doesn't exist in Xcode 12 anymore.

Next I tried ONLY_ACTIVE_ARCH, which I know this will result in I cannot Archive my app in the end

Finally, I searched my local podspec, found

    s.ios.deployment_target = "10.0"

Since my main app's minimum deploy target is set to iOS 11. So I set

    s.ios.deployment_target = "11.0"

Xcode doesn't complain this armv7 anymore.

Hope this will help someone, check your framework or any dependencies, make sure they are set correctly.

Upvotes: 0

Cx.
Cx.

Reputation: 59

  1. "Product" -> "Scheme" -> "Edit Scheme"
  2. select "Build"
  3. Uncheck "Parallelize Build"

Upvotes: 4

Murolau Murolau
Murolau Murolau

Reputation: 87

Forget about complicated answers that can affect other developed apps because you change XCODE inners.

In my experience, this happens because you update versions duplicating projects, that it is the simplest way to do it.

The problem is worked out when you set to YES the "Enable Modules (C and Objetive -C)" parameter in BUILD SETTINGS tab.

I also recommend to compare the BUILD SETTINGS parameters (there are a lot but is faster than rebuild the project ... I do not understand why Apple makes it so complicated) beetween projects than work ok.

BUILD SETTINGS paramenters comparation

Upvotes: 0

bona912
bona912

Reputation: 639

I found the issue.

My project supports lower minimum deployment target than the framework, and that caused the issue. I had to include the framework starting from a specific iOS version.

Here is the scenario and the issue: my project supports iOS 9 and the framework supports starting from 9.1. For that reason I was not getting the latest framework, instead Cocoapods was downloading the older version of the framework which doesn't support arm64.

So for the time being I just included the framework only for iOS 9.1 and above:

platform :ios, '9.1'
      pod 'PodName', '~> 3.2'

Then the project compiled properly, thanks for those who tried to help. I spent half day because of this and Im putting this here for anyone who might face the same problem.

Upvotes: 3

Denys
Denys

Reputation: 74

Try adding this to your pod file

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: 3

Related Questions