0

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
Community
  • 1
  • 1
Dai
  • 141,631
  • 28
  • 261
  • 374
  • The undefined symbols "_OBJC_CLASS_$_FMDatabase" indicates that the problem is *not* with linking to libsqlite, but with adding the FMDB files. Have you double-checked that all .m files have the "Target Membership" checkbox switched on? – Martin R Feb 26 '16 at 05:50

1 Answers1

0

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

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • Is there a special reason not to link to the .tbd file? I had no problem with that so far. And as you can see from the linker output, it has `-lsqlite3`. – Martin R Feb 26 '16 at 05:51