2

I have code that I build into a framework. It is sometimes useful, when debugging other project code relying on the framework, to instead build the source into the other project directly. The only issue is the way headers are referenced:

// Framework
#import <my_framework/my_widget.h>

// Source
#import "my_widget.h"

I could make a bunch of edits and go on my way, but I feel like there must be a clever solution to this, perhaps related to setting something for the Framework search path.

I'm curious about doing this in Xcode, though the raw command would also be useful.

Update

Despite some sensible advice, I'm having trouble getting this to work, so more explicit help would be great (and hopefully helpful to others).

// My framework source directory
/work/my_framework_project/source/widgets/my_widget.h
/work/my_framework_project/source/widgets/my_widget.m

// The framework that creates
/work/my_framework.framework/my_framework
/work/my_framework.framework/Headers/my_widget.h

// The project I'm debugging
/work/some_project/source/my_source.m

If I drop the framework into some_project, I refer to my header like this:

#import <my_framework/my_widget.h>

If I drop the reference to framework and add the source to the project, I need to do this, but don't want to:

#import "my_widget.h"

Note that I do not import "my_framework/my_widget.h" -- if that matters.

If I follow the first suggested answer, then I add this as a flag to the source files when I'm compiling them (currently by adding it in the "Compile Sources" area.

-I/work/my_framework.framework/Headers

This is not solving the issue of wanting to refer to the imports using the framework notation.

1
  • Solved it by making a subdirectory inside Headers called "my_framework" and copying all of the headers into this directory (and use the suggested "User header search path" solution). Note that a symbolic link in Headers (my_framework -> .) did not work, I needed a real directory. Commented Jan 31, 2013 at 21:16

1 Answer 1

1

though the raw command would also be useful

Here it is:

<COMPILER> -Imy_framework_dir <other options...>

So you use the -I (uppercase 'i') flag for this (GCC or Clang style).

Xcode supports this feature using the 'user search header paths' section on the 'Build phases -> Compilation' tab of your project.

Sign up to request clarification or add additional context in comments.

3 Comments

This will search my framework for the headers but use my source .m files, yes? I'm having trouble getting this to work. Your comment about 'Build phases -> Compilation" is "Compile Sources" on Xcode 4.5 yeah? I must have some pathing issues...
@BenFlynn 1. yes, 2. probably (I don't know the exact name/title, I don't use Xcode... Occasionally you may need to tick the 'Always search user header paths' checkbox on the same tab.)
Ok, it looks as though it adds the argument generally if you add it to 'Build Settings -> User Header Search Paths' or otherwise you can do it on a per-file basis with 'Build phases -> Compile sources'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.