I'm having some issues when compiling my app to iOS. I'm using sqlite3 and imported as
将我的应用程序编译到iOS时遇到一些问题。我正在使用sqlite3并导入为
#import <sqlite3.h>
Well, I only found a file named libsqlite3.0.dylib in my Mac and I copied it to my project. When I compile it for iOS Simulator, it works just fine. However, when I try to compile the app for iOS Device, it throws an error (Apple Match-O Linker Error) in every call I do in my implementation to sqlite's function (such as _sqlite3_open, etc.)
好吧,我只在我的Mac上找到了一个名为libsqlite3.0.dylib的文件,并将其复制到我的项目中。当我为iOS模拟器编译它时,它工作得很好。但是,当我尝试为iOS设备编译应用程序时,它会在我执行的每个调用中抛出一个错误(Apple Match-O链接器错误)到sqlite的函数(例如_sqlite3_open等)
How can I compile it to iOS Device?
如何将其编译到iOS设备?
Thank you!
4 个解决方案
#1
58
Instead of simply copying the library, do it like this:
而不是简单地复制库,这样做:
-
in Xcode Navigator, click on your target (the upmost entry)
在Xcode Navigator中,单击您的目标(最上面的条目)
-
go to
Build Phases
, thenLink Binary With Libraries
转到Build Phases,然后将Binary与Libraries链接起来
-
add the libsqlite3.dylib from it's location at
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOSxx.sdk/usr/lib/
从它位于/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOSxx.sdk/usr/lib/的位置添加libsqlite3.dylib
#2
1
Just in case someone faced that same problem as me. If you are unit testing your code, add the lib file also to your test target.
以防有人遇到与我相同的问题。如果您要对代码进行单元测试,请将lib文件也添加到测试目标中。
#3
0
Did you try to import sqlite3 library like:
您是否尝试导入sqlite3库,如:
#import "sqlite3.h"
instead of:
#import <sqlite3.h>
#4
-1
The best way that I have found to use SQLite in your IOS application is to build your own copy of the SQLit library and include it in your project. libsqlite3.0.dylib is a very old copy of SQLite.
我在IOS应用程序中使用SQLite的最佳方法是构建自己的SQLit库副本并将其包含在项目中。 libsqlite3.0.dylib是一个非常古老的SQLite副本。
You can easily download the SQLite Amalgamation source code and build it for IOS. this gives you the latest SQLite source code that has all the latest bug fixes and improvements.
您可以轻松下载SQLite Amalgamation源代码并为IOS构建它。这将为您提供最新的SQLite源代码,其中包含所有最新的错误修复和改进。
If you can open Xcode and create a new static library project, then you are 75% of the way there.
如果你可以打开Xcode并创建一个新的静态库项目,那么你就是75%的方式。
Once you have the static library project, include the SQLite sources that you downloaded from the SQLite Amalgamation and set a few Preprocessor options and your off and running with the latest code.
获得静态库项目后,请包含从SQLite Amalgamation下载的SQLite源,并设置一些预处理器选项,然后关闭并运行最新代码。
For complete details and sample source code you can visit my blog conedogers
有关完整的详细信息和示例源代码,您可以访问我的博客conedogers
#1
58
Instead of simply copying the library, do it like this:
而不是简单地复制库,这样做:
-
in Xcode Navigator, click on your target (the upmost entry)
在Xcode Navigator中,单击您的目标(最上面的条目)
-
go to
Build Phases
, thenLink Binary With Libraries
转到Build Phases,然后将Binary与Libraries链接起来
-
add the libsqlite3.dylib from it's location at
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOSxx.sdk/usr/lib/
从它位于/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOSxx.sdk/usr/lib/的位置添加libsqlite3.dylib
#2
1
Just in case someone faced that same problem as me. If you are unit testing your code, add the lib file also to your test target.
以防有人遇到与我相同的问题。如果您要对代码进行单元测试,请将lib文件也添加到测试目标中。
#3
0
Did you try to import sqlite3 library like:
您是否尝试导入sqlite3库,如:
#import "sqlite3.h"
instead of:
#import <sqlite3.h>
#4
-1
The best way that I have found to use SQLite in your IOS application is to build your own copy of the SQLit library and include it in your project. libsqlite3.0.dylib is a very old copy of SQLite.
我在IOS应用程序中使用SQLite的最佳方法是构建自己的SQLit库副本并将其包含在项目中。 libsqlite3.0.dylib是一个非常古老的SQLite副本。
You can easily download the SQLite Amalgamation source code and build it for IOS. this gives you the latest SQLite source code that has all the latest bug fixes and improvements.
您可以轻松下载SQLite Amalgamation源代码并为IOS构建它。这将为您提供最新的SQLite源代码,其中包含所有最新的错误修复和改进。
If you can open Xcode and create a new static library project, then you are 75% of the way there.
如果你可以打开Xcode并创建一个新的静态库项目,那么你就是75%的方式。
Once you have the static library project, include the SQLite sources that you downloaded from the SQLite Amalgamation and set a few Preprocessor options and your off and running with the latest code.
获得静态库项目后,请包含从SQLite Amalgamation下载的SQLite源,并设置一些预处理器选项,然后关闭并运行最新代码。
For complete details and sample source code you can visit my blog conedogers
有关完整的详细信息和示例源代码,您可以访问我的博客conedogers