Problems with build-script –xcode

Hi, I’m encountering an error with the main branch and the swift-DEVELOPMENT-SNAPSHOT-2024-10-30-a tag when running the following command:

utils/build-script --swift-darwin-supported-archs "$(uname -m)" --xcode --clean

The error message is as follows:

CMake Error at cmake/modules/SwiftXcodeSupport.cmake:21 (message):
  No import configuration of clang-resource-headers specified?!
Call Stack (most recent call first):
  cmake/modules/SwiftXcodeSupport.cmake:88 (check_imported_target_has_imported_configuration)
  cmake/modules/SwiftSharedCMakeConfig.cmake:213 (fix_imported_targets_for_xcode)
  cmake/modules/SwiftSharedCMakeConfig.cmake:255 (swift_common_standalone_build_config_clang)
  CMakeLists.txt:915 (swift_common_standalone_build_config)

There are no issues when I run this alternative command:

utils/build-script --skip-build-benchmarks \
  --skip-ios --skip-watchos --skip-tvos --swift-darwin-supported-archs "$(uname -m)" \
  --sccache --release-debuginfo --swift-disable-dead-stripping \
  --bootstrapping=hosttools --clean

This problem doesn’t occur when using the swift-DEVELOPMENT-SNAPSHOT-2024-10-27-a tag.

My Environment:

  • Macbook Pro Apple M2 Pro
  • macOS Sequoia 15.1
  • CMAKE 3.24.2

Please let me know if any additional information would be helpful.

Thank you in advance for your help.

Hmm, the check requiring imported targets to have a specific imported configuration seems overly aggressive. The clang-resource-headers doesn't specify which configurations it needs to be included with.

Could you try copying this diff:

diff --git a/cmake/modules/SwiftXcodeSupport.cmake diff --git a/cmake/modules/SwiftXcodeSupport.cmake b/cmake/modules/SwiftXcodeSupport.cmake
index ed0d4f3a15d..2fd509046ee 100644
--- a/cmake/modules/SwiftXcodeSupport.cmake
+++ b/cmake/modules/SwiftXcodeSupport.cmake
@@ -10,21 +10,22 @@ function(escape_path_for_xcode config path result_var_name)
 
   # Hack to deal with the fact that paths contain the build-time
   # variables. Note that this fix is Xcode-specific.
   string(REPLACE "$(CONFIGURATION)" "${config}" result "${path}")
   string(REPLACE "$(EFFECTIVE_PLATFORM_NAME)" "" result "${result}")
   set("${result_var_name}" "${result}" PARENT_SCOPE)
 endfunction()
 
 function(check_imported_target_has_imported_configuration target config)
   get_target_property(IMPORTED_CONFIGS_LIST ${target} IMPORTED_CONFIGURATIONS)
-  if ("${IMPORTED_CONFIGS_LIST}" STREQUAL "IMPORTED_CONFIGS_LIST-NOTFOUND")
+  if ("${IMPORTED_CONFIGS_LIST}" STREQUAL "IMPORTED_CONFIGS_LIST-NOTFOUND"
+    AND NOT ${target} STREQUAL "clang-resource-headers")
     message(FATAL_ERROR "No import configuration of ${target} specified?!")
   endif()
 
   if(NOT "${config}" IN_LIST IMPORTED_CONFIGS_LIST)
     message(FATAL_ERROR "${target} does not have imported config '${config}'?! Instead: ${IMPORTED_CONFIGS_LIST}")
   endif()
 endfunction()
 
 function(fixup_imported_target_property_for_xcode target property llvm_build_type)
   set(FULL_PROP_NAME "${property}_${llvm_build_type}")

and running pbpaste | git apply from within the Swift compiler repo.
Please verify that it configures (I expect that it will) and gives you the expected Xcode experience. Thanks.

1 Like

Thank you for the reply.

I tried it and got the below error.

CMake Error at cmake/modules/SwiftXcodeSupport.cmake:26 (message):
  clang-resource-headers does not have imported config 'MINSIZEREL'?!
  Instead: IMPORTED_CONFIGS_LIST-NOTFOUND
Call Stack (most recent call first):
  cmake/modules/SwiftXcodeSupport.cmake:89 (check_imported_target_has_imported_configuration)
  cmake/modules/SwiftSharedCMakeConfig.cmake:213 (fix_imported_targets_for_xcode)
  cmake/modules/SwiftSharedCMakeConfig.cmake:255 (swift_common_standalone_build_config_clang)
  CMakeLists.txt:915 (swift_common_standalone_build_config)

FYI we have recently introduced a new way to generate an Xcode project for the Swift repo: A new way to work on the Swift project in Xcode. Feel free to give it a try!

4 Likes

Thank you!

It works well. It's very fast and convenient.

BTW, the below command works.

utils/generate-xcode <build dir>

but, the below one didn't work.

./swift-xcodegen <path to Ninja build directory>

Where do we run the command?

The README could probably be a bit clearer there, but ./swift-xcodegen is assuming you're in the utils/swift-xcodegen folder. utils/generate-xcode directly runs it though, so it's better to use that instead.

1 Like

I see. Thanks!

Updating the README in [xcodegen] Update README by hamishknight · Pull Request #77428 · swiftlang/swift · GitHub, hopefully that improves things.

1 Like