BACKGROUND
We have an iPhone app that uses sqlite
for a large database. We use FTS3
, full text search, so we have to "roll our own" sqlite instead of using the library included in the iOS SDK. We use the amalgamated sqlite.c file, and we use FMDB
as an Obj-C wrapper.
THE PROBLEM
My project compiles, but it crashes on an exception that I've installed to detect if the database is malfunctioning (more on that in a bit). My partner, however, is merrily coding away, with no problems - on the EXACT SAME commit revision as me. That's what's weird.
Specifically, the app does the following on first load:
databaseWithPath:
followed by open
.goodConnection
on FMDB at this point returns YES
- the database is indeed open and working.SELECT * FROM sqlite_master WHERE type = 'table'
returns no records. (there should be many tables)WHAT I'VE TRIED
Now, if you ask sqlite to "open" a database that doesn't exist -- it'll just create one. That's what this behavior looks like. So, I opened up a Terminal window, navigated to my app's Documents directory on the simulator, and typed:
Makbook:Documents makdad$ sqlite3 myDB.db
Which runs sqlite3, and, of course, everything looks fine. All my data is there.
I stepped through line-by-line of FMDB's open method to make sure I was opening the right database. It looks like I certainly am.
First thing I tried was downgrading to Xcode 3.2.6. Same problem, so I think I've ruled out an Xcode 3/4 difference in compiling (although I suspected that at first).
Does anyone have any debugging-fu to try, or any knowledge as to what my problem could be?
The problem is with the iOS 4.3 SDK Simulator. I had neglected to test the iOS device itself, and it works.
To support older iOS versions, we use the -weak_library /usr/lib/libSystem.B.dylib linker flag. Removing that flag on iOS Simulator 4.3 stops ALL the weird behavior relating to sqlite3.
The reason my partners weren't having the problem is that they are running Xcode 3.2.5, which is 4.2. Even when I downgraded to Xcode 3, I still had 4 installed - so 3 was using the 4.3 SDK as well.
I am going to open a new question about the new issue, as this question is so far off the actual issue :)