Cocoapods - Flurry & TestFlight - Undefined symbols for architecture
Asked Answered
R

3

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?

Representation answered 8/8, 2013 at 18:8 Comment(6)
Sounds like an issue with your header search paths. Double check it's the same for your target as in Pods.xcconfig.Recently
I'm using $(inherited) so it is pulling all of Pods.xcconfig search paths also. That should do it right?Representation
I ran into this issue too and just removed Testflight, Flurry, and Parse from Cocoapods. Not worth the headache to get working.Microsporangium
This is what I did also. Wish I could have kept it in Cocoapods.Representation
There is a solution! See my answer to resolve the issue while keeping Cocoapod support.Erring
@Representation can you check the correct answer?Sinclare
S
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.

Sinclare answered 20/10, 2013 at 12:20 Comment(6)
Be sure to check your "Library Search Paths" Build Setting as well. This was causing the problem for me.Anaclitic
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"Damning
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.Anallise
1000 KISSES FOR YOU. I did exactly what markrickert did too. Remove -ObjC thinking it was gone!Nina
Ever a constant reminder of my own stupidity. Thank you!Elea
Why did this worked?? can you help me to understand?Inculpable
E
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
Erring answered 29/10, 2013 at 20:16 Comment(3)
This didn't seem to work with me regarding Flurry. I'm still getting the undefined symbols errorBoehmenism
Perhaps Flurry is a separate issue. Please post a new question with your specifics.Erring
This solutions works great for me I suggest @Boehmenism to create sample project and integrate flurry only an add libFlurry. I don't have testflight library integrated.Soliloquize
L
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.

Lanark answered 15/10, 2013 at 16:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.