# PUBLIC\_HEADER target property ignored when building Mac OS Frameworks

**URL:** <https://discourse.cmake.org/t/public-header-target-property-ignored-when-building-mac-os-frameworks/6311>\
**Category:** Code\
**Tags:** os:macos\
**Created:** [August 20, 2022, 4:07pm UTC](https://discourse.cmake.org/t/public-header-target-property-ignored-when-building-mac-os-frameworks/6311 "2022-08-20T16:07:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DwayneDuane](https://discourse.cmake.org/user_avatar/discourse.cmake.org/dwayneduane/32/2698_2.png) [@DwayneDuane](https://discourse.cmake.org/u/DwayneDuane)\
**Post date:** [August 20, 2022, 4:07pm UTC](https://discourse.cmake.org/t/public-header-target-property-ignored-when-building-mac-os-frameworks/6311/1 "2022-08-20T16:07:31Z")

</div>

CMake version: 3.21.2  
OS: macOS Monterey 12.4

I am trying to build a MacOS framework using CMake and would like to copy the lib’s public headers into a `Headers` subfolder inside the framework. According to CMake [documentations](https://cmake.org/cmake/help/v3.21/prop_tgt/PUBLIC_HEADER.html), all I need to do is to set the `PUBLIC_HEADER` target property. Here is my CMakeLists.txt:

```auto
cmake_minimum_required(VERSION 3.21)
project(hello)

set(CMAKE_CXX_STANDARD 17)
add_library(hello SHARED src/hello.cpp)
target_include_directories(hello PRIVATE include)

set_target_properties(hello PROPERTIES
    FRAMEWORK True
    MACOSX_FRAMEWORK_IDENTIFIER com.cmake.helloFramework
    VERSION 16.4.0
    SOVERSION 1.0.0
    PUBLIC_HEADER include/hello.h
    XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer"
)

install(
    TARGETS hello
    FRAMEWORK 
        DESTINATION lib
)
     

```

And here is how I configure, built, and installed my project:

```auto
mkdir build && cd build
cmake -G "Xcode" -DCMAKE_INSTALL_PREFIX=../install ..
cmake --build . --target install

```

Here is the output I get:

```auto
-- Install configuration: "Debug"
-- Installing: /Users/user_name/Desktop/public_header_test/install/lib/hello.framework
-- Installing: /Users/user_name/Desktop/public_header_test/install/lib/hello.framework/Resources
-- Installing: /Users/user_name/Desktop/public_header_test/install/lib/hello.framework/Versions
-- Installing: /Users/user_name/Desktop/public_header_test/install/lib/hello.framework/Versions/Current
-- Installing: /Users/user_name/Desktop/public_header_test/install/lib/hello.framework/Versions/16.4.0
-- Installing: /Users/user_name/Desktop/public_header_test/install/lib/hello.framework/Versions/16.4.0/Resources
-- Installing: /Users/user_name/Desktop/public_header_test/install/lib/hello.framework/Versions/16.4.0/Resources/Info.plist
-- Installing: /Users/user_name/Desktop/public_header_test/install/lib/hello.framework/Versions/16.4.0/hello
-- Installing: /Users/user_name/Desktop/public_header_test/install/lib/hello.framework/hello

```

The header `include/hello.h` does not get installed inside `hello.framework` at all, despite the CMake documentation explicitly stating that `PUBLIC_HEADER` should work for frameworks. Am I doing or understanding something incorrectly here?

---

<div class="post-metadata">

**Author:** ![vdamewood](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/v/7ab992/32.png) [@vdamewood](https://discourse.cmake.org/u/vdamewood)\
**Post date:** [August 20, 2022, 4:14pm UTC](https://discourse.cmake.org/t/public-header-target-property-ignored-when-building-mac-os-frameworks/6311/2 "2022-08-20T16:14:23Z")

</div>

> [@DwayneDuane](#):
>
> `add_library(hello SHARED src/hello.cpp)`

Change this to:

`add_library(hello SHARED src/hello.cpp include/hello.h)`

The framework’s public headers have to be source files of the framework’s target.
