devinross
devinross

Reputation: 2816

iPhone: Using static library in an application crashes the device but not the iphone simulator

I have a library I made, and now I want to utilize it in an application. I've believe I've properly linked to the library. Here are all the things I've done:

Like I said in the title, I've successfully run the app with the static library in the simulator. Once I try testing the app using the device, it crashes the second it has to use a function from the library:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[NSDate firstOfCurrentMonth]: unrecognized selector sent to class 0x3841bb44'
2009-10-10 12:45:31.159 Basement[2372:207] Stack:

Upvotes: 0

Views: 992

Answers (2)

Jon Lundy
Jon Lundy

Reputation: 21

I ran into this problem recently. I was unable to get the -all_load to work, when I noticed that another category I had DID work. I was lazy for this category and included it in with another file.

I eventually created a dummy class (no methods, instance variables) and included the implementation of my categories in the .m file for that dummy class. After doing this my categories started working even after I removed the -all_load flag.

This was on iPhone OS 3.1.3.

This certainly is not the RIGHT way to fix it, but it seemed to work.

Full sample code is on my blog for my (trivial) categories.

Upvotes: 0

fbrereto
fbrereto

Reputation: 35935

This is due to a bug in the current SDK linker. See this post for more information on the problem and possible workarounds. (also see this post.)

Update:

Another thing you can try is to remove the static library and include the library's source files directly in the application's project. I was facing a similar static library linking issue and that's what I ended up falling back on to get it to run successfully. If that works (however gross a workaround it may be) then it's definitely a linker issue.

Upvotes: 2

Related Questions