Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 4.2: How to import .h file from subproject

Tags:

xcode

ios

I am new to Xcode subprojects. In my iPhone app project MyProject, I am trying to refactor some common code to a static library project called MyLibrary. After I create MyLibrary and move the code, MyProject is no-longer compiling. The error is that the MyProject cannot see the .h files in MyLibrary.

The error MyLibraryConfig.h: No such file or directory is coming in the line:

#import "MyLibraryConfig.h"
  • How to import the MyLibrary .h files in MyProject ?
  • What is the best practice here? Assuming I have multiple such libraries, it is tedious to add these to header search paths to the parent project.
like image 966
Shameem Avatar asked Feb 29 '12 15:02

Shameem


People also ask

How do I create a .H file in Xcode?

To create a new file, choose File/New/File … which will open a template chooser in which you can select a header file, a C file, or a C++ file. If you select a C or C++ file, it will give you the option of also creating a header file with the same name.

How do I import files into Xcode?

I include them in the project by right-clicking on the project folder in the project view in Xcode, and selecting "Add Files to ...". I then navigate to the folder containing the source files, click on the folder and select "Add." With the options "Create folder references" and "Add to target [target name]".

What is .h file in Xcode?

h, which is called the header file. The implementation section goes into MyClass. m, which is called the implementation file. The separation into two files is not inconvenient, because Xcode, expecting you to follow this convention, makes it easy to jump from editing a . h file to the corresponding .


1 Answers

In build settings --> Header Search Path --> Add below entry

$(SRCROOT) and mark it as recursive.

enter image description here

like image 133
Saran Avatar answered Oct 20 '22 00:10

Saran