带有 SQLITE FTS3 Xcode 版本的 iPhone 应用程序无法正常工作
我的 iPhone 应用程序使用 SQLITE 的 FTS3 函数(特别是 MATCH 和 OFFSET)。这些对于我的优化搜索算法至关重要。我通过在项目中的一个名为 SQLite 的组下包含三个 SQLITE 源文件(即 sqlite3.c、sqlite3.h 和 sqlite3ext.h)来实现 FTS3。我从框架组中删除了之前对 libsqlite3.dylib 库的引用。我将“其他 C 标志”和“其他 C++ 标志”项目设置设置为 -DSQLITE_ENABLE_FTS3=1。 (我还尝试简单地将这些标志设置为 -DSQLITE_ENABLE_FTS3。)
该应用程序在调试和发布版本的模拟器中都表现良好。该应用程序在 iPhone 上也能完美运行,但仅限于调试版本!
发布版本不会为任何使用 MATCH 和 OFFSET 关键字的 SQL 调用返回结果行。我的具体问题是,“当我在连接 iPhone 的情况下构建发布版本时,我的启用 FTS3 的 SQLITE 版本是否未与我的应用程序一起安装?”我在 Mac 上相应的 Release-iphoneos 子文件夹中看到 sqlite.o 对象文件。它比 Debug-iphoneos 子文件夹中的小一点,但我得出的结论是,这是由于缺少调试符号造成的。
我迫切需要一个解决方案,因此任何想法都将不胜感激。
My iPhone application uses SQLITE's FTS3 functions (specifically MATCH and OFFSET). These are essential to my optimized searching algorithm. I implemented FTS3 by including three SQLITE source files, namely sqlite3.c, sqlite3.h and sqlite3ext.h in my project, under a group named SQLite. I removed from the Frameworks group my previous reference to the libsqlite3.dylib library. I set the "Other C Flags" and "Other C++ Flags" project settings to -DSQLITE_ENABLE_FTS3=1. (I also tried simply setting those flags to -DSQLITE_ENABLE_FTS3.)
The application performs perfectly in the Simulator for both debug and release builds. The application also performs perfectly on the iPhone, BUT only for the debug build!
The release build does not return result rows for any SQL calls using the MATCH and OFFSET keywords. My specific question is, "When I build the release version with my iPhone connected, is my FTS3 enabled version of SQLITE not being installing along with my app?" I see the sqlite.o object file in the appropriate Release-iphoneos subfolder on my Mac. It is a bit smaller than the one in the Debug-iphoneos subfolder, but I concluded this is due to a lack of debug symbols.
I am desperate for a solution, so any ideas at all will be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
好吧,对于那些可能从我的古怪经历中受益的人来说,这就是解决方案。经过一番折腾后,我决定放松发布版本中的一些优化。我这样做只是为了获得有关问题的另一条线索,而不是作为解决方案。果然,代码完美运行!然后,我说“好吧,让我把优化放回最小和最快,继续我的调查。”神奇的是,一切仍然有效!总而言之,我所做的唯一一件事就是更改项目设置中的优化,然后将其放回去!当然,所有这一切都是经过大量调试、清理所有目标后重新编译等之后的。直到我更改并将优化重置为原始值之前,一切都没有产生任何影响。疯狂,但这就是我的故事,我会坚持下去。希望这可以帮助遇到此问题的其他人。
OK, for those who may benefit from my quirky experience, here was the solution. After much hair pulling I decided to relax some of the optimization in the Release version. I did this just to get another clue as to the problem - not as a solution. Sure enough, the code worked perfectly! Then, I said "OK, let me put the optimization back to smallest and fastest to continue my investigation." Magically, everything still worked!!! In summary, the only thing that I did was to change the optimization in the the Project settings, and then put it back! All of this, of course, was after a lot of debugging, recompiling after cleaning all targets, etc. NOTHING had made a difference until I changed and reset the optimization to the original value. Crazy, but that is my story and I'm sticking to it. Hope this helps someone else experiencing this problem.
请注意,如果您只使用 fts3,则可以使用 SDK 附带的普通 sqlite3 库。如果执行以下命令:
它将告诉您Apple在编译默认库时使用了哪些编译选项。当我运行此命令时,我看到:
SQLite version = 3.7.2
[DATABASE] 编译选项:
ENABLE_FTS3
ENABLE_FTS3_PARENTHESIS
ENABLE_LOCKING_STYLE=1
ENABLE_RTREE
OMIT_BUILTIN_TEST
OMIT_LOAD_EXTENSION
TEMP_STORE=1
THREADSAFE=2
这是针对 iOS 4.3.5 进行编译的。我可以确认 fts3 虚拟表和 MATCH 关键字在我的构建中正常工作。
Just a note that if you are only using fts3 you can just use the normal sqlite3 library that comes with the SDK. If you execute the following:
It will tell you what compile options Apple used when compiling the default library. When I run this I see:
SQLite version = 3.7.2
[DATABASE] Compile options:
ENABLE_FTS3
ENABLE_FTS3_PARENTHESIS
ENABLE_LOCKING_STYLE=1
ENABLE_RTREE
OMIT_BUILTIN_TEST
OMIT_LOAD_EXTENSION
TEMP_STORE=1
THREADSAFE=2
This is compiling against iOS 4.3.5. I can confirm that fts3 virtual tables and the MATCH keyword are working in my build.
我要做的第一件事是对 iPhone 发布版本进行干净的构建,并详细查看原始构建日志。您可以查看那里执行的实际命令,以查看这些额外的编译器/预处理器标志是否实际配置为用于该目标。
如果不是,那么您可能在目标设置中犯了错误。
The first thing I would do is make a clean build of the iPhone release build and look in detail at the raw build log. You can look at the actual commands executed there to see if those extra compiler/preprocessor flags are actually configured to be used for that target.
If they are not then you probably made a mistake in the Target settings.
tldr;
Swift 4.0.3
< strong>输出
参考
tldr;
Swift 4.0.3
Output
Reference