Skip to content

Many problems in pod install #316

Closed
hartbit opened this Issue Jun 7, 2012 · 18 comments

3 participants

@hartbit
hartbit commented Jun 7, 2012

After @irrationalfab helped me by merging the Spec master branch into 0.6, I got the latest version of my dependencies, but I'm having bizarre linking errors. Here's what happened:

  • Deleted the workspace and Pods directory.
  • Updated the Podfile to use link_with.
  • Ran pod install.
  • Tried compiling my test target and got this link error (notice that it's coming from libPods-test.a):
`Undefined symbols for architecture i386:
    "_OBJC_CLASS_$_SenTestCase", referenced from:
        _OBJC_CLASS_$_SPTSenTestCase in libPods-test.a
  • Checked Pods-test.xconfig and it does contain SenTestingKit:

OTHER_LDFLAGS = -ObjC -ObjC -lstdc++ -framework Foundation -framework SenTestingKit

  • Checked the build settings for the Pods project and saw the OTHER_LDFLAGS setting is overridden to hide the xconfig settings.
  • Removed the override and now getting new link errors:
-dynamic not specified the following flags are invalid: -ObjC -ObjC 
can't locate file for: -lstdc++
file: -lstdc++ is not an object file (not allowed in a library)

Notice that all the problems seem to come from Specta. Btw, here is my Podfile for reference:

Podfile

platform :ios, '5.0'

target :test do
    link_with 'FujiTests'
    dependency 'Specta'
    dependency 'Expecta'
    dependency do |spec|
        spec.name           = 'OCMockito'
        spec.version        = '0.22'
        spec.source         = { :git => 'https://github.com/TrahDivad/OCMockito.git' }
        spec.source_files   = 'Source/OCMockito/*.{h,m}'

        spec.dependency 'OCHamcrest'
    end
end
@fabiopelosin
CocoaPods member

There seem to be two issues:

  • the target test is not inheriting the platform form the implicit default target. Can you confirm it by adding also the platform to it?
  • An error in linking stdc++

I've updated expecta to not require the -ObjC linker flag as it should be automatically added by CococaPods

@fabiopelosin
CocoaPods member

Regarding stdc++ I think that it was the double -ObjC, because OCHamcrest lints. Can you report back?

@hartbit
hartbit commented Jun 7, 2012

the target test is not inheriting the platform form the implicit default target. Can you confirm it by adding also the platform to it?

I don't understand what you're saying. Can you elaborate?

@hartbit
hartbit commented Jun 7, 2012

Regarding stdc++ I think that it was the double -ObjC, because OCHamcrest lints. Can you report back?

I updated your Expecta fix, and as you can see, the first error only mentions ObjC once, but apart from that, the errors are the same:

-dynamic not specified the following flags are invalid: -ObjC 
can't locate file for: -lstdc++
file: -lstdc++ is not an object file (not allowed in a library)
@fabiopelosin
CocoaPods member

@alloy we need you help.

@fabiopelosin
CocoaPods member

I don't understand what you're saying. Can you elaborate?

I meant the following, but after checking the code looks like there is no issue with it.

platform :ios, '5.0'

target :test do
    link_with 'FujiTests'
    platform :ios, '5.0'
    ...
    end
end

Because the following implied an architecture issue. As there should be no problem loading SenTestingKit

Undefined symbols for architecture i386
@hartbit
hartbit commented Jun 7, 2012

To be precise, the problem seems to be coming from the fact that pod install is setting an empty value for the OTHER_LDFLAGS build setting of the Pods project target, therefore overriding the xconfig stuff. I know I'm repeating myself here, but just to make sure there is no misunderstanding.

You should be able to easily reproduce the problem by using the same Podfile and creating some test cases (using SenTestingKit).

@fabiopelosin
CocoaPods member

To be precise, the problem seems to be coming from the fact that pod install is setting an empty value for the OTHER_LDFLAGS build setting of the Pods project target, therefore overriding the xconfig stuff. I know I'm repeating myself here, but just to make sure there is no misunderstanding.

I've missed this point 😭

@alloy
CocoaPods member
alloy commented Jun 7, 2012

The problem is not with building libPods-test.a. I have just ran it locally and it builds fine for me (just the lib). The problem is when the linker tries to link this archive into your app. The OTHER_LDFLAGS option is only meant for your app, which is why we override it in Pods.xcodeproj. Can you verify that the OTHERLD_FLAGS show up in the build settings of your app?

@hartbit
hartbit commented Jun 8, 2012

@alloy I understand. I put the override back in, and checked that my project is indeed using the xconfig settings for OTHERLD_FLAGS. But the original error is still there. Here is the entire link command.

Notice that the command contains -framework SenTestingKit. I just don't understand. Can you reproduce that on your end by using Specta in the test target of your test project?

Ld /Users/david/Library/Developer/Xcode/DerivedData/Fuji-bqkdeyegjpcnjnewtekfnimrjtcz/Build/Products/Debug-iphonesimulator/FujiTests.octest/FujiTests normal i386
    cd /Users/david/Dropbox/Projects/Fuji
    setenv MACOSX_DEPLOYMENT_TARGET 10.6
    setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk -L/Users/david/Library/Developer/Xcode/DerivedData/Fuji-bqkdeyegjpcnjnewtekfnimrjtcz/Build/Products/Debug-iphonesimulator -F/Users/david/Library/Developer/Xcode/DerivedData/Fuji-bqkdeyegjpcnjnewtekfnimrjtcz/Build/Products/Debug-iphonesimulator -F/Applications/Xcode.app/Contents/Developer/Library/Frameworks -filelist /Users/david/Library/Developer/Xcode/DerivedData/Fuji-bqkdeyegjpcnjnewtekfnimrjtcz/Build/Intermediates/Fuji.build/Debug-iphonesimulator/FujiTests.build/Objects-normal/i386/FujiTests.LinkFileList -Xlinker -rpath -Xlinker /Applications/Xcode.app/Contents/Developer/Library/Frameworks -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -ObjC -lstdc++ -framework Foundation -framework SenTestingKit -fobjc-arc -Xlinker -no_implicit_dylibs -D__IPHONE_OS_VERSION_MIN_REQUIRED=50100 -framework CoreGraphics -lPods-test -framework UIKit -framework GLKit -framework OpenGLES -framework SenTestingKit -framework Foundation -o /Users/david/Library/Developer/Xcode/DerivedData/Fuji-bqkdeyegjpcnjnewtekfnimrjtcz/Build/Products/Debug-iphonesimulator/FujiTests.octest/FujiTests

Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_SenTestCase", referenced from:
      _OBJC_CLASS_$_SPTSenTestCase in libPods-test.a(SPTSenTestCase.o)
  "_OBJC_METACLASS_$_SenTestCase", referenced from:
      _OBJC_METACLASS_$_SPTSenTestCase in libPods-test.a(SPTSenTestCase.o)
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
@hartbit
hartbit commented Jun 8, 2012

This possibly has nothing to do with the problem at hand, but why does Specta have the following line in it's podspec:

s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '"$(DEVELOPER_FRAMEWORKS_DIR)"',
                 'LD_RUNPATH_SEARCH_PATHS' => '"$(DEVELOPER_FRAMEWORKS_DIR)"' }

I tried removing them from the xconfig, but then the preprocessor can not locate the SenTestingKit header:

#import <SenTestingKit/SenTestingKit.h>
    => 'SenTestingKit/SenTestingKit.h' file not found
@hartbit
hartbit commented Jun 8, 2012

This was indeed the problem. Since Xcode 4.3, project templates test targets contain this build setting for FRAMEWORK_SEARCH_PATHS:

$(SDKROOT)/Developer/Library/Frameworks
$(DEVELOPER_LIBRARY_DIR)/Frameworks

For it to work, this setting has to be set both in the test target and the Pods target.
Specta was overriding this for some reason. I can fix this in the Specta podspec if you want.

@alloy
CocoaPods member
alloy commented Jun 8, 2012

Ah I see, the Specta spec should probably inherit the config values like so:

s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '"$(inherited)" "$(DEVELOPER_FRAMEWORKS_DIR)"',
                 'LD_RUNPATH_SEARCH_PATHS' => '"$(inherited)" "$(DEVELOPER_FRAMEWORKS_DIR)"' }

Can you see if that makes it work and then fix the spec? (Or just fix the values if that remains the problem.) Thanks!

@hartbit
hartbit commented Jun 8, 2012

Ok, so I updated Specs to have the Specta podspec say:

s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '"$(SDKROOT)/Developer/Library/Frameworks" "$(DEVELOPER_LIBRARY_DIR)/Frameworks"' }

I then merged master into 0.6, and now my project compiles successfully after a fresh pod install.
I'll let you close the issue if you think there is nothing else to fix...

@hartbit
hartbit commented Jun 8, 2012

Ah I see, the Specta spec should probably inherit the config values like so:

Your suggestion would not work because the Pods target needs the same setting as the one that Xcode automatically adds for test targets.

@alloy
CocoaPods member
alloy commented Jun 8, 2012

Cool, thanks. I wonder if those two aren't actually the same paths. Could you see if it works with just the last value? In the meantime I’ll close this ticket as the problem has been found.

@alloy alloy closed this Jun 8, 2012
@alloy
CocoaPods member
alloy commented Jun 8, 2012

Your suggestion would not work because the Pods target needs the same setting as the one that Xcode automatically adds for test targets.

Gotcha.

@fabiopelosin
CocoaPods member

Is it a good idea to make different xcconfigs for the pods targets and the app targets. Isn't this something needed for #221?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.