views:

1237

answers:

3

I am confused at this setting (Project -> Edit Active Target). The Search Paths can differ based on the SDK setting (simulator vs device).

But if I provide both simulator and device paths, for lets say the Frameworks path, then i get linker errors. But it seems if I only provide the proper path for whichever SDK i have selected, then it builds fine!

How can I keep both path settings? Currently Im having to cut and paste the appropriate path based on the SDK i have selected to build.

Thanks!

A: 

You should have two separate build target profiles set up, one for sim and one for device, rather than constantly editing the same one. That's kind of the point of targets.

phoebus
This isn't the point of targets. It's the same target for different platforms. Targets are things like "Test app" versus "Main app" versus "Disk image." It's not a good way to switch platforms for a single target.
Rob Napier
Okay, i am not using custom frameworks. I am using standard frameworks in addition to the standard sqlite3 library.So... if I should not be using a separate Target for each platform, how do I fix my framework/lib path problem? I have one single Target. If I want to build for simulator I select Simulator 3.0 from the drop-down list. Likewise I select Device 3.0 for device.
AlvinfromDiaspar
+1  A: 

Which kind of search path are you talking about? The system search paths are automatically handled for you, so I assume that your problem is some custom library.

There are two solutions. You can use conditional settings, or you can use universal libraries. I've grown to love universal libraries, but haven't had time to write up full instructions yet. The way they work is to build a static library for the simulator and for the device, and then use lipo to glue them together. You can then use the same library for both platforms. I really need to write up full instructions for this because it's very useful.

There are two more approaches. First you can use conditional settings. In xcconfig files (see my talk on why to use xcconfig files), you put something like this:

LD_FLAGS[sdk=iphonesimulator*] = -lsasl2

That links sasl2 just for the simulator. Set whatever you flag you need. Another solution is variable substitution:

HEADER_SEARCH_PATHS = "$(SRCROOT)/MyPackage/build/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/include"

This assumes that MyPackage is in a subdirectory of your project and it was built into the build directory. It'll look in, for example, Debug-iphoneos for its variables.

You can also do both of the above in the build pane, but I really recommend folks get away from the build pane for any serious project. Variable substitution works identically in the build pane, and conditional settings are accessible from right-clicking on a setting.

Rob Napier
+1  A: 

If you're only using

  • project headers
  • SDK framework headers
  • sqlite3 headers

then your Header Search Paths should be empty. Xcode provides search paths for your project headers, SDK frameworks, and /usr/include/*.h automatically, and adjusts those for the framework in use.

The only reasons to have custom Header Search Paths is when you have references to headers that are not in the SDK, are in "deep" locations in the SDK (such as in subdirectories of /usr/include or in buried frameworks), or are in other targets or projects your project cross-references.

cdespinosa