Xcode "directory not found for option -L" errors - xcode

I'm getting these errors:
ld: warning: directory not found for option '-L"/pathToMyApp/MyApp/Shared/Libraries/ADMS_AppLibrary"'
ld: warning: directory not found for option '-L"/pathToMyApp/MyApp/Shared/Libraries/TestFlightSDK1.1"'
ld: warning: directory not found for option '-L"/pathToMyApp/MyApp/Shared/Libraries/Medialets"'
ld: library not found for -lTestFlight
clang: error: linker command failed with exit code 1 (use -v to see invocation)
These directories do in fact exist at the paths above.
The thing is, the app used to compile fine. All I did was add a new version of the Medialets library to the project, and now I get these erros.

There are two errors that people seem to be confused about:
If it is a "directory not found for option '-L/..." error That means it's a Library Error, and you should try to:
Click on your project (targets)
Click on Build Settings
Under Library Search Paths, delete the paths
If it is a "directory not found for option '-F/..." That means it's a Framework Error, and you should try to:
Click on your project (targets)
Click on Build Settings
Under Frameworks Search Paths, delete the paths

I had the same problem when I added a new library to the project.
It seems that the linker error occurs when the Xcode 5 adds a path to "Library Search Paths" automatically when adding a new library directory to the project.
The linker error disappeared once I manually edited the paths. (I didn't essentially change the path, just tried some different formats such as $(PROJECT_DIR)/path/to/library or "$(SRCROOT)/path/to/library". It worked even after changed back to the original format.)
I think it's a bug of Xcode. I'm using Xcode 5.1 (5B130a).

For the "-L" issue,
If you are using cmake (in my case 3.3.2) and use the xcode generator, it will generate multiple entries for each link-directory you specify,
link_directories ("${PROJECT_SOURCE_DIR}/SDKs/thelib/lib")
see the cmake sourcecode, cmGlobalXCodeGenerator::AddDependAndLinkInformation(...) where it does this:
{ ...
if(this->XcodeVersion > 15)
{
// Now add the same one but append
// $(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) to it:
linkDirs += " ";
linkDirs += this->XCodeEscapePath((*libDir + "/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)").c_str());
}
linkDirs += " ";
linkDirs += this->XCodeEscapePath(libDir->c_str());
}
which will result in XCode having these entries in the Lib Search Path
/Users/myuser/thelib/lib/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
/Users/myuser/thelib/lib
So that makes it a bit more difficult to get rid of this warning; Depending on your file-structure, one of those is likely going to be wrong - and even if you manually remove it they will be back next time your project is regenerated.
One work-around is to just create empty directories for the ones it complains about...
It's also possible to "pass some arguments" to the linker using "-Wl", but so far I didn't find out what to pass to silence that specific warning.

ld: warning: directory not found for option '-L"----it's a Library Error
Select your project go to the Build Settings tab,Under Library Search Paths, Replace the path with this string $(SRCROOT)

Just removing the lib from "Link With Binary With Libraries" section of "Build Phases" doesn't seem to resolve the issue in Xcode 6 at least.
1) Go to your project navigator and find the "Frameworks" folder
2) your lib is probably there already, so just right click and "Delete"
3) Select "Remove References"
4) go to your repo or project folder where all your files are and drag
it into the "Frameworks" folder
5) clean, and rebuild and the errors should go away

I did not have any added library paths under Library Search Paths, but instead I could solve this issue by deleting the Derived data, by going to Preferences -> Locations

I started seeing both -L and -F errors in the build for a react native app and none of the existing answers solved the problem.
For me the problem was I had updated the ios version in my Podfile:
platform :ios, '11.0'
but not in the xcode project.pbxproj file:
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
(The setting appears multiple times in the .pbxproj file)
Making the versions match solved the problem.

Related

Xcode 7 build failed due to ld: library not found for -liPhone-lib

I'm trying to build my first ARKit app with Xcode 9 beta for iOS 11.
When I build my application on Xcode, I get the following error
"Xcode 7 build failed due to ld: library not found for -liPhone-lib
error: linker command failed with exit code 1"
Any idea how to solve it?
I guess its Unity3D game. I also observed linker error for liPhone-lib.
Solution is simple, just drag liPhone-lib's parent folder to library search path.
Clean Build. Cheers
In my project, liPhone-lib placed in Libraries folder. So I just dragged Libraries folder to Xcode library search path...its solved my problem.
See attach image:
Looks like either Unity or Xcode incorrectly puts double quotes around the search path for the Libraries folder.
In Xcode, click your target and open Build Settings
Find Library Search Paths and remove all the escaped double quotes,
In the project's Library Search Paths, find the entry that looks like this:
\"$(SRCROOT)/Libraries\"
double click the entry to edit it and remove the escaped double quotes, so it looks like this:
$(SRCROOT)/Libraries
The project should now compile correctly again.

Xcode: After removal of framework - "Linker command failed with exit code 1"

I tried to install the Charts framework for my application but for some reasons things wouldn't work. Therefore, I decided to remove it from the application in order to reinstall a different version, but now I get an error when building:
ld: warning: directory not found for option '-F/Users/antonkallbom/Library/Developer/Xcode/DerivedData/Aiida-dwnonkyfsunbssdfeglitwzmrecb/Build/Products/Debug-iphonesimulator/Charts'
ld: framework not found Charts
clang: error: linker command failed with exit code 1 (use -v to see invocation)
So I guess I need to remove the path somehow in order to be able to build the project? I tried deleting all the filed in DerivedData, but without success.
I saw some similar problems where you were supposed to remove the paths from "Framework Search Paths", but I don't seem to have it in Xcode?
The setting is within Build Settings:
Search for "Search Paths" and you should see Framework Search Paths...
Okay, I finally got it working! :)
There were flags included in .debug.xcconfig and .release.xcconfig, as well as some additional paths in -frameworks.sh. After removing them, it works!
Should have thought about searching the whole project earlier... Thanks for the help!

Swift 2.0 import and compile with sqlite3 library

Trying to test some sqlite with Swift 2 but I cannot make a correct build when adding the libsqlite3.0.tbd file on the Link Binary with libraries. I also tried to add the libsqlite3.dylib from /usr/lib but I get the following error.
ld: library not found for -lsqlite3
clang: error: linker command failed with exit code 1 (use -v to see invocation)
any idea on how can I correctly build with the library. It is just an empty project just for testing. Thanks a lot in advance.
Seeing this here as well. I am assuming the 'tbd' means 'to be done', as in, the library still needs to be built for the OSX 10.11 SDK. Should disappear in the next beta...
Meanwhile, it can be fixed by going to your project's settings -> Build Phases -> Link with binaries. Click '+', then click 'Add other'. Now hit Cmd-Shift-G and navigate to /usr/lib. There, you can select libsqlite3.dylib. Now your project should build without error.
In order to prevent errors when moving the XCode project around, make sure the reference to libsqlite3.dylib uses an absolute path (click on the .dylib in the file list, then go to the properties pane and select 'absolute path')
Meanwhile, you can use libsqlite3.dylib from previous SDK. open terminal, type
locate libsqlite3.dylib
You'll find several files like these:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/lib/libsqlite3.dylib
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libsqlite3.dylib
Go to your project's setting -> Build Phases -> Link with Binaries. Add BOTH files by clicking +, then Add Other. Hit Cmd-Shift-G, and copy-paste the file path. Click Open.
If you install sqlite3 using macports, remove /opt/local/lib from Library Search Path in Build Settings.

xcode library not found

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.
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.
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).
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.
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:
For me, I open the projectname.xcworkspace file and it all works.
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.
This worked for me:
Go to build setting -> Linking -> Other Linker Flags -> Remove all other than $(inherited)
Cd ios && pod update
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
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
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
You can also try to lint with the --use-library option, as cocoapods lint libraries as framework by default since v0.36
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.
In XCode 10.1, I had to set "Library Search Paths" to something like $(PROJECT_DIR)/.../path/to/your/library
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.

Xcode linker Directory not found for option

Xcode 4 is throwing me a warning about directory not found for option '-L/Users/t2wu/Documents/blah blah'. Yes it shouldn't be found because I removed it. I remove the directory and I also removed the directory setting in both the target and the project library search path. I also remove the .a file which I was linking before from the "Link binaries with Libraries". It compiles fine, it just gives me the warning. Why is it still having the -L flag?
Check the Build settings tab and make sure that the "Library search paths" option is empty.
At last resort, fire up Terminal and cd to the app project directory (appname.xcodeproj) and do a fgrep for the erroneous search path. I've found some of these lurking in the project.pbxproj file; ended up editing the file manually to get rid of them. (Of course you should make a copy of the file before doing so, in case you trash the project file.)
It'd also be worthwhile to do a "clean" on the project. How to Empty Caches and Clean All Targets Xcode 4.
I had the same issue in my project, it contains multiple custom framework created by me and the project. My issue is resolved by removing 'Framework search Paths' and 'Library Search Paths' from the target which has this issue.
In my case in targets -> build settings I removed searchpaths for which errors occured. Then removed libraries from project and added them again.
You may need to clear the Search Paths for the Tests target as well as the main project. This had me stumped for a little while.
I checked the library search path
I went to Build settings -> Search Paths change the "Framework Search Paths" to $(inherited)...that solved my problem
Sometimes, this error occurs if you open Project.xcodeprojinstead of Project.xcworkspace. Check your project directory and make sure to open Project.xcworkspace.

Resources