19
votes

I am trying to make a framework for my project. Into my framework I added the path of my header files to target>Build Settings>header-search path. After that I added this framework to my project by Build Phases>Link Binary With Libraries.

When I want to import the header file which I included in my framework, I get a .h file not found error. Is what I'm trying to do possible? Or am I missing anything?

I created framework like that;

Opened new project as iOS>Framework&Library>Cocoa Touch Framework I didn't add any class, i just added header search path and library search path and linker flags. I don't think i did a mistake in this part because we do it in every project but first time i m doing this for framework. Then i pressed run and get my framework from Products.

I opened my project and added framework Build Phases>Link Binary With Libraries. I m able to import header file of framework like #import <myframework/framework.h> After this i added framework also General>Embedded Binaries. Everything look normal but i cannot add headers to my project which i included to my framework with header search path. I have to use header search path because there is tons of headers, i cannot add all of them to my Xcode.

2
You don't need to set header search path if the header is within a framework, do you? You have to name the header properly in the #import statement, however (#import <Framework/Framework.h>).trojanfoe
There is a lot of headers in another path. I have to use header search path unfortunately. Kind of company rule. Thanks for your comment.Yucel Bayram
Can you describe more detail how exactly you have created your framework and how exactly you imported it?arturdev
@arturdev Sure, i did this. please read it again. Hope there is enough details.Yucel Bayram

2 Answers

29
votes

Make sure you all Public Header appears in Public Section else drag and drop .h file to public enter image description here

5
votes

Everything look normal but i cannot add headers to my project which i included to my framework with header search path.

It sounds as though you're expecting all the headers that can be found at the path specified by your header search path will become part of your framework, so that if there's a header named SomeHeader.h in your search path, it will be built into your framework and you'll be able to import it into client projects like:

#import <MyFramework/SomeHeader.h>

But that's not the case at all. If you want your framework to provide SomeHeader.h, you need to add that file to the project and, as Meghs Dhameliya already pointed out, you need to specify SomeHeader.h in the Public Headers portion of the Headers build phase. This will make Xcode copy the header file into the framework so that clients of the framework can import the header file. It's not clear that that's what you really want, though... in comments you wrote:

There is a lot of headers in another path. I have to use header search path unfortunately. Kind of company rule.

So it sounds like all projects in your company specify the same header search path so that they have access to these header files. If that's true, then there's no reason for projects to need to #import them from your framework, but in that case it's not clear what the actual problem is. Or, perhaps you're creating the framework so that client projects can get the headers from your framework instead of having to reference the header search path. In that case, you will need to add those headers to the project and specify them as described above.