Swift 2.0 import and compile with sqlite3 library - swift2

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.

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.

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 tests. Clang: error: linker command failed with exit code 1 for FBSDKCoreKit

I added new Tests target to my project, but I have this error even I don't use any FBSDKCoreKit dependencies in the tests. Generally I use CocoaPods, but not for FBSDKCoreKit framework. Tried everything — no results.
ld: framework not found FBSDKCoreKit
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Normal Run builds are working perfectly, just tests are not running.
In the test target settings:
My mistake. I just didn't follow all steps from FB doc:
Drag the FBSDKCoreKit.framework, FBSDKLoginKit.framework, and FBSDKShareKit.framework files into the Frameworks group of Xcode's Project Navigator. In the displayed dialog, choose Create groups for any added folders and deselect Copy items into destination group's folder. This references the SDK where you installed it rather than copying the SDK into your app.
Open Xcode's Build Settings tab in your project.
Add ~/Documents/FacebookSDK to the project's Framework Search Paths setting.
https://developers.facebook.com/docs/ios/getting-started/

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.

How to install VTK 6.1 for OSX 10.8 with Cocoa/XCode support?

The extremely helpful guidelines posted at http://www.vtk.org/Wiki/Cocoa_VTK and via the readme file by Sean McBride and Mike Jackson inside the VTK repo were slightly out of date for VTK 6.1. So in case this helps anybody, I'm posting instructions for installing VTK 6.1 on OSX 10.8 with support for the SimpleCocoaVTK Xcode project.
* Installing VTK 6.1 for OSX 10.8 with Cocoa support *
These instructions slightly modify Ryan Glover's instructions at http://www.vtk.org/Wiki/Cocoa_VTK and the README.rtf in the VTK/Examples/GUI/Cocoa/Documentation folder by Sean McBride and Mike Jackson.
Clone the VTK git repo into a directory of your choice:
cd /Users/you/
git clone https://github.com/Kitware/VTK.git
cd VTK
git checkout tags/v6.1.0
make a build directory
mkdir VTKBuild
cd VTKBuild
Run the VTK cmake script
You will now be inside /Users/you/VTK/VTKBuild, run cmake from here (using the parent directory's CMake files):
cmake ..
Edit lots of lines in the newly generated CMakeCache.txt (in the current VTKBuild directory). One issue I had was that there were error if I didn't use a full path for the CMAKE_INSTALL_PREFIX. So make sure to use "/Users/you/" instead of "~":
CMAKE_INSTALL_PREFIX:PATH=/Users/you/VTK/VTKBuild
BUILD_SHARED_LIBS:BOOL=OFF
CMAKE_BUILD_TYPE:STRING=Debug
VTK_USE_SYSTEM_ZLIB:BOOL=ON
CMAKE_OSX_ARCHITECTURES:STRING=i386;x86_64
CMAKE_OSX_SYSROOT:STRING=/Applications/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk
Compile the VTK project (this might take over an hour to run!):
make
Copy headers to an include directory:
make install
VTK should now be completely installed in the VTKBuild directory and ready to use in an XCode project!
Go to your finder, navigate to Users/you/VTK/Examples/GUI/Cocoa/ and double click to open SimpleCocoaVTK.xcodeproj in XCode.
In the XCode menubar (at the top of the screen) Go to Preferences->Locations->Source Trees and use the + button to add in two source trees:
vtk-debug-include vtk-debug-include Users/you/VTK/VTKBuild/include/vtk-6.1
vtk-debug-lib vtk-debug-lib Users/you/VTK/VTKBuild/lib
Click on the XCode project and delete all the references to vtk 6.0:
In the project view, select Targets->SimpleCocoaVTK and then press "Build Phases" and then open the "Link Binary With Libraries". Delete all the files that begin with "libvtk" and end with "6.0.a"
In the file view of the SimpleCocoaVTK project, hightlight and delete all the files in the vtk-libraries folder.
Make sure the XCode file view is active. Then in the finder, navigate to /Users/you/VTK/VTKBuild/lib, and select all the files that begin with "libvtk" and end with "6.1.a". Drag these files into the folder "vtk-libraries" in the XCode file view.
In XCode, do a Product->Clean
You can now build and run the sample SimpleCocoaVTK project.
I also had to set
VTK_WRAP_PYTHON:BOOL=ON
in CMakeCache.txt
It depends on what user you are too on your machine (computer) and the permissions relevant to that user. I did a find and replace on the CMakeCache.txt file and changed all /usr/local references to /Users/myusername/Develop/VTKInstall. That way everything's at your fingertips and you don't have to change permissions on things.
When you open up the Cocoa example make sure to set in you preferences these paths (e.g. Preferences->Locations->Source Trees). Also you'll need to re-import your vtk-libraries into the project.
I'm running Yosemite with XCode 6.1.1. I hope this helps someone!
If you get error messages likes this, when trying to build VTK:
#error: garbage collection is no longer supported
make[2]: *** Rendering/OpenGL/CMakeFiles/vtkRenderingOpenGL.dir/vtkCocoaRenderWindowInteractor.mm.o] Error 1
make1: *** [[Rendering/OpenGL/CMakeFiles/vtkRenderingOpenGL.dir/all] Error 2
You need to remove a flag in the source CMakeLists.txt:
#IF(APPLE)
SET(VTK_OBJCXX_FLAGS_DEFAULT "-fobjc-gc")
SET(VTK_REQUIRED_OBJCXX_FLAGS ${VTK_OBJCXX_FLAGS_DEFAULT} CACHE STRING "Extra flags for Objective-C++ compilation")
MARK_AS_ADVANCED(VTK_REQUIRED_OBJCXX_FLAGS)
ENDIF(APPLE)#
Either outcomment or delete it all together. Then run cmake again in an empty build directory. Check in the generated CMakeCache.txt in your build directory if it contains a key like VTK_REQUIRED_OBJCXX_FLAGS, it shouldn´t, try running cmake in an empty build directory again.
This 'bug' maybe fixed in future VTK versions.
Source: [Solved] Build Qt 5.2.1 + VTK 6.1.0 + CMake 2.8.12.2

Resources