jeudi 25 février 2016

Linking to Sqlite in Xcode 7

I'm following this tutorial here: http://ift.tt/1JK1SAB - 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/http://ift.tt/1M9mvtN"
/Applications/http://ift.tt/1jmLxI7
-arch i386
-isysroot /Applications/http://ift.tt/1P1Ibv2
-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/http://ift.tt/107CuVI
 -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

Aucun commentaire:

Enregistrer un commentaire