tags:

views:

955

answers:

5

How can I add a reference the CoreLocation framework to my app and get it to compile for both the Simulator and a device without needing to delete and re-add the frame when switching platforms?

I'm writing a multi player game. Sometimes I test by putting my app on a device and also in the simulator and debug in simulator side. But I've recently added some CoreLocation services to my app and when I switch the platform from Simulator to Device, I need to remove the CoreLocation reference and re-add it from a different location. Then, when switching back to Simulator, I need to do it again.

I understand why. I'm just wondering if there are any tricks or tips which might help me automate this.

A: 

I guess it's not that complicated. You can drag both the simulator framework and the device framework into an XCode project and it works. I'll remove the Simulator one before shipping, but it works for debugging.

marcc
I'm not entirely sure about this, but can't you select the build target of each framework with a checkbox after single clicking them?
Prairiedogg
+2  A: 

if you add it with relative path, it will point to the right base sdk when you switch between simulator and device.
When you do "add exiting frameworks", there is a window that tells you reference type, it should be Default (which should point to Relative to Current SDK)
then when you change the SDK to device or simulator it will look from the active SDK frameworks folder.

CiNN
Yeah, thanks. That's what I ended up figuring out. I didn't know that I could have both in the project at the same time!
marcc
? you only need one...
CiNN
If I take the CoreLocation framework out of the Developer\Platforms\iPhoneOS.platform\....... folder, it doesn't work on the Simulator. If I take it out of Developer\Platforms\iPhoneSimulator.platform\..... folder, it won't work on the device. Maybe I'm doing something wrong? I am finding the framework in Finder and dragging it onto the Frameworks folder in XCode.
marcc
i did say to add the relative path
CiNN
+2  A: 

You have to add the framework by double-clicking the target, open the general tab, pressing the plus-button below the "liked-libraries" section.

Nikolai Ruhe
+1  A: 
John Ballinger
A: 

I'm new to XCode development and ran into the same problem that you did.

There are several ways to add a framework to a project: dragging and dropping into the frameworks folder; adding to the linked libraries in the target's info page; etc. I found that the easiest way to add a framework to a project is the right click on the Frameworks folder in the "Groups and Files" Tab and choose "Add>Existing Frameworks"

When you select a framework it will be added relative to the SDK - If you open the frameworks' "info" window (ctrl-click> Get Info) after adding it, the path-type will be set to "Relative to current SDK")

THD