Xcode: Unity builds have no way to compile/ analyze/ preprocess an individual original file
Original files (non the generated cxx ones) of a unity-enabled target do not belong to any target according to Xcode. Trying to compile an individual file shows not a member of any targets in the current scheme
whatever the active scheme may be. Same goes for preprocessor checks and Xcode static analysis
In essence: there's no way to compile/preprocess an original file in isolation in Xcode in a unity build target. Visual Studio can compile one single file in the same case.
cmake version 3.18.6 Xcode 11.3
- Run
cmake . -G Xcode
- Open
unity_compile.xcodeproj
. - Open file1.cpp in Xcode.
- Product menu -> Perform action -> preprocess/ compile/ analyze file1.cpp
- "Show the report navigator" to go to logs
- Find
'file1.cpp' is not a member of any targets in the current scheme that build for running
in the logs.
cmake_minimum_required(VERSION 3.16)
project(unity_compile)
file(WRITE file1.cpp "int main() {
return 0;
;
}")
add_executable(main file1.cpp)
set_target_properties(main PROPERTIES UNITY_BUILD ON)
set_target_properties(main PROPERTIES UNITY_BUILD_BATCH_SIZE 10)
set(CMAKE_XCODE_ATTRIBUTE_COMPILER_INDEX_STORE_ENABLE FALSE CACHE BOOL "" FORCE)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "" FORCE)