开发者

My App crashes when launched on my Iphone

I have a problem here : my app crashed on my Iphone (JB) though Xcode doesn't complain about anything. The app works fine on the simulator though.

However, there is this in the device logs :

Thread 0 Crashed:
0   libSystem.B.dylib              0x00078ac8 __kill + 8
1   libSystem.B.dylib              0x00078ab8 kill + 4
2   libSystem.B.dylib              0x00078aaa raise + 10
3   libSystem.B.dylib              0x0008d03a abort + 50
4   libstdc++.6.dylib              0x00044a20 __gnu_cxx::__verbose_terminate_handler() + 376
5   libobjc.A.dylib                0x00005958 _objc_terminate + 104
6   libstdc++.6.dylib              0x00042df2 __cxxabiv1::__terminate(void (*)()) + 46
7   libstdc++.6.dylib              0x00042e46 std::terminate() + 10
8   libstdc++.6.dylib              0x00042f16 __cxa_throw + 78
9   libobjc.A.dylib                0x00004838 objc_exception_throw + 64
10  CoreFoundation                 0x0009fd0e +开发者_开发问答[NSException raise:format:arguments:] + 62
11  CoreFoundation                 0x0009fd48 +[NSException raise:format:] + 28
12  Foundation                     0x000125d8 -[NSURL(NSURL) initFileURLWithPath:] + 64
13  Foundation                     0x000371e0 +[NSURL(NSURL) fileURLWithPath:] + 24

Any idea what the problem can be ? I've already spent my whole day on that, but... I'm stuck.

Thanks in advance...

Miky Mike

Ok, Here is more then from the console, I get this :

This GDB was configured as "--host=i386-apple-darwin --target=arm-apple-darwin".tty /dev/ttys002 Loading program into debugger… Program loaded. target remote-mobile /tmp/.XcodeGDBRemote-17280-65 Switching to remote-macosx protocol mem 0x1000 0x3fffffff cache mem 0x40000000 0xffffffff none mem 0x00000000 0x0fff none run Running… Error launching remote program: failed to get the task for process 456. Error launching remote program: failed to get the task for process 456. The program being debugged is not being run. The program being debugged is not being run.

[Session started at 2010-12-23 20:33:33 +0100.] GNU gdb 6.3.50-20050815 (Apple version gdb-1472) (Thu Aug 5 05:54:10 UTC 2010) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "--host=i386-apple-darwin --target=arm-apple-darwin".tty /dev/ttys004 Loading program into debugger… Program loaded. target remote-mobile /tmp/.XcodeGDBRemote-17280-72 Switching to remote-macosx protocol mem 0x1000 0x3fffffff cache mem 0x40000000 0xffffffff none mem 0x00000000 0x0fff none run Running… Error launching remote program: failed to get the task for process 508. Error launching remote program: failed to get the task for process 508. The program being debugged is not being run. The program being debugged is not being run.

Here is the code that calls the URL

NSURL *storeURL = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"TheLearningMachine.sqlite"]];

I hope this will better for you to read.


Something in your code is calling [NSURL fileURLWithPath:] with a bad URL on the device. This URL is likely bad because you're referencing a hard-coded path on the device.

Check how you're constructing the URL - the simulator is more tolerant of issues here.

Are you trying to invoke something like mailto: or callto: ?

It could also be side-effects of a different problem, such as this Japanese post that is calling init without having called alloc first - seems to have the same callstack as you.


Ok guys, thanks for your support and suggestions, Graham Parks was right. I've had a hard time though because I had no means of using the debugger with the Iphone. (Maybe because it's jailbroken). It's still not working by the way but at least, my app is now.

I don't know if you guys can remember the first time you saw your first app appearing on the screen of your Iphone... Waouh, I almost cried, all the more since I had just paid the 79 euros to Apple to find my app would not install on a JB Iphone.

This is my Christmas gift I guess.

As regards the bug here, the thing is I had mad a mistake in defining my URL.

NSString *modelPath = [[NSBundle mainBundle] pathForResource:@"TheLearningMachine" ofType:@"momd"];

The problem was "momd", (mom is much better) and is much more cooperative with my Iphone too ;-)

So thanks to all of you for helping.... And merry Christmas by the way !

Miky Mike


Somewhere in your app's startup code you're making a call to [NSURL fileURLWithPath:], and it's raising an exception. You need to check what string is being passed to it, perhaps with an NSLog() call.

(My wild guess is the value being passed to it is nil, because whatever code generates that path is failing for some reason. It's hard to say without seeing the actual code)


Check your console. An uncaught exception was thrown; details of that exception will be printed out in Xcode's console.


Based on your code, this line is the problem:

NSURL *storeURL = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"TheLearningMachine.sqlite"]];

Try replacing it with this:

NSString *appDirectory = [self applicationDocumentsDirectory];
NSLog(@"appDirectory: %@",appDirectory);
NSString *finalPath = [appDirectory stringByAppendingPathComponent: @"TheLearningMachine.sqlite"];
NSLog(@"finalPath: %@",appDirectory);
NSURL *storeURL = [NSURL fileURLWithPath: finalPath];
NSLog(@"storeURL: %@",storeURL);

One of the lines above should produce a nil, or at least some kind of a strange value when it outputs it into the console.


Forgive me, but I can't find any -(NSString*) applicationDocumentsDirectory method or property defined in iOS. Are you defining this yourself, or am I being a doorknob?


I just ran into this myself and what I found that worked was to click on your file in the left hand pane to open it in the file inspector, then make sure your "Target Membership" (found on the right hand side of the Xcode Pane) has your main project checked. Without that your file path won't be correct and you'll get a crash.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