sqlite3 fails to read database for me, but not for same commit on another machine - iphone

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:
Copy the database into the user's document directory so that it is writeable. (working OK)
Open the database using FMDB's databaseWithPath: followed by open.
Calling goodConnection on FMDB at this point returns YES - the database is indeed open and working.
Calling 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?

Had the same issue with our custom compiled SQLite3. I found a solution to this problem on this blog http://regularrateandrhythm.com/regular-rate-rhythm-blog/sqlite3-fts-in-IOS4.html

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 :)

Related

Unable to run app in Simulator Xcode 6

Yesterday i was testing my app in the iOS simulator and everything was working fine. I then decided to run the app on my iPhone and i got the error unable to install application, Unknown error occurred this has happened before so I cleaned my build folder (as this has fixed this issue before) however, the same error occurred. I then ran the app in the iOS simulator again and now i get the error Unable to run app in Simulator, An error was encountered while running (Domain = LaunchServicesError, Code = 0). I find this very weird as i didn't change anything besides trying to run the app on my iPhone. I have tried every solution given on this post and still no luck.
I'm sorry if my question doesn't contain much detail but as I said I didn't change anything and it was building and running fine a minute before plugging in my iPhone and trying to run it on there.
Any help would be much appreciated.
edit
I tried running other projects (with and without extensions) and they are working on both simulator and iPhone, therefore the problem must be within my project. (my project does have a today extension)
In that kind of cases I usually :
Product > Clean
Close xCode
Delete the Derived Data (in ~/Library/Developer/Xcode/DerivedData subfolders)
Delete the app on the iPhone
Reboot the iPhone
Restart and rebuild
I had this problem. In my case, it was caused by the Build value being blank. After putting a value there, and resetting the simulator once more, the issue went away.
I had the same problem and checking the system log carefully helped me to identify a coliding library that was causing this error. You can also check this answer if you are using extensions.
Generally it means there is a problem with the build, it may be due to old cache (solved by a clean build) or a project definition error (missing library, bad definition in info.plist, etc).
In my case it happened only on iOS 8, turns out that my widget had the wrong bundle ID.

Guard Malloc doesn't work

I'm experimenting with different profiling options that Xcode provides, but when I enabling Guard Malloc option in Diagnostics tab and trying to run, I'm getting this error with immediate crash:
dyld: could not load inserted library: /usr/lib/libgmalloc.dylib
And it is right, /usr/lib/ doesn't contain this library. I've located it in:
Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/lib/
So I've created link, and started Command Line Tool (just to be sure, because it apparently part of MacOS SDK), enabled Guard Malloc again but the problem remains.
I don't quite get where is a problem: does it new Xcode 4.3 inadvertence, problem with my system or planned decision by Apple to replace it with something else (maybe Instruments)?
on device or simulator?
According to http://developer.apple.com/library/ios/#DOCUMENTATION/Performance/Conceptual/ManagingMemory/Articles/MallocDebug.html
You can use this option both Mac apps and also for iPhone applications running in the simulator.
Well, I got stuck by this too. From an apple list:
http://prod.lists.apple.com/archives/xcode-users/2012/Feb/msg00197.html
That's a known issue that's being investigated. I think that you may be able to work around it by installing the 10.7.3 combo installer
Which means you need to download the combo installer from: http://support.apple.com/kb/DL1484?
I'm trying it now to make sure it works, but the person on the mailing list said it worked.
Problem came up again recently, combo update didn't helped (libgmalloc.dylib was in place).
New solution was to Repair Disk Permissions in Disk Utility:
It looks like you can't enable Guard Malloc when debugging directly on a device (at least iPad in my case), even when running the latest and greatest versions of everything. Running still works in the simulator though.

XCode error "The application bundle does not contain a valid identifier."

Recently, after upgrading to Lion and Xcode 4.2.1 I am getting this error when trying to run my app on my iPhone 4S:
"The application bundle does not contain a valid identifier."
My identifier is indeed valid, and I have been able to run my app with this identifier earlier.
The problem might appear when I change computers.
I have two computers that I am using to code my app, and I am using Dropbox to keep track of my files.
Restarting XCode, my mac and my iPhone does not work.
Cleaning the target and rebuilding does not work.
The only thing I have been able to do to fix it is to create a completely new project and moving my files. This made things work until I swapped computer. Now I am in the same trouble again.
Any idea? Anyone?
Three suggestions:
Check that your developer key is in both computers
Did you try to update the project? There is a strangly-named key in the middle bottom under the project's properties. Try this.
I had similar issues. I found that some things weren't updated when I updated osx and xcode. To get out of the situation, I would suggest creating a new project and copy paste code, files and build settings. This might seem stupid, but you know apple is not good at creating IDE's. You might just get your self lost in the undocumented settings.

putpkt: Error and testing Core-Data Lightweight migration

I have an xcode project that has 4 targets (2 apps, 1 iPhone and 1 iPad version for each). I have recently implemented Core Data Lightweight Migration.
I am currently only testing two of the apps, the iPhone versions, call them App A and App B. I am able to run the current app store version of App A on my iPhone, then install my new version of App A to test the Lightweight Migration. It works fine, no problem.
Then, I try the same thing with App B. I am able to install the current app store version of App B on my iPhone no problem. BUT, when I try in install the new version of app B on my iPhone, I get the following error (or a variant of it) EVERY time: "putpkt: write failed, broken pipe"
I am confused since the two current versions are in the same project and have the exact same settings for every configuration (debug, release, distribution). The is not ad-hoc distribution.
Every post I have read for this error on this forum, and anywhere, suggests things like removing the app, restarting the device, restarting xcode, etc. And sure, I can get it to work that way. BUT I cannot test my migration that way.. If I remove the old version of the app from the device nothing is getting migrated!
I am pulling my hair out over this. The two apps were originally in two different projects, and I added App B to the App A project as a new target - that is the only thing I can think of, as I feel like I have looked at everything. I would really appreciate some help to figure out this problem. I feel sick about sending out a database update that I cannot test - I can't take the chance of corrupting people's data, especially when I have not offered a backup option until this current version. Ugh.
EDIT: when I try to run App B on the device without updating, I often get the following error:
Error Starting Executable... Don't know how to run. Try "help target".
EDIT: I think I am having this trouble because I renamed the product name for app B. I think this changed the bundle and will not allow me to migrate data. I will try to change it back and post an update. It seems like merge bundles IS working well for app A in the meantime.
Making sure the new project and the original project had the same product name and the same data model name fixed this problem for me.

Why does Xcode keep changing its active executable?

Something really weird is going on with Xcode and an iPhone project I'm working on, when I'm building for the simulator, the project has 2 active executables (MyApp - iPhone Simulator (2.0) and MyApp - iPhone Simulator (2.1)) Almost all of the time, I want to use the the 2.1 active executable, but Xcode will occasionally silently change to the 2.0 one.
There doesn't seem to be any pattern to this or any trigger that I can notice. Googling has found a couple of people out there who are having the same problem, but no solutions.
Help me stackoverflow-kenobi! You're my only hope!
Ok, it was a bug. The good news: it's fixed in the fresh new 2.2 SDK.
That is weird -- I've been doing iPhone/XCode development for a while, now, and never seen anything like that.
Are you absolutely certain that you're not poking around some place that's causing the change?
Might you have a corrupt XCode or .xcodeproj? If it persists, I'd try re-creating my project and, if that didn't help, reinstalling XCode.
Very strange, indeed...!
I have the same problem. I need to set the active Executable to 2.1 for openAL to work. The pattern I observed is that it switches back everytime I switch to export to the device. Isn't that what happens with you?
I've seen the issue commented a couple of times on the official iphone dev forum, but no solutions. Looks like a bug.
So.. why are you actually doing that? It is probably better, given the nature of the iPhone (with multiple frameworks for multiple architectures), to set up different Targets for your various projects. The executable produced will be the result of the build phases for your targets.