20

I'm upgrading my project to use Cocoapods and when I try building my project for an iOS device or for a simulator I get:

Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_TestFlight", referenced from:
      objc-class-ref in PhotoPreviewViewController.o
  "_OBJC_CLASS_$_Flurry", referenced from:
      objc-class-ref in MyAppDelegate.o
      objc-class-ref in InitialSetupViewController.o
      objc-class-ref in InitialDownloadViewController.o
      objc-class-ref in HistoryViewController.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

(with the architecture different of course)

Under "Link Binary With Libraries" libPods.a is black so I don't think there is any issue there. It is also doing autocomplete for both of them, so I'm not sure why it isn't finding them at the compile time.

Any suggestions?

quaertym
  • 3,917
  • 2
  • 29
  • 41
RyanJM
  • 7,028
  • 8
  • 60
  • 90

3 Answers3

70

The following worked for me:

In the Build Settings, do not override "Other Linker Flags". If it is bold, select it and press backspace, it should be back to its normal state. If it is not fixed, delete all flags, remove and reinstall Pods and that should fix it.

quaertym
  • 3,917
  • 2
  • 29
  • 41
  • 2
    Be sure to check your "Library Search Paths" Build Setting as well. This was causing the problem for me. – Isaac Overacker Nov 15 '13 at 02:04
  • 4
    This worked. Never knew that you could hit backspace to remove overrides. At first i just removed the "-ObjC" that was there and it was blank. Apparently "blank" doesn't mean "defaults" – markrickert Dec 04 '13 at 16:13
  • 1
    This doesn't really explain why this fixes the issues. There might be valid reasons to edit or add to the Other Linker Flags. At least in the case of TestFlight, the reason why this probably fixes the issue is that it ensures -lTestFlight is part of the linker flags. If you need to customize the linker flags, ensure you have this flag for TestFlight. – Fostah Apr 03 '14 at 18:17
  • 1000 KISSES FOR YOU. I did exactly what markrickert did too. Remove -ObjC thinking it was gone! – super9 Apr 19 '14 at 09:00
  • 1
    Ever a constant reminder of my own stupidity. Thank you! – Ben Kreeger Oct 07 '14 at 13:14
  • Why did this worked?? can you help me to understand? – Eduardo Urso Nov 07 '14 at 18:35
22

Cocoapods, for some reason, doesn't include libTestFlight.a in the TestFlight target. So to fix this issue, each time you run pod install, you must:

  1. Open the Pods-TestFlightSDK target in the Pods.xcodeproj project
  2. Open Build Phases tab
  3. Add (via "Add Other...") libTestFlight.a to Link Binary With Libraries dropdown

libTestFlight.a can be found in your [$SRCROOT]/Pods/TestFlightsSDK folder.

enter image description here

Do the same with Flurry and you're good to go!

Update May 1st 2014

It looks like "missing library integration" is a symptom of using the --no-integrate flag (e.g., pod install --no-integrate).

And to make life easier, I've written a script to automatically add the libraries after running pod (update|install) --no-integrate

Adjust as necessary and add this to the bottom of your Podfile:

# Use post_install to automatically include required libraries
post_install do |installer_representation|
    installer_representation.project.targets.each do |target|
        if target.name == 'Pods-TestFlightSDK'
            libFile = installer_representation.project.new_file('TestFlightSDK/libTestFlight.a')
        end

        if target.name == 'Pods-Brightcove-Player-SDK'
            libFile = installer_representation.project.new_file('Brightcove-Player-SDK/Library/libBCOVPlayerSDK.a')
        end

        unless libFile.nil?
            puts "    - Adding %s to %s Frameworks Build Phases" % [libFile, target.name]
            target.frameworks_build_phase.add_file_reference(libFile)
        end
    end
end
Tom Redman
  • 5,592
  • 4
  • 34
  • 42
  • This didn't seem to work with me regarding Flurry. I'm still getting the undefined symbols error – s73v3r Nov 05 '13 at 18:32
  • Perhaps Flurry is a separate issue. Please post a new question with your specifics. – Tom Redman Nov 05 '13 at 20:55
  • 1
    This solutions works great for me I suggest @s73v3r to create sample project and integrate flurry only an add libFlurry. I don't have testflight library integrated. – Rajan Maharjan Nov 29 '13 at 16:52
1

I've found that can be few reasons of this issue:

  1. libPod.a not included in "link binary with libraries" (try to remove reference and add again)
  2. Compiler can't find library. Strange behaviour, try to write path to libraries using ${PODS_ROOT} at "Library search path". ($(PODS_ROOT)/TestFlightSDK for example)
  3. Compiler can't find header. try to write path to headers using ${PODS_ROOT} at "Header search path".

Hope that this is helpful.

HereTrix
  • 1,315
  • 7
  • 13