Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't archive on Xcode: CocoaPods linking error

On an iOS project, when I compile my project to run it, it works fine.
But if I archive it, it fails with the following error:

ld: file not found: /Users/xxxxx/Work/xxxxx/codes/xxxxx/DerivedData/xxxxx/Build/Intermediates/ArchiveIntermediates/xxxxx/InstallationBuildProductsLocation/Applications/libPods.a
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I'm using Xcode 4.6 and iOS 5.0.

like image 291
Mickey Cheong Avatar asked Feb 01 '13 10:02

Mickey Cheong


People also ask

Why can't I install CocoaPods in Xcode?

It will not be possible to install Cocoapods in the generated Xcode project which will result in link errors when building your application. Building native extensions. This could take a while... libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. --srcdir=.

Why does Xcode keep crashing when I archive a build?

After that I was able to archive and export the build on Xcode 13.1 again. So it seems that Xcode 13.1 has a bug where potentially any error thrown during the distribution phase will just crash the app. The bug was introduced in our project because one of our dependencies is not ready to use bitcode.

Why doesn't Xcode detect implicit dependencies when linking?

If Xcode complains when linking, e.g. Library not found for -lPods, it doesn't detect the implicit dependencies: Go to Product > Edit Scheme Add the Pods static library, and make sure it's at the top of the list

Why can’t I use bitcode on Xcode?

The bug was introduced in our project because one of our dependencies is not ready to use bitcode. Disabling bitcode on Xcode was solving the issue, but using the xcodebuild command was not, because we tried using an export options plist file generated by Fastlane, which seems to be defective.


1 Answers

I searched for a long time and finally got something and solved the same problem for me. For anyone who still needs:

In Build Setting > Other Linker Flag:

Probably the flag is different for Debug and others.
Try to change wherever $(TARGET_BUILD_DIR) to $(BUILT_PRODUCTS_DIR).

For me, I changed $(TARGET_BUILD_DIR)/libPods.a to $(BUILT_PRODUCTS_DIR)/libPods.a, and problem solved.

like image 101
PowerQian Avatar answered Oct 21 '22 01:10

PowerQian