# Xcode just ignore generated files?

**URL:** https://discourse.cmake.org/t/xcode-just-ignore-generated-files/11325
**Category:** Usage
**Tags:** gen:ninja, gen:xcode
**Created:** [July 25, 2024, 2:26pm UTC](https://discourse.cmake.org/t/xcode-just-ignore-generated-files/11325 "2024-07-25T14:26:24Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![davemilter](https://discourse.cmake.org/user_avatar/discourse.cmake.org/davemilter/32/541_2.png) [@davemilter](https://discourse.cmake.org/u/davemilter)
#### Post date: [July 25, 2024, 2:26pm UTC](https://discourse.cmake.org/t/xcode-just-ignore-generated-files/11325/1 "2024-07-25T14:26:25Z")

</div>

I have external project build by script and also this script generates header file.

And this generated file is problem, when it changed (script produced modified file),  
then `Xcode` just ignore this change.

If I change generator to `Ninja` all works just fine.

The minimum reproducible example looks like this:

```auto
cmake_minimum_required(VERSION 3.17 FATAL_ERROR)
project(foo)

add_custom_target(ext_lib_target  
  COMMAND /bin/sh ${CMAKE_SOURCE_DIR}/build_static_lib.sh "${PROJECT_BINARY_DIR}/cpp"
  BYPRODUCTS "${CMAKE_SOURCE_DIR}/rawlib/libmyrawlib.a" "${PROJECT_BINARY_DIR}/cpp/generated_header.hpp"
  DEPENDS ${CMAKE_SOURCE_DIR}/build_static_lib.sh
  WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
  
add_library(ext_lib STATIC IMPORTED GLOBAL)
add_dependencies(ext_lib ext_lib_target)
set(HEADERS_OUT_DIR "${PROJECT_BINARY_DIR}")
set_target_properties(ext_lib
  PROPERTIES
  IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/rawlib/libmyrawlib.a"
  IMPORTED_NO_SONAME True
)
set_target_properties(ext_lib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${HEADERS_OUT_DIR}")

add_library(core STATIC core/boo.hpp core/boo.cpp "${PROJECT_BINARY_DIR}/cpp/generated_header.hpp")
target_include_directories(core PUBLIC core)
target_link_libraries(core PUBLIC ext_lib)

add_executable(foo main.cpp)
target_link_libraries(foo PRIVATE core)

```

where toy `build_static_lib.sh` looks like this:

```auto
#!/bin/sh

set -euo pipefail
cd rawlib && clang -c lib.c -o lib.o && ar crv libmyrawlib.a lib.o
echo "#pragma once\n#include <string>\nstruct Boo {\nstd::string data;\n};\n" > $1/generated_header.hpp

```

`core/boo.hpp` includes `"${PROJECT_BINARY_DIR}/cpp/generated_header.hpp"`:

```auto
#include "cpp/generated_header.hpp"

```

and `core/boo.cpp` includes `boo.hpp`:

```auto
#include "boo.hpp"

```

but any changes in `cpp/generated_header.hpp` do not cause rebuild of boo.cpp,  
`xcodebuild` called via `cmake --build . -t foo --config Release` just ignores this changes.

But change of `boo.hpp` for example, cause proper rebuild.

May be `Xcode` doesn’t support generated header files,  
or may it doesn’t like header file in `${PROJECT_BINARY_DIR}` ?

Full source code:

main.cpp

```auto
#include <cstdio>

#include "boo.hpp"

int main() {
  auto v = find_something();  
  printf("f = %zu\n", v.data.size());
}

```

boo.cpp

```auto
#include "boo.hpp"

Boo find_something() {
  Boo ret;
  ret.data = "1234";
  return ret;
}  

```

```auto
#pragma once

#include "cpp/generated_header.hpp"

Boo find_something();

```

---

<div class="post-metadata">

### Author: ![davemilter](https://discourse.cmake.org/user_avatar/discourse.cmake.org/davemilter/32/541_2.png) [@davemilter](https://discourse.cmake.org/u/davemilter)
#### Post date: [July 29, 2024, 7:04pm UTC](https://discourse.cmake.org/t/xcode-just-ignore-generated-files/11325/2 "2024-07-29T19:04:54Z")

</div>

I created issue in cmake’s gitlab [https://gitlab.kitware.com/cmake/cmake/-/issues/26173](https://gitlab.kitware.com/cmake/cmake/-/issues/26173)
