xcode library not found
XcodeXcode Problem Overview
I'm getting the following error:
> ld: library not found for -lGoogleAnalytics > clang: error: linker command failed with exit code 1 (use -v to see invokation)
I've spent some time googling but can't find how to fix this problem. I'm new to xcode and this is an existing project that I need to work on.
Xcode Solutions
Solution 1 - Xcode
You need to set the "linker search paths" of the project (for both Debug and Release builds). If this library was in, say, a sibling directory to the project then you can set it like this:
$(PROJECT_DIR)/../GoogleAnalytics/lib
(you want to avoid using an absolute path, instead keep the library directory relative to the project).
Solution 2 - Xcode
In my case, the project uses CocoaPods. And some files are missing from my project.
So I install it from CocoaPods: https://cocoapods.org/.
And if the project uses CocoaPods we've to be aware to always open the .xcworkspace folder instead of the .xcodeproj folder in the Xcode.
Solution 3 - Xcode
All in all, the Xcode cannot find the position of library/header/framework, then you tell Xcode where they are.
set the path that Xcode use to find library/header/framework in Build Settings --> Library/Header/Framework Search Paths.
Say, now it cannot find -lGoogleAnalytics
, so you add the directory where -lGoogleAnalytics
is to the Library Search Paths.
Solution 4 - Xcode
In my case I had a project with lots of entries in "Build Settings > Other Linker Flags"
I needed to reduce it down to just
$(inherited)
-ObjC
Old settings:
Updated settings:
Solution 5 - Xcode
For me, I open the projectname.xcworkspace file and it all works.
Solution 6 - Xcode
If you have pods installed, make sure to open the workspace folder (white Xcode icon) not the project folder. This resolved the library not found for ...
error. Very simple issue but I was stuck on this for a long time.
Solution 7 - Xcode
If you are using Pods to include the GoogleAnalytics iOS SDK into your project, it's worth noting that since the 3.0 release your Other Linker Flags
needs to include -lGoogleAnalyticsServices not the old -lGoogleAnalytics
Solution 8 - Xcode
This worked for me:
Solution 9 - Xcode
If your library file is called libGoogleAnalytics.a you need to put -lGoogleAnalytics so make sure the .a file is named as you'd expect
Solution 10 - Xcode
You can also try to lint
with the --use-library
option, as cocoapods lint libraries as framework by default since v0.36
Solution 11 - Xcode
The problem might be the following: SVN ignores .a files because of its global config, which means someone didn't commit the libGoogleAnalytics.a to SVN, because it didn't show up in SVN. So now you try to check out the project from SVN which now misses the libGoogleAnalytics.a (since it was ignored and was not committed). Of course the build fails.
You might want to change the global ignore config from SVN to stop ignoring *.a files.
Or just add the one missing libGoogleAnalytics.a file manually to your SVN working copy instead of changing SVNs global ignore config.
Then re-add libGoogleAnalytics.a to your XCode project and commit it to SVN.
Solution 12 - Xcode
In XCode 10.1, I had to set "Library Search Paths" to something like $(PROJECT_DIR)/.../path/to/your/library
Solution 13 - Xcode
For me it was a silly thing: my mac uploaded the file into iCloud, and that is why Xcode did not find it.
If you turn off the automatic upload, it wont happen again.
Solution 14 - Xcode
None of the above worked for me, what did was making sure the Pod file platform :ios, '11.0' matched with the minimum deployment target in the XCODE setting