Linking to Sqlite in Xcode 7 - xcode

I'm following this tutorial here: http://www.techotopia.com/index.php/An_Example_SQLite_based_iOS_8_Application_using_Swift_and_FMDB - unfortunately it's written for Xcode 6, not 7.
I followed these steps up to "Creating and Preparing the SQLite Application Project":
Once the project has been created, the next step is to configure the project to include the SQLite dynamic library (libsqlite3.dylib) during the link phase of the build process. Failure to include this library will result in build errors.
To add this library, select the target entry in the Xcode project navigator (the top entry with the product name) to display the General information panel. Select the Build Phases tab to display the build information. The Link Binary with Libraries section lists the libraries and frameworks already included in the project. To add another library or framework click on the ‘+’ button to display the full list. From this list search for, and then select libsqlite3.dylib and click Add.
...however libsqlite3.dylib is not in the list, so I selected libsqlite3.tbd instead (libsqlite3.0.tbd was also listed, but I didn't select it).
However when I build the project I get this output:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_FMDatabase", referenced from:
type metadata accessor for __ObjC.FMDatabase in Database.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I found this QA which isn't of much help ( Undefined symbols for architecture i386 using libsqlite3.dylib with FMDB Xcode 7 ios9 ) because the solutions offered are to either add libsqlite3.dylib (which doesn't exist, I searched in my filesystem), or to add a reference to libsqlite3.tbd which I have done already.
Here's my linker command (formatted for readability):
Ld build/Debug-iphonesimulator/MyApp.app/MyApp normal i386
cd "/Users/me/src-me/MyApp"
export IPHONEOS_DEPLOYMENT_TARGET=9.2
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-arch i386
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk
-L/Users/(me)/src-me/MyApp/build/Debug-iphonesimulator
-F/Users/(me)/src-me/MyApp/build/Debug-iphonesimulator
-filelist /Users/(me)/src-me/MyApp/build/MyApp.build/Debug-iphonesimulator/MyApp.build/Objects-normal/i386/MyApp.LinkFileList
-Xlinker
-rpath
-Xlinker #executable_path/Frameworks
-mios-simulator-version-min=9.2
-Xlinker
-objc_abi_version
-Xlinker 2 -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator
-Xlinker
-add_ast_path
-Xlinker /Users/(me)/src-me/MyApp/build/MyApp.build/Debug-iphonesimulator/MyApp.build/Objects-normal/i386/MyApp.swiftmodule
-lsqlite3
-framework ExternalAccessory
-Xlinker
-dependency_info
-Xlinker /Users/(me)/src-me/MyApp/build/MyApp.build/Debug-iphonesimulator/MyApp.build/Objects-normal/i386/MyApp_dependency_info.dat
-o /Users/(me)/src-me/MyApp/build/Debug-iphonesimulator/MyApp.app/MyApp

Do not link to the .tbd file. Just add -lsqlite3 to the Other Linker Flags build setting.

Related

xcode 7.2 Linker command failed with exit code 1

