1

In my project, i have imported some third party frameworks like google-maps. EveryThing work fine when compiling, but when it runs, the app crashes and i could track the suspicious method:

//Invoked when the class is instantiated in XIB
-(id)initWithCoder:(NSCoder*)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if(self)
    {
        [self customInitialization];
    }
    return self;
}

Here is the stack of the crash i got:

TestMapDirections[1343:11603] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
*** First throw call stack:
(0x13ea052 0x2035d0a 0x1392a78 0x13929e9 0xae854b 0xae84d5 0x23e3f 0x23d17 0x223b0 0x2230b 0x29e5 0x2ae6 0x3d3335 0x4d1fa2 0x4d16b7 0x3d2ead 0x4d1fa2 0x4d19af 0x4d16b7 0x3d2305 0x5d884f 0x5d8dd7 0x13ebec9 0x1b75c2 0x1b755a 0x25cb76 0x25d03f 0x25c2fe 0x1dca30 0x1dcc56 0x1c3384 0x1b6aa9 0x1601fa9 0x13be1c5 0x1323022 0x132190a 0x1320db4 0x1320ccb 0x1600879 0x160093e 0x1b4a9b 0x2478 0x23d5)
terminate called throwing an exceptionsharedlibrary apply-load-rules all
Current language:  auto; currently objective-c

You can download my application and try it on your stuff, maybe you can help me more figure out the problem, thanx in advance.

EDIT: @JSON coco: here is the code of the customInitialization method:

-(void)customInitialization
{
    // do the initialization of class variables here..

    mDirections          = [UICGDirections sharedDirections];
    mDirections.delegate = self;
}
4
  • What is the code in the far more suspicious -customInitialization method? Commented Jan 12, 2012 at 15:54
  • Hi @Jason: i have edited my post, also, please try to download and run my sample, it a light application, may be you'll understand more better my problem :) Commented Jan 12, 2012 at 15:57
  • 1
    Well, the problem is that something is trying to initialize a URL with a nil path. So perhaps the class that this inherits from? Keep checking up the class hierarchy each class's -initWithCoder: method and find the one that is unpacking the URL from the coder and trying to initialize an ivar. Change that so you check that the URL you decoded was not nil before you attempt to call that method. Commented Jan 12, 2012 at 16:01
  • This class inherits from the UIViewController class, it's a view controller, please if you don't mind, download my sample and tell me which class should i fix in it the -initWithCoder issues and make your suggestion as an answer :) Commented Jan 12, 2012 at 16:05

1 Answer 1

2

So, I looked over your code. It's actually the Google Map API that's crashing. It expects to find some file called api.html. I'm not familiar with this framework the you're using, so I can't tell you what that html file is used for or where to get it. However, you need to find it and add it to your project file and make sure it gets into your Copy Resources build phase. To do that, just look in the File Utility Inspector on the right side of your editor (if it's not opened, you can open it by pressing CMD+ALT+1). After you add the api.html file to your project, select it, and check to make sure it's checked for your target in the file inspector.

This will cause the crash to stop. If that file isn't actually needed, you can alter the line 39 of the file UICGoogleMapsAPI.m. That's the line that's crashing since it can't file the api.html file.

Sign up to request clarification or add additional context in comments.

3 Comments

Ok friend, i will look for that file. Just let's keep in touch :)
Hi again, that's it, the api.html was missing. By the way, can you please tell me how could you know that the specified file named api.html was missing, i mean may be a tip that can help me save a lot of time on eventual issues in the future. Thanx a lot for your continuous help :)
@Malek The cause of the crash was the exception being thrown for passing an invalid argument (in this case, passing nil for creating a URL from a path string). Since we know it's an exception, I put a breakpoint on exception-raise and ran the app. After it stopped, I tracked back through the stack to see where the nil was, and I saw that a path is being requested for api.html from the main bundle and it's being passed, unchecked, into the URL constructor. That should probably be re-written anyway to just get a URL from the bundle in the first place.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.