library not found error in Xcode (not pods) - xcode

I added 'libAbc.a' file in my Xcode project at TARGETS > Build Phases > Link Binary With Libraries > Add files, and added the path of the file at Library Search Paths both Debug and Release. Then I got the following error:
directory not found for option '-L"(my Xcode project directory)/../lib'
library not found for -lAbc
The libAbc.a file certainly exists in that paths.
How can I fix it?

Related

iOS build: command ld failed with a nozero exit code

For a react-native project, I got the following error during Xcode build:
clang: error: no such file or directory: '/Users/user172615/Library/Developer/Xcode/DerivedData/xxx/Build/Products/Debug-appletvsimulator/libBVLinearGradient.a'
Command Ld failed with a nonzero exit code
This happened after adding react-native-linear-gradient, and following the instructions in https://github.com/react-native-community/react-native-linear-gradient (manual installation for iOS).
As specified in https://github.com/react-native-community/react-native-linear-gradient#manually, libBVLinearGradient.a is included in Build Phases -> Link Binary With Libraries for the target myProject
libBVLinearGradient.a is also included in General -> Frameworks, Libraries and embedded content.
I tried deleting DerivedData, and rebuilding. Didn't help.
Since the error indicates Debug-appletvsimulator, I included libBVLinearGradient.a in Build Phases -> Link Binary With Libraries for the target myProject-tvOS
When this didn't help, I deleted the myProject-tvOS target. All didn't help.
I am using Xcode 11.3, react-native 0.59.9.
Any idea?
Instead of downloading it, do this instead.
Click on clone existing project
Then copy this link
https://github.com/react-native-community/react-native-linear-gradient
And paste the link here
Then it will download the project.
If the problem still happens, then create a new project, copy and paste everything.

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 "directory not found for option -L" errors

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.

xcodebuild header files not found in ReskIt

I am pretty new to Xcode development. We are using command line tools to build the iOS project. We kep on getting the RestKit/RestKit.h file not found error while using command line build. If we use the normal XCode utility build it build without any issues.. There are few more thrid party code being used which may also have the same issue.
The folder struture of the project is like this.
--Project.xcodeproject
-- RestKit
----RestKit.xcodeproject
--SDWebImageKit
-----SDWebImageKit.xcodeproject
-----SDWebImage
---- .h and .m files
What path should we set in header search paths to properly build this in xcodebuild command line utility.
I resolved all the issues by creating a workspace, adding a scheme and building hte workspace using xcodebuild. I didnt have to chnage any of the header settings as being set in XCode GUI.

Setting dylib paths as a XCode build step

I have a Cocoa application as XCode project that has several supplementary bits of functionality as dylib targets.
When XCode builds the project, it places all the build outputs in a single folder: The .app bundle and the dylib files. And when executed from the XCode debugger, the .app launches.
I can't however launch the application from finder.
How do I setup XCode to 'deploy' the app in a standalone state? I have found that I can use ld on the actual app binary to contain a relative path to the dylibs: #executable_path/../../mylib.dylib
Running a script after each build seems wrong: there must be some way (that Im totally missing) to do this easily from inside XCode - it must be a common issue surely?
It looks like that XCode supports having #executable_path, #loader_path and #rpath used in the Target Info > Build > Linking > Dynamic Library Install Name setting (LD_DYLIB_INSTALL_NAME) setting.
The help text says: "Sets an internal "install path" (LC_ID_DYLIB) in a dynamic library. Any clients linked against the library will record that path as the way dyld should locate this library"
This seems very promising, but usability is a problem if I need to link dylibs in multiple paths against a common library - the relative path is going to be different each time.
Running my testapp from finder, I get the following (relevant) error text
Dyld Error Message:
Library not loaded: #executable_path/../../util.dylib
Referenced from: /Volumes/data/Code/TestApp/build/Debug/TestApp.app/Contents/MacOS/TestApp
Reason: image not found
util.dylib is in /Volumes/data/Code/TestApp/build/Debug/ so I am confused :/
You should use a Copy Files build phase to copy the dylib to the app's bundle when building the app. You'll want to copy it to Frameworks. You can then set the install path to #executable_path/../Frameworks/mylib.dylib.

Resources