I am having the devil of a time with an error in XCode 7.2 the full of the build error is as follows..
Ld /Users/skrite/Library/Developer/Xcode/DerivedData/PivoTrac-endythvhjbfwtchiigrtipfugerp/Build/Products/Debug-iphonesimulator/PivoTrac.app/PivoTrac normal x86_64
cd /Users/skrite/XCode-Projects/PivoTrac
export IPHONEOS_DEPLOYMENT_TARGET=9.2
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk -L/Users/skrite/Library/Developer/Xcode/DerivedData/PivoTrac-endythvhjbfwtchiigrtipfugerp/Build/Products/Debug-iphonesimulator -F/Users/skrite/Library/Developer/Xcode/DerivedData/PivoTrac-endythvhjbfwtchiigrtipfugerp/Build/Products/Debug-iphonesimulator -filelist /Users/skrite/Library/Developer/Xcode/DerivedData/PivoTrac-endythvhjbfwtchiigrtipfugerp/Build/Intermediates/PivoTrac.build/Debug-iphonesimulator/PivoTrac.build/Objects-normal/x86_64/PivoTrac.LinkFileList -Xlinker -rpath -Xlinker #executable_path/Frameworks -mios-simulator-version-min=9.2 -Xlinker -objc_abi_version -Xlinker 2 -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -Xlinker -add_ast_path -Xlinker /Users/skrite/Library/Developer/Xcode/DerivedData/PivoTrac-endythvhjbfwtchiigrtipfugerp/Build/Intermediates/PivoTrac.build/Debug-iphonesimulator/PivoTrac.build/Objects-normal/x86_64/PivoTrac.swiftmodule /Users/skrite/Library/Developer/Xcode/DerivedData/PivoTrac-endythvhjbfwtchiigrtipfugerp/Build/Products/Debug-iphonesimulator/Alamofire.framework/Alamofire -Xlinker -dependency_info -Xlinker /Users/skrite/Library/Developer/Xcode/DerivedData/PivoTrac-endythvhjbfwtchiigrtipfugerp/Build/Intermediates/PivoTrac.build/Debug-iphonesimulator/PivoTrac.build/Objects-normal/x86_64/PivoTrac_dependency_info.dat -o /Users/skrite/Library/Developer/Xcode/DerivedData/PivoTrac-endythvhjbfwtchiigrtipfugerp/Build/Products/Debug-iphonesimulator/PivoTrac.app/PivoTrac
ld: framework not found Realm for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
it is strange. I have reset my code from git a few times and there are a couple of times that it has worked (made the arrow go away) but usually not. It may have something to do with ios charts library that went missing.
The last time i got it working again was by removing (deleting) iosCharts from my project navigator, but part of it must still be there or misplaced because i did not get an error about "import Charts" and when i ran the app, it loaded a chart. However, as i am writing new code (only editing one file) the above error shows up again. I have been working on this since early yesterday. Thanks for any tips. I am very new at this.

Swift 2 iOS 9 - ld: warning: directory not found iPhoneSimulator9.0.sdk/Developer/Library/Frameworks

I have a warning in my ios appTests:
Ld /Users/Mazorati/Library/Developer/Xcode/DerivedData/exchangerate-fxnywlxmtfpaccbcpsmygvhirtma/Build/Products/Debug-iphonesimulator/exchangerateTests.xctest/exchangerateTests normal x86_64
cd /Users/Mazorati/Projects/iOS/exchangerate
export IPHONEOS_DEPLOYMENT_TARGET=8.1
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.0.sdk -L/Users/Mazorati/Library/Developer/Xcode/DerivedData/exchangerate-fxnywlxmtfpaccbcpsmygvhirtma/Build/Products/Debug-iphonesimulator -F/Users/Mazorati/Library/Developer/Xcode/DerivedData/exchangerate-fxnywlxmtfpaccbcpsmygvhirtma/Build/Products/Debug-iphonesimulator -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.0.sdk/Developer/Library/Frameworks -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks -filelist /Users/Mazorati/Library/Developer/Xcode/DerivedData/exchangerate-fxnywlxmtfpaccbcpsmygvhirtma/Build/Intermediates/exchangerate.build/Debug-iphonesimulator/exchangerateTests.build/Objects-normal/x86_64/exchangerateTests.LinkFileList -Xlinker -rpath -Xlinker #executable_path/Frameworks -Xlinker -rpath -Xlinker #loader_path/Frameworks -mios-simulator-version-min=8.1 -bundle_loader /Users/Mazorati/Library/Developer/Xcode/DerivedData/exchangerate-fxnywlxmtfpaccbcpsmygvhirtma/Build/Products/Debug-iphonesimulator/exchangerate.app/exchangerate -Xlinker -objc_abi_version -Xlinker 2 -framework XCTest -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -Xlinker -add_ast_path -Xlinker /Users/Mazorati/Library/Developer/Xcode/DerivedData/exchangerate-fxnywlxmtfpaccbcpsmygvhirtma/Build/Intermediates/exchangerate.build/Debug-iphonesimulator/exchangerateTests.build/Objects-normal/x86_64/exchangerateTests.swiftmodule -Xlinker -dependency_info -Xlinker /Users/Mazorati/Library/Developer/Xcode/DerivedData/exchangerate-fxnywlxmtfpaccbcpsmygvhirtma/Build/Intermediates/exchangerate.build/Debug-iphonesimulator/exchangerateTests.build/Objects-normal/x86_64/exchangerateTests_dependency_info.dat -o /Users/Mazorati/Library/Developer/Xcode/DerivedData/exchangerate-fxnywlxmtfpaccbcpsmygvhirtma/Build/Products/Debug-iphonesimulator/exchangerateTests.xctest/exchangerateTests
Error:
ld: warning: directory not found for option '-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.0.sdk/Developer/Library/Frameworks'
Click on your project (targets)
Click on Build Settings
Use the arrows next to your project name (right above the Basic and All buttons) the change to the Tests target
if the warning is ...for option '-L/... thats Library Search Paths, delete the stuff there
if the warning is ...for option '-F/... thats Framework Search Paths, delete the stuff there
Clean
Build
The warning i was getting was this:
ld: warning: directory not found for option '-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/Developer/Library/Frameworks'
My Framework Search Paths were empty so updating/deleting this + Clean + Rebuild did not work for me...
If you are in this situation, try deleting your projects test target.
I got this warning together with 44 errors about about classes not valid for i386. What helped for me was:
product clean
close Xcode
remove all files from ~/Library/Developer/Xcode/DerivedData
I receive this error when opening files from their destination in finder. However, if I open the project from X Code it works fine.
Project 'Test' file delete to solution this app.

Xcode plugin template cocoapods

I want to create Xcode plugin, and I choose Xcode Plugin Template from Alcatraz, then i close project add Podfile open workspace and try to build i get ann error every time:
ld: library not found for -lDTXcodeUtils
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here is a full output:
Ld /Users/jakubmazur/Library/Application\
Support/Developer/Shared/Xcode/Plug-ins/CreateFilesPlugin.xcplugin/Contents/MacOS/CreateFilesPlugin
normal x86_64
cd /Users/jakubmazur/Developer/CreateFilesPlugin
export MACOSX_DEPLOYMENT_TARGET=10.10
/Users/jakubmazur/Desktop/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-arch x86_64 -bundle -isysroot /Users/jakubmazur/Desktop/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk
-L/Users/jakubmazur/Library/Developer/Xcode/DerivedData/CreateFilesPlugin-dmzpluimftctcqhbkndjiknqtjnz/Build/Products/Debug
-F/Users/jakubmazur/Library/Developer/Xcode/DerivedData/CreateFilesPlugin-dmzpluimftctcqhbkndjiknqtjnz/Build/Products/Debug
-filelist /Users/jakubmazur/Library/Developer/Xcode/DerivedData/CreateFilesPlugin-dmzpluimftctcqhbkndjiknqtjnz/Build/Intermediates/CreateFilesPlugin.build/Debug/CreateFilesPlugin.build/Objects-normal/x86_64/CreateFilesPlugin.LinkFileList
-mmacosx-version-min=10.10 -ObjC -lDTXcodeUtils -lXcodeEditor -fobjc-arc -fobjc-link-runtime -framework AppKit -framework Foundation -lPods -Xlinker -dependency_info -Xlinker /Users/jakubmazur/Library/Developer/Xcode/DerivedData/CreateFilesPlugin-dmzpluimftctcqhbkndjiknqtjnz/Build/Intermediates/CreateFilesPlugin.build/Debug/CreateFilesPlugin.build/Objects-normal/x86_64/CreateFilesPlugin_dependency_info.dat
-o /Users/jakubmazur/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins/CreateFilesPlugin.xcplugin/Contents/MacOS/CreateFilesPlugin
ld: library not found for -lDTXcodeUtils clang: error: linker command
failed with exit code 1 (use -v to see invocation)
Any idea what should i set to do this?
Podfile:
source 'https://github.com/CocoaPods/Specs.git'
platform :osx
pod "DTXcodeUtils"
Do the following steps. Its a work around.
Remove all the scheme and add by clicking auto create schemes.(The pods schemes will be checked once its recreated, need it checked for working it).
Then remove the scheme file from copy bundle resources(is it shows an error).
Deep clean and run
Its building without any error for me, Not sure whether it shows any run time errors/ exceptions

Xcode File not found while trying to run app

I'm Getting this error in Xcode then I try to run my app
Ld /Users/danielsorensen/Library/Developer/Xcode/DerivedData/Keyboard-cimemloksqjdnxhkdziqxwhxgwcg/Build/Products/Debug-iphonesimulator/KeyboardTests.xctest/KeyboardTests normal x86_64
cd "/Users/danielsorensen/Downloads/codecanyon-9105493-color-keyboard-universal/Color Custom Keyboard"
export IPHONEOS_DEPLOYMENT_TARGET=8.0
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk -L/Users/danielsorensen/Library/Developer/Xcode/DerivedData/Keyboard-cimemloksqjdnxhkdziqxwhxgwcg/Build/Products/Debug-iphonesimulator -F/Users/danielsorensen/Library/Developer/Xcode/DerivedData/Keyboard-cimemloksqjdnxhkdziqxwhxgwcg/Build/Products/Debug-iphonesimulator -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk/Developer/Library/Frameworks -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.0.sdk/Developer/Library/Frameworks -filelist /Users/danielsorensen/Library/Developer/Xcode/DerivedData/Keyboard-cimemloksqjdnxhkdziqxwhxgwcg/Build/Intermediates/Keyboard.build/Debug-iphonesimulator/KeyboardTests.build/Objects-normal/x86_64/KeyboardTests.LinkFileList -Xlinker -rpath -Xlinker #executable_path/Frameworks -Xlinker -rpath -Xlinker #loader_path/Frameworks -bundle_loader /Users/danielsorensen/Library/Developer/Xcode/DerivedData/Keyboard-cimemloksqjdnxhkdziqxwhxgwcg/Build/Products/Debug-iphonesimulator/Color\ Custom\ Keyboard.app/Color\ Custom\ Keyboard -Xlinker -objc_abi_version -Xlinker 2 -framework XCTest -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -Xlinker -add_ast_path -Xlinker /Users/danielsorensen/Library/Developer/Xcode/DerivedData/Keyboard-cimemloksqjdnxhkdziqxwhxgwcg/Build/Intermediates/Keyboard.build/Debug-iphonesimulator/KeyboardTests.build/Objects-normal/x86_64/KeyboardTests.swiftmodule -mios-simulator-version-min=8.0 -Xlinker -dependency_info -Xlinker /Users/danielsorensen/Library/Developer/Xcode/DerivedData/Keyboard-cimemloksqjdnxhkdziqxwhxgwcg/Build/Intermediates/Keyboard.build/Debug-iphonesimulator/KeyboardTests.build/Objects-normal/x86_64/KeyboardTests_dependency_info.dat -o /Users/danielsorensen/Library/Developer/Xcode/DerivedData/Keyboard-cimemloksqjdnxhkdziqxwhxgwcg/Build/Products/Debug-iphonesimulator/KeyboardTests.xctest/KeyboardTests
ld: file not found: /Users/danielsorensen/Library/Developer/Xcode/DerivedData/Keyboard-cimemloksqjdnxhkdziqxwhxgwcg/Build/Products/Debug-iphonesimulator/Color Custom Keyboard.app/Color Custom Keyboard
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I got the same error and I solved it by following these steps:
1) Go to the project
2) On the left side bar (in the screen that appears click on Tests
3) Go to the build settings tab and look for "test host"
4) Now the path that appears in the field is probably wrong so you just need to update it to the appropriate one (In my particular case I renamed the project and some folders and so some paths were wrong)
If you still see the error then you might need to fix some other paths in the Build settings tabs.
Go to Project -- > Build Settings --> Testing --> Test Host
Remove the paths from Debug and Release and give the correct path.
If you don't know the correct path just keep it empty and then clean it and build.
This works fine for me.
I got this fixed by selecting the Tests target and searching for Bundle Loader in Build Settings and changing the product name in that path. I got this error because I have changed the Product name. The Bundle loader has the old product name in the path, so it searches for that path.
Go to project name that given on top. Click on it. Go to "New Scheme" and change the Name to whatever you want.

Xcode 5 bot fails to build -- framework not found by ld

I am trying to set up my first Bot for CI. This bot successfully downloads source tree from git but fails to build application (IOS7, simulator mode) which I can build and run without any problems with regular Xcode 5.0.1 environment.
Particularly Bot fails on ld stage (see excerpt below). As I can suggest from the log file, ld cannot find QuartzCore framework, where CA.. functions are defined.
Compiler found all header files from framework, so, for the first glance path are configured OK, but ld cannot find library itself to link...
I suspect this is a trivial error with permissions or environment settings. Could you please point me where to dig?
Thanks in advance.
Regards,
Vladimir
+++ +++ +++
"/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk -L/Library/Server/Xcode/Data/BotRuns/Cache/c5e74f8f-f2c8-f2c8-9bba-cc3ce564b8fb/DerivedData/Build/Products/Debug-iphonesimulator -F/Library/Server/Xcode/Data/BotRuns/Cache/c5e74f8f-f2c8-f2c8-9bba-cc3ce564b8fb/DerivedData/Build/Products/Debug-iphonesimulator -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/Developer/Library/Frameworks -F/Applications/Xcode.app/Contents/Developer/Library/Frameworks -filelist /Library/Server/Xcode/Data/BotRuns/Cache/c5e74f8f-f2c8-f2c8-9bba-cc3ce564b8fb/DerivedData/Build/Intermediates/SBK.build/Debug-iphonesimulator/SBKTests.build/Objects-normal/i386/SBKTests.LinkFileList -bundle_loader /Library/Server/Xcode/Data/BotRuns/Cache/c5e74f8f-f2c8-f2c8-9bba-cc3ce564b8fb/DerivedData/Build/Products/Debug-iphonesimulator/SBK.app/SBK -Xlinker -objc_abi_version -Xlinker 2 -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=6.1 -framework CoreText -framework SenTestingKit -framework UIKit -framework Foundation -framework CoreData -Xlinker -dependency_info -Xlinker /Library/Server/Xcode/Data/BotRuns/Cache/c5e74f8f-f2c8-f2c8-9bba-cc3ce564b8fb/DerivedData/Build/Intermediates/SBK.build/Debug-iphonesimulator/SBKTests.build/Objects-normal/i386/SBKTests_dependency_info.dat -o /Library/Server/Xcode/Data/BotRuns/Cache/c5e74f8f-f2c8-f2c8-9bba-cc3ce564b8fb/DerivedData/Build/Products/Debug-iphonesimulator/SBKTests.octest/SBKTests Undefined symbols for architecture i386:
"_CATransform3DMakeScale", referenced from: -[MBSwitch showFillLayer:animated:] in MBSwitch.o
"_CGAffineTransformIdentity", referenced from: -[TTTAttributedLabel drawTextInRect:] in TTTAttributedLabel.o
"_CGContextAddLineToPoint", referenced from: -[TTTAttributedLabel drawStrike:inRect:context:] in TTTAttributedLabel.o
"_CGContextAddPath", referenced from:
. . . . [skip ] . . . .
ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)
** TEST FAILED **
The following build commands failed:
Ld /Library/Server/Xcode/Data/BotRuns/Cache/c5e74f8f-f2c8-f2c8-9bba-cc3ce564b8fb/DerivedData/Build/Products/Debug-iphonesimulator/SBKTests.octest/SBKTests normal i386 (1 failure)
+++ +++ +++
Solved!
It was really trivial issue.
Xcode bot tries to build all targets included into schema. In my case this is project itself and unit tests target. As tests was not developed yet, this target was not compiled. But bot tries to compile it... So all frameworks, linked to the "main target" should be linked to the test target as well.

Resources