views:

601

answers:

3

I am using Xcode 3.2.1 in project, where Base SDK is iPhone Device 3.0 and iPhone OS Deployment Target is iPhone OS 2.0, in other words a backwards compatible application.

The problem is MapKit Framework. It's added as Weak linked library, but the app just does not link for "Device - 2.2.1" target. I have run out of ideas... What else can I do but mark the library as "weak" linked? It used to work originally, but not any more.

Here's part of command line, which looks just fine to me:

-framework Foundation -framework UIKit -framework CoreGraphics
 -weak_framework CoreLocation -weak_framework MapKit

Error note:

ld: framework not found MapKit
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++-4.0 failed with exit code 1
+1  A: 

To run your app on 2.2.1, you don't need to choose 2.2.1 in that menu, just leave the "Active SDK" set to 3.0 or beyond.

David Maymudes
It's the linker failure. Can't run anything, which does link first :)
JOM
wait--do you have a separate target for 2.2.1? You don't want to compile an OS-specific binary... Does it link if you set it to Device-3.0? If so, that's what you should be doing, and it should still run on 2.2.1 because you weak linked.
David Maymudes
Yep, just one target. Want to run same app as-is in both 2.x and 3.x devices. Links and runs just fine for Device-3.0 Simulator. My iPhone is still in box, using iPod Touch to test. Can't find any second place to overwrite default weak linking for MapKit, but it must be there somewhere...
JOM
Oh, d*mn! I think you're right... Got to check this!
JOM
The problem was that my certificate had expired. Fixed, after lots of related problems, and now my app nicely crashes on hardware! Thanx for the tip!
JOM
Well, besides that I should NOT select target as 2.2.1, exactly like you said! I just didn't realize this, since 3.0 didn't work either, but that was due expired dev cert. Didn't notice those were two different problems.
JOM
+1  A: 

Try the MailComposer sample project from Apple, which does a similar thing with the MessageUI framework. What you may need to do is set the Base SDK to 2.2.1 instead of 2.0.

cdespinosa
Reading MailComposer, done that Weak linking. Can't find anything which might have overwritten that setting :(
JOM
+1  A: 

Just to clarify the problem and solution:

Problem: I wanted to create a backwards compatible application, which would run on both iPhone OS 2.x and 3.x devices. It would use 3.x specific features when available e.g. MapKit.

Solution: set your "Base SDK as iPhone Device 3.0" and "iPhone OS Deployment Target as iPhone OS 2.0". Connect your iPhone OS 2.x device (mine was iPod Touch, where I refuse to upgrade to latest available iPod software version) and select at top left corner the target as "Device - 3.0" - even when your connected device is NOT 3.0 compatible at all !!!

Pretty confusing, looks totally non-logical at first, but that's the way it works!

JOM