Undefined Symbols in Linking iOS App

Hi!

Xcode 14.3 on MacOS 13.3.1

I'm developing in iOS app targeting iOS 14.0 and higher. I've included 4 cocoa pods in my project and my code has compiled and run just fine.

When I started to try to build an archive to submit to the app store, things started falling apart.

Now nothing compiles for simulators and test devices and I end up with linking errors with undefined symbols. I've tried clean builds, pod updating, pod installing, explicitly importing the modules in my swift code. I'm ready to pull my hair out.

Undefined symbols for architecture arm64: "OBJC_CLASS$_SFGeometryUtils", referenced from: objc-class-ref in MGRS.o ld: symbol(s) not found for architecture arm64

Any suggestions? Randomly I can get past this road block and then I run into:

cannot find type 'TIFFImage' in scope var tiffImage: TIFFImage!

Then randomly back to unresolved symbols by linker.

Thanks,

Bobby

  • OK. More comments on this. Setting Build Active Architecture Only = No for all the Pods and for the project helped eliminate occasional linker errors. Also, Pods Build Options Allow Multiplatform Builds = Yes also helps. However, when I go to build for generic Arm64, still get linker errors. But, I can successfully build an archive.

Add a Comment

Accepted Reply

Here are the steps I've taken to get around this.

  1. Close Xcode
  2. rm -rf Pods
  3. rm Podfile.lock
  4. pod install
  5. remove Xcode cache from ~/Library/Developer/Xcode/DerivedData/
  6. re-start Xcode, re-load project workspace and then build.

Seems to be that how cocoapods are added to an Xcode project is somewhat flaky?

Replies

One of the authors of one of the cocoa pods I'm using downloaded my repo and was able to compile/link (build) it with no problem. He has virtually the same configuration. Thus, I'm guessing its some kind of tool chain bug or settings. Havent been able to figure out how to fix. I've even tried uninstalling and re-installing XCode.

Here are the steps I've taken to get around this.

  1. Close Xcode
  2. rm -rf Pods
  3. rm Podfile.lock
  4. pod install
  5. remove Xcode cache from ~/Library/Developer/Xcode/DerivedData/
  6. re-start Xcode, re-load project workspace and then build.

Seems to be that how cocoapods are added to an Xcode project is somewhat flaky?

Can you give a step by step tutorial on where to go to do all of this please? thanks

So, the solution above does not always seem to work. Periodically, the error creeps back in randomly. I searched high and low and found a better solution that now seems to work.

In your Podfile, add

use_frameworks! : linkage :static

That takes care of the issue.

Here is my Podfile

# Uncomment the next line to define a global platform for
#  your project

platform :ios, '14.0'

target OpenAthenaIOS' do
  # Comment the next line if you don't want to use dynamic 
  # frameworks use_frameworks!

  use_frameworks! :linkage => :static

  # Pods for OpenAthenaIOS
  pod 'sf-ios', '4.1.2'  
  # pod 'grid-ios', '1.0.5'
  pod 'mgrs-ios', '1.1.4'
  pod 'tiff-ios', '4.0.1'
  pod 'UTMConversion', '~> 1.3'
  pod 'NSExceptionSwift', '~> 1.0.1'

end

target 'OpenAthenaIOSTests' do
  # Comment the next line if you don't want to use dynamic
  # frameworks use_frameworks!
  use_frameworks! :linkage => :static

  # Pods for OpenAthenaIOS
  pod 'sf-ios', '4.1.2'  
  # pod 'grid-ios', '1.0.5'
  pod 'mgrs-ios', '1.1.4'
  pod 'tiff-ios', '4.0.1'
  pod 'UTMConversion', '~> 1.3'
  pod 'NSExceptionSwift', '~> 1.0.1'

end

The better solution is to add

use_frameworks! : linkage :static

See above comment for more info.