AlvinfromDiaspar
AlvinfromDiaspar

Reputation: 6834

iPhone xcode search path for device vs simulator?

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!

Upvotes: 2

Views: 7345

Answers (4)

Jeff Ames
Jeff Ames

Reputation: 2044

Rob already hinted at this, but to clarify, here's how you'd set it using the build window.

In the build settings window, select the setting you want to modify (like "Framework search paths"). Then click the gear in the lower left, and select "Add Build Setting Condition." Then you can add a value that applies only to iOS Simulator builds, and a second build setting condition to apply only to device builds.

Upvotes: 1

cdespinosa
cdespinosa

Reputation: 20799

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.

Upvotes: 0

Rob Napier
Rob Napier

Reputation: 299355

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.

Upvotes: 7

phoebus
phoebus

Reputation: 14931

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.

Upvotes: 1

Related Questions