Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to teach Xcode to include all header files in output of static library project?

I followed a tutorial to create a static library project. Then I dragged in my classes and added them to the target.

When I build & run, it creates a libUtils.a file. Upon reveal in Finder the include folder only contains the header file for the first class that Xcode created automatically when I created the project. All other header files are missing.

I double-checked: All the added class files are part of the project and the inspector shows a target membership checkmark for the target project.

Is this a bug in Xcode or must I register all files I create additionally somewhere else?

like image 971
Proud Member Avatar asked Oct 05 '13 21:10

Proud Member


People also ask

Do static libraries need header files?

You can have the libraries installed without the headers. You can't then compile code that uses the header, but you can run code that uses the shared library.

How do I create a static library in XCode?

Open XCode and start a new project. Under iOS, select Library and “Cocoa Touch Static Library” say it as "staticlibrary". This will create a nice new project for us that builds a . a file.

How do I open a header file in XCode?

Holding the Command key, click the import/include statement to view the header. Also, you can Command-click on a symbol to jump to the header file that defines it.


1 Answers

Add Headers files

Xcode 10.2.1

Project editor -> select a target -> Build Phases -> + Add a new Build Phase -> New Header Phase

enter image description here

The second step is to add .h files

//Build Phases
Project editor -> select a target -> Build Phases -> Headers -> add files to the **public** zone
//or
//Target Membership
Select `.h` file -> Select File Inspectors Tab -> Target Membership -> Select the target and make it **public**

[Target Membership]

like image 140
yoAlex5 Avatar answered Sep 20 '22 07:09

yoAlex5