Xcode 5 and iOS 7 Linker Error #1400

Closed
azamsharp opened this Issue Sep 24, 2013 · 59 comments

Projects

None yet
@azamsharp

When the app builds it gives the following error message:

ld: library not found for -lPods
clang: error: linker command failed with exit code 1 (use -v to see invocation)

It used to work just fine! I am now targeting iOS 7 and Cocoapods is running into errors.

@rivera-ernesto
Contributor

I think the Pods static library target is being skipped at the beginning of the build because of the configuration does not include 64bit arm.

The latest Cocoapods fixes this.

@fabiopelosin
Member

That is what my hunch tells me as well. I'm closing the issue until further information is provided.

@azamsharp

Hi,

Thanks! I have already update the cocoapods gem but still it gets the same error: Here are some more details:

Ld /Users/azamsharp/Library/Developer/Xcode/DerivedData/VegetableTree-aktfvmbkhiktaqdmujjksoyvammb/Build/Intermediates/VegetableTree.build/Debug-iphoneos/VegetableTree.build/Objects-normal/armv7/VegetableTree normal armv7
cd "/Users/azamsharp/Documents/VT New Work/VegetableTree"
setenv IPHONEOS_DEPLOYMENT_TARGET 7.0
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.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 armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk -L/Users/azamsharp/Library/Developer/Xcode/DerivedData/VegetableTree-aktfvmbkhiktaqdmujjksoyvammb/Build/Products/Debug-iphoneos -F/Users/azamsharp/Library/Developer/Xcode/DerivedData/VegetableTree-aktfvmbkhiktaqdmujjksoyvammb/Build/Products/Debug-iphoneos -filelist /Users/azamsharp/Library/Developer/Xcode/DerivedData/VegetableTree-aktfvmbkhiktaqdmujjksoyvammb/Build/Intermediates/VegetableTree.build/Debug-iphoneos/VegetableTree.build/Objects-normal/armv7/VegetableTree.LinkFileList -dead_strip -ObjC -lsqlite3 -framework CoreGraphics -framework MobileCoreServices -framework QuartzCore -framework SystemConfiguration -framework UIKit -fobjc-arc -fobjc-link-runtime -miphoneos-version-min=7.0 -framework MapKit -framework CoreLocation -framework Social -framework Twitter -framework MessageUI -framework UIKit -framework Foundation -framework CoreGraphics -lPods -Xlinker -dependency_info -Xlinker /Users/azamsharp/Library/Developer/Xcode/DerivedData/VegetableTree-aktfvmbkhiktaqdmujjksoyvammb/Build/Intermediates/VegetableTree.build/Debug-iphoneos/VegetableTree.build/Objects-normal/armv7/VegetableTree_dependency_info.dat -o /Users/azamsharp/Library/Developer/Xcode/DerivedData/VegetableTree-aktfvmbkhiktaqdmujjksoyvammb/Build/Intermediates/VegetableTree.build/Debug-iphoneos/VegetableTree.build/Objects-normal/armv7/VegetableTree

ld: library not found for -lPods
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Here is the Podfile:

platform :ios, '7.0'
pod 'FMDB'
pod 'AFNetworking'
pod 'MBProgressHUD'
pod 'CKCalendar'
pod 'SVSegmentedControl'
pod 'REMenu', '~> 1.2.1'
pod 'TSMessages'

Hopefully, the above details help! Please let me know what can I provide further.

For some reason I cannot reopen this issue! Should I submit a new issue with the same content.

@fabiopelosin
Member

Reading it again this error appears to be related to Xcode not being able to find the Pods library. I would check that:

  • you are using the workspace
  • the Pods library builds
  • the Pods library is referenced in the products group of your project
  • your target includes the Pods library in the link with frameworks build phase

If those are not the cause of the issue it might be an architecture mismatch and I would suggest to select your target in Xcode and validate it settings (Editor menu).

For some reason I cannot reopen this issue! Should I submit a new issue with the same content.

Please no, this issue tracker is reserved to the development of the tool (open issues = things to implement) in future please use StackOverflow or the mailing list.

@azamsharp

Thanks for the reply!

you are using the workspace

YES

the Pods library builds

YES

the Pods library is referenced in the products group of your project

The Products folder in my project only has the file which represents my project. "MyProject.app". There is no Cocoapods file in the Products folder.

your target includes the Pods library in the link with frameworks build phase

YES

@fabiopelosin
Member

the Pods library is referenced in the products group of your project

The Products folder in my project only has the file which represents my project. "MyProject.app". There is no Cocoapods file in the Products folder.

Sorry the frameworks group.

@azamsharp

It is added in the frameworks group but it is red in color. I saw your posting on

#1352

Where you indicated about deleting the architecture. Not sure if I understand that deleting the architecture means.

My Project architecture is "Standard architecture (armv7, armv7s) , the pods project has the same architecture.

One of the warnings I saw was "Pods was rejected as an implicit dependency for 'libPods.a' because its architecture 'x86_64' did'nt contain all required architectures 'i386 x86_64'

@fabiopelosin
Member

One of the warnings I saw was "Pods was rejected as an implicit dependency for 'libPods.a' because its architecture 'x86_64' did'nt contain all required architectures 'i386 x86_64'

Bingo!

Where you indicated about deleting the architecture. Not sure if I understand that deleting the architecture means.

CocoaPods now matches the user architecture by default. However it doesn't match the build only for active architecture setting which should be the cause of your issue. I suggest to set it as in CocoaPods which should be the same suggestion of the build settings validation.

@azamsharp

I followed the following steps:

Go to Product > Edit Scheme
Click on Build
Add the Pods static library, and make sure it's at the top of the list
Clean and build again

The pods was missing in the list so I added it and moved it to the top of the list. Now when I run I get the following:

ld: 107 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1

@fabiopelosin
Member

This is not needed.

@azamsharp

Thanks!

You said >> I suggest to set it as in CocoaPods which should be the same suggestion of the build settings validation.

I am having a hard time understanding what it means. My Pods project has the following build settings:

Architectures: Standard architectures (armv7, armv7s)
Base SDK: Latest iOS (iOS 7.0)
Build Active Architecture Only: YES
Supported Platforms: iOS
Valid Architectures: arm64 armv7 armv7s

@azamsharp

Everywhere on the forums they are saying that delete the architectures. What does that mean? How can I delete the architectures? If I click on the architectures setting and press "Delete" button nothing happens.

#1352

@fabiopelosin
Member

If I click on the architectures setting and press "Delete" button nothing happens.

This mean that they already are the default.

Your issue should be about making the settings of the CP target match with the ones of your target. If those that you listed match I can't help you further as it is something else.

@azamsharp

What does CP target stands for?

CP = Current Project

@fabiopelosin
Member

CP = CocoaPods 😄

@huyaloha

Hi, is there any news. I still stuck in this issue when I cannot build or run the app in real device. I have updated cocoapods to version 0.25 but no luck.

@andrespch

hey guys I tried to update cocoapods and now I get this error

fatal: ambiguous argument 'xcode-5-support': unknown revision or path not in the working tree.

Any ideas?

@alloy
Member
alloy commented Sep 25, 2013

@huyaloha Be sure to read the notes for Xcode 4 users in the CHANGELOG, it might also apply if you’re migrating a project from Xcode 4 to 5. Is that your situation?

@alloy
Member
alloy commented Sep 25, 2013

@andrespch It sounds like you were using an unreleased CocoaPods. You no longer need to do that, just install the latest gems. E.g. gem install cocoapods.

@fabiopelosin
Member

That was the name of the development branch for the feature. You should edit or delete your Gemfile.


Sent from Mailbox for iPhone

On Wed, Sep 25, 2013 at 8:27 PM, Eloy Durán notifications@github.com
wrote:

@huyaloha Be sure to read the notes for Xcode 4 users in the CHANGELOG, it might also apply if you’re migrating a project from Xcode 4 to 5. Is that your situation?

Reply to this email directly or view it on GitHub:
#1400 (comment)

@azamsharp

For those of who are asking if I resolved the problem. The answer is NO. Unfortunately, I had to take out Cocoapods from my project.

@andrespch

Thanks guys, with a little help from a friend I ended up fixing it by
setting on the pods project "Build active architechtures only" to no. and
then the standard architechtures for both the targets and the project.
Hope this helps someone.

2013/9/25 Fabio Pelosin notifications@github.com

That was the name of the development branch for the feature. You should
edit or delete your Gemfile.


Sent from Mailbox for iPhone

On Wed, Sep 25, 2013 at 8:27 PM, Eloy Durán notifications@github.com
wrote:

@huyaloha Be sure to read the notes for Xcode 4 users in the CHANGELOG,
it might also apply if you’re migrating a project from Xcode 4 to 5. Is

that your situation?

Reply to this email directly or view it on GitHub:
#1400 (comment)


Reply to this email directly or view it on GitHubhttps://github.com/CocoaPods/CocoaPods/issues/1400#issuecomment-25113238
.

@alloy
Member
alloy commented Sep 25, 2013

@andrespch Did you try to change the value in your app target instead as indicated in the CHANGELOG ?

@huyaloha

@alloy You saved my life. It works when I change the Build Active Architecture Only to same as in Pods.

@sgryschuk

@andrespch that worked for me, thanks!

@georgbachmann

i just ran into the same problem today when changing

platform :ios, '6.0'

to
platform :ios, '7.0'

I did check my "Build Active Architecture Only" Settings on both my project and the pod project and they are the same...
"Apple Mach-O Linker Error" because of "Undefined symbols for architecture i386"

I even deleted the workspace, the podfile.lock and the pods folder and reinstalled using
pod install
but still my app won't compile any more

and help is very much appreciated!

@georgbachmann

I have the ARCHS settings in my project set
xcode_cocoapods_problem
The settings are the same on the pod project as well as my actual project.
I also tried out including the 64bit version as well as without. Still the error is present when compiling.

Undefined symbols for architecture i386
....
@fabiopelosin
Member

@georgbachmann Does any of your pods include a vendored library or framework?

@georgbachmann

@irrationalfab I don't really know...
I just had a look at my errors and most of them are related to

pod 'MagicalRecord'
pod 'SDWebImage'
pod 'AFNetworking', '~> 1.2.1'

f.e.:

"_kCGImagePropertyPixelHeight", referenced from:
  -[SDWebImageDownloaderOperation connection:didReceiveData:] in libPods.a(SDWebImageDownloaderOperation.o)

"_UTTypeCopyPreferredTagWithClass", referenced from:
  _AFContentTypeForPathExtension in libPods.a(AFHTTPClient.o)

"_NSMergeByPropertyObjectTrumpMergePolicy", referenced from:
  +[NSManagedObjectContext(MagicalRecord) MR_setRootSavingContext:] in libPods.a(NSManagedObjectContext+MagicalRecord.o)

Thanks for helping!

@georgbachmann

I still can't compile my project if I do a 'pod update'
would be so great if someone could help me... i'd really like to update my cocoapods

Still tons of messages like those:

Undefined symbols for architecture i386:
"_NSInMemoryStoreType", referenced from:
  -[NSPersistentStoreCoordinator(MagicalRecord) MR_addInMemoryStore] in libPods.a(NSPersistentStoreCoordinator+MagicalRecord.o)
"_NSInferMappingModelAutomaticallyOption", referenced from:
  +[NSPersistentStoreCoordinator(MagicalRecord) MR_autoMigrationOptions] in libPods.a(NSPersistentStoreCoordinator+MagicalRecord.o)

all of them are Apple Mach-O Linker Errors

@fabiopelosin
Member

@georgbachmann This issue appears to be related to modules. Can you confirm that disabling them in the target of the Pod fixes the build?

@georgbachmann

Just to test that i removed the MagicalRecords out of the target and got less errors, that's correct.
Errors remain for f.e. DropboxSDK, TestFlightSDK

But as I need f.e. MagicalRecords in my project I can't disable the in my pod-target....

@fabiopelosin
Member

To be clear I was referring to disabling modules in the build settings of the target. Not removing the target.

@georgbachmann

Ah, ok... I didn't get that...
When searching for "module" in my Pods' build settings I can see one called "Enable Modules (C and Obj-C)"
I tried building with it set to YES as well as NO but it's the same error with both settings...

But then I had a closer look at my errors and from 49 build errors i managed to get down to 6...
I included MagicalRecord which through the Pod-Project imported the "CoreData" Framework for me. Now I had to do it myself in my main Project... Same with "MobileCoreServices"....

Now there are 6 errors remaining which I don't understand why I get them....

One is caused by a TFLog (which comes from the TestFlight pod....)
"_TFLog"
"OBJC_CLASS$_TestFlight"

And the others seem to be caused from the Dropbox-iOS-SDK pod...

Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_DBRestClient"
  "_OBJC_CLASS_$_DBSession"
  "_kDBRootDropbox"
  "_OBJC_CLASS_$_TestFlight"

Any ideas how I could get rid of them? As they seem to be coming from the pods, I don't think including another framework would help here?!?

Thank you for helping me...

@fabiopelosin
Member

Adding frameworks manually? I think tha your build settings are overriding CocoaPods ones. Check that the value of the xcconfig end up in your target.


Sent from Mailbox for iPad

On Fri, Oct 18, 2013 at 4:41 PM, georgbachmann notifications@github.com
wrote:

Ah, ok... I didn't get that...
When searching for "module" in my Pods' build settings I can see one called "Enable Modules (C and Obj-C)"
I tried building with it set to YES as well as NO but it's the same error with both settings...
But then I had a closer look at my errors and from 49 build errors i managed to get down to 6...
I included MagicalRecord which through the Pod-Project imported the "CoreData" Framework for me. Now I had to do it myself in my main Project... Same with "MobileCoreServices"....
Now there are 6 errors remaining which I don't understand why I get them....
One is caused by a TFLog (which comes from the TestFlight pod....)
"_TFLog"
"OBJC_CLASS$_TestFlight"
And the others seem to be caused from the Dropbox-iOS-SDK pod...
Undefined symbols for architecture i386:
"OBJC_CLASS$_DBRestClient"
"OBJC_CLASS$_DBSession"
"_kDBRootDropbox"
"OBJC_CLASS$_TestFlight"
Any ideas how I could get rid of them? As they seem to be coming from the pods, I don't think including another framework would help here?!?

Thank you for helping me...

Reply to this email directly or view it on GitHub:
#1400 (comment)

@georgbachmann

I checked my settings and it seems as if the Pod xcconfig is at least used in my project.
What I don't get is that I never changed any build settings whatsoever on my own...

bildschirmfoto 2013-10-19 um 10 26 12

@fabiopelosin
Member

Each target should use a configuration, generated by CocoaPods, named after itself. Definitely your set looks not correct. As this is not the place to discuss usage questions please submit any further question to Stack Overflow or to the mailing list, after having a check to the documentation at http://docs.cocoapods.org.

@cjvraay
cjvraay commented Nov 18, 2013

I also had a problem using CocoaPods and the MagicalRecord pod that suddenly stopped working and as per the comment from georgbachmann, adding the CoreData framework to my target fixed it.

@rivera-ernesto
Contributor

@cjvraay Then probably the podspec needs an update ;)

@mal3k
mal3k commented Feb 3, 2014

I fixed that issue by setting the architectures in the Pod target the same as the architecture on my project target (see attached screenshot)

That was working fine, but for somehow, the architecture on the Pod target got changed. Just make sure its the same as your app target architecture.
screen shot 2014-02-03 at 10 26 14

@alloy
Member
alloy commented Feb 3, 2014

Attention

Please read the answer in the troubleshooting guide.

@NickNick
NickNick commented Feb 5, 2014

I just installed cocoapods, and I have this issue with this as podfile and a completely new XCode "single view"-project.

platform :ios, '7.0'
pod 'RestKit', '~> 0.20.0'

ios, '5.0' or '7.0' doesn't seem to matter, but my deployment target is 7.0

Screenshot of Pods-settings:
screen shot 2014-02-05 at 22 27 40 439

Screenshot of new project settings (they are all at their default):
screen shot 2014-02-05 at 22 27 46 671

Steps to reproduce:
Create a new XCode iOS "Single View"-Project
Create the podfile && pod install
open ThatProject.xcworkspace
Try to build it, fails with "ld: library not found for -lPods"

@mal3k
mal3k commented Feb 5, 2014

@NickNick see my reply, I had exactly the same error when trying to archive my app #1400 (comment)

@NickNick
NickNick commented Feb 5, 2014

@mal3k In the screenshots I posted, the architectures are the same, right?

@NickNick
NickNick commented Feb 6, 2014

Step 4 of http://guides.cocoapods.org/using/troubleshooting.html#using-the-cocoapods-project resolved this issue for me. When/why is it necessary? Isn't the Pods-target something XCode should automatically find, because it's in the same workspace? Like in CMake?

@ansel1
ansel1 commented Feb 24, 2014

I tried the suggested resolution in the troubleshooting guide, but it still isn't working. Our target has both ARCHS and VALID_ARCHS set to just arm7 (limited by a library we use). Build active archs is set to true for debug. So when we build, I think the pods project is building the arm64 arch (because I'm trying to run it on my 5s), but my project is building arm7. I think I'm following all the recommendations (ensure my target has an ARCHS setting, ensure my target's Build Active Archs is true for debug to match the pods project setting), but still no go.

@mattsellars

Unfortunately I cannot set my project's ONLY_ACTIVE_ARCH to YES otherwise if fails to install to the iPhone 5S due to using arm64 as the active architecture(some of our 3rd party frameworks are not arm64 yet). Is there any way I can tell cocoapods to set the ONLY_ACTIVE_ARCH to NO in the Podfile?

@alloy
Member
alloy commented Feb 28, 2014

To modify the Pods Xcode project you can use the post_install hook http://guides.cocoapods.org/syntax/podfile.html#post_install.

@mattsellars

Alloy thanks for the tip that does exactly what I needed!

@pbernery
Contributor

It also worked for me. I cannot build with 64 bits because of a third party library. As pointed out by @alloy, Adding these lines in my Podfile fixes the build issue:

post_install do |installer_representation|
  installer_representation.project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['VALID_ARCHS'] = 'armv7 armv7s'
      config.build_settings['ARCHS'] = 'armv7 armv7s'
    end
  end
end

However, CocoaPods complains about multiple values found:

[!] Found multiple values (`armv7`, `armv7s`) for the architectures (`ARCHS`) build setting for the `Pods` target definition. Using the first.

Any idea how to fix this?

@msmollin
msmollin commented Apr 8, 2014

@pbernery We have the same issue as others with 3rd party libs. Here's how we did it and thus kept arm64 support in our main project -

post_install do |installer_representation|
  installer_representation.project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
    end
  end
end

--Edit--
That also resolves the warning you see in your logs.

@dethell
dethell commented Jul 7, 2014

I'm using XCode 6 Beta 2 with the latest RestKit Pod and had the error about not finding -lPods. Following the troubleshooting steps didn't help. I realized it might be due to my duplicating the release configuration into one for "Ad Hoc". I usually have an Ad Hoc as well as a TestFlight configuration to keep them separate from Release.

Setting the Archive setting in the Scheme of both the Pods target and the app target to Release instead of my Ad Hoc configuration allowed the archive to be built.

Not sure if that is an XCode 6 specific problem or if this happens in XCode 5 as well. I never used CocoaPods before XCode 6 beta.

@AliSoftware
Contributor

@dethell when you duplicated your configuration to add te "AdHoc" config did you also think of adding it in your Podfile as we'll especially to tell CocoaPods to consider this configuration as if it was a "Release"?

IIRC the syntax should be sthg like that (see the guides here):

xcodeproj 'yourproject', 'Ad Hoc' => :release

@dethell
dethell commented Jul 8, 2014

No I didn't. I'll try that.

On Monday, July 7, 2014, AliSoftware notifications@github.com wrote:

@dethell https://github.com/dethell when you duplicated your
configuration to add te "AdHoc" config did you also think of adding it in
your Podfile as we'll especially to tell CocoaPods to consider this
configuration as if it was a "Release"?

IIRC the syntax should be sthg like that (see the guides):

workspace 'yourworkspace', 'AdHoc' => :release


Reply to this email directly or view it on GitHub
#1400 (comment)
.

@albsala
albsala commented Jul 14, 2014

@pbernery @msmollin this works for me too:

post_install do | installer |
    installer.project.build_configurations.each do |config|
        config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
    end
end

Targets inherit this setting.

@dethell
dethell commented Jul 14, 2014

Yes, adding the :release config line for my ad hoc build fixed this problem.

On Monday, July 7, 2014, AliSoftware notifications@github.com wrote:

@dethell https://github.com/dethell when you duplicated your
configuration to add te "AdHoc" config did you also think of adding it in
your Podfile as we'll especially to tell CocoaPods to consider this
configuration as if it was a "Release"?

IIRC the syntax should be sthg like that (see the guides):

workspace 'yourworkspace', 'AdHoc' => :release


Reply to this email directly or view it on GitHub
#1400 (comment)
.

@Glavin001 Glavin001 referenced this issue in Streamlyne/ios-app Aug 25, 2014
Closed

"Unable to download app" via TestFlight #38

@dariodepasquale

Very good Mal3k: your solution worked for me.

@pikaboo
pikaboo commented Feb 28, 2016

this solution:

post_install do | installer |
    installer.project.build_configurations.each do |config|
        config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
    end
end

does not work for me

everytime i update the pods, i have to manually change the active architecture to NO
is it possible to make it automatic somehow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment