Xcode: Fix POST_BUILD order in bundle targets on Xcode 16+

XCode 16+ no longer delays our POST_BUILD phase until after bundle files
like `Info.plist` are generated.  Teach the Xcode generator to add
explicit dependencies to the POST_BUILD phase in bundle targets to
ensure the files are created before it runs.

Fixes: #26656
This commit is contained in:
Alexandra Cherdantseva
2025-02-21 21:51:56 +02:00
committed by Brad King
parent b18513105c
commit 2dc8c1d45f
6 changed files with 70 additions and 3 deletions
@@ -0,0 +1,15 @@
enable_language(CXX)
add_executable(app MACOSX_BUNDLE app.cxx)
add_library(fw SHARED fw.cxx)
set_property(TARGET fw PROPERTY FRAMEWORK 1)
foreach(target IN ITEMS app fw)
set_property(TARGET ${target} PROPERTY XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT dwarf-with-dsym)
add_custom_command(
TARGET ${target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E sha256sum
[["$DWARF_DSYM_FOLDER_PATH/$DWARF_DSYM_FILE_NAME/Contents/Resources/DWARF/$PRODUCT_NAME"]]
[["$DWARF_DSYM_FOLDER_PATH/$DWARF_DSYM_FILE_NAME/Contents/Info.plist"]]
[["$TARGET_BUILD_DIR/$EXECUTABLE_PATH"]]
[["$TARGET_BUILD_DIR/$INFOPLIST_PATH"]]
)
endforeach()
@@ -91,6 +91,13 @@ if(XCODE_VERSION VERSION_GREATER_EQUAL 12)
XcodeObjectLibsInTwoProjectsMacOS()
block()
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/BundlePostBuild-build)
run_cmake(BundlePostBuild)
set(RunCMake_TEST_NO_CLEAN 1)
run_cmake_command(BundlePostBuild-build ${CMAKE_COMMAND} --build . --config Debug)
endblock()
endif()
function(XcodeSchemaGeneration)
+4
View File
@@ -0,0 +1,4 @@
int main()
{
return 0;
}
+4
View File
@@ -0,0 +1,4 @@
int fw()
{
return 0;
}