diff options
author | Russell Greene <russell@shotover.com> | 2022-11-10 20:50:03 (GMT) |
---|---|---|
committer | Russell Greene <russell@shotover.com> | 2022-11-18 19:58:03 (GMT) |
commit | b99c386122b3e27b3c931c49f26d4afd93580755 (patch) | |
tree | 25b67f110ff43a7f0f939e1f9ca6cdd9b1128a39 | |
parent | 43918087123d5ec5b6df3b7cb56c123a7adc5b90 (diff) | |
download | CMake-b99c386122b3e27b3c931c49f26d4afd93580755.zip CMake-b99c386122b3e27b3c931c49f26d4afd93580755.tar.gz CMake-b99c386122b3e27b3c931c49f26d4afd93580755.tar.bz2 |
Xcode: Allow bundling extensionkit extensions
Fixes: #24150
14 files changed, 126 insertions, 4 deletions
diff --git a/Help/prop_tgt/XCODE_EMBED_type.rst b/Help/prop_tgt/XCODE_EMBED_type.rst index e8383c2..da744c2 100644 --- a/Help/prop_tgt/XCODE_EMBED_type.rst +++ b/Help/prop_tgt/XCODE_EMBED_type.rst @@ -16,9 +16,21 @@ The supported values for ``<type>`` are: ``APP_EXTENSIONS`` .. versionadded:: 3.21 - The specified items will be added to the ``Embed App Extensions`` build phase. + The specified items will be added to the ``Embed App Extensions`` build + phase, with ``Destination`` set to ``PlugIns and Foundation Extensions`` They must be CMake target names. +``EXTENSIONKIT_EXTENSIONS`` + .. versionadded:: 3.26 + + The specified items will be added to the ``Embed App Extensions`` build + phase, with ``Destination`` set to ``ExtensionKit Extensions`` + They must be CMake target names, and should likely have the + ``XCODE_PRODUCT_TYPE`` target property set to + ``com.apple.product-type.extensionkit-extension`` + as well as the ``XCODE_EXPLICIT_FILE_TYPE`` to + ``wrapper.extensionkit-extension`` + ``PLUGINS`` .. versionadded:: 3.23 diff --git a/Help/prop_tgt/XCODE_EMBED_type_CODE_SIGN_ON_COPY.rst b/Help/prop_tgt/XCODE_EMBED_type_CODE_SIGN_ON_COPY.rst index cb449ac..ca35c25 100644 --- a/Help/prop_tgt/XCODE_EMBED_type_CODE_SIGN_ON_COPY.rst +++ b/Help/prop_tgt/XCODE_EMBED_type_CODE_SIGN_ON_COPY.rst @@ -14,6 +14,9 @@ The supported values for ``<type>`` are: ``APP_EXTENSIONS`` .. versionadded:: 3.21 +``EXTENSIONKIT_EXTENSIONS`` + .. versionadded:: 3.26 + ``PLUGINS`` .. versionadded:: 3.23 diff --git a/Help/prop_tgt/XCODE_EMBED_type_PATH.rst b/Help/prop_tgt/XCODE_EMBED_type_PATH.rst index 160f765..5a5c65f 100644 --- a/Help/prop_tgt/XCODE_EMBED_type_PATH.rst +++ b/Help/prop_tgt/XCODE_EMBED_type_PATH.rst @@ -17,5 +17,8 @@ The supported values for ``<type>`` are: ``APP_EXTENSIONS`` .. versionadded:: 3.21 +``EXTENSIONKIT_EXTENSIONS`` + .. versionadded:: 3.26 + ``PLUGINS`` .. versionadded:: 3.23 diff --git a/Help/prop_tgt/XCODE_EMBED_type_REMOVE_HEADERS_ON_COPY.rst b/Help/prop_tgt/XCODE_EMBED_type_REMOVE_HEADERS_ON_COPY.rst index e3a7ced..da8f61b 100644 --- a/Help/prop_tgt/XCODE_EMBED_type_REMOVE_HEADERS_ON_COPY.rst +++ b/Help/prop_tgt/XCODE_EMBED_type_REMOVE_HEADERS_ON_COPY.rst @@ -19,5 +19,11 @@ The supported values for ``<type>`` are: If the ``XCODE_EMBED_APP_EXTENSIONS_REMOVE_HEADERS_ON_COPY`` property is not defined, headers WILL be removed on copy by default. +``EXTENSIONKIT_EXTENSIONS`` + .. versionadded:: 3.26 + + If the ``XCODE_EMBED_APP_EXTENSIONS_REMOVE_HEADERS_ON_COPY`` property is not + defined, headers WILL be removed on copy by default. + ``PLUGINS`` .. versionadded:: 3.23 diff --git a/Help/release/dev/xcode-ios-extensionkit.rst b/Help/release/dev/xcode-ios-extensionkit.rst new file mode 100644 index 0000000..b77b4ec --- /dev/null +++ b/Help/release/dev/xcode-ios-extensionkit.rst @@ -0,0 +1,11 @@ +xcode-ios-extensionkit +---------------------- + +* The :prop_tgt:`XCODE_EMBED_EXTENSIONKIT_EXTENSIONS <XCODE_EMBED_<type>>` target property + was added to tell the :generator:`Xcode` generator to ExtensionKit-based extensions + such as extensions using the Background Assets framework. + Aspects of the embedding can be customized with the + :prop_tgt:`XCODE_EMBED_EXTENSIONKIT_EXTENSIONS_PATH <XCODE_EMBED_<type>>`, + :prop_tgt:`XCODE_EMBED_EXTENSIONKIT_EXTENSIONS_CODE_SIGN_ON_COPY <XCODE_EMBED_<type>_CODE_SIGN_ON_COPY>` and + :prop_tgt:`XCODE_EMBED_EXTENSIONKIT_EXTENSIONS_REMOVE_HEADERS_ON_COPY <XCODE_EMBED_<type>_REMOVE_HEADERS_ON_COPY>` + properties. diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 0e94de5..aeb5074 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3929,7 +3929,7 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) void cmGlobalXCodeGenerator::AddEmbeddedObjects( cmXCodeObject* target, const std::string& copyFilesBuildPhaseName, const std::string& embedPropertyName, const std::string& dstSubfolderSpec, - int actionsOnByDefault) + int actionsOnByDefault, const std::string& defaultDstPath) { cmGeneratorTarget* gt = target->GetTarget(); if (!gt) { @@ -3965,7 +3965,8 @@ void cmGlobalXCodeGenerator::AddEmbeddedObjects( copyFilesBuildPhase->AddAttribute("dstPath", this->CreateString(*fwEmbedPath)); } else { - copyFilesBuildPhase->AddAttribute("dstPath", this->CreateString("")); + copyFilesBuildPhase->AddAttribute("dstPath", + this->CreateString(defaultDstPath)); } copyFilesBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", this->CreateString("0")); @@ -4091,6 +4092,17 @@ void cmGlobalXCodeGenerator::AddEmbeddedAppExtensions(cmXCodeObject* target) RemoveHeadersOnCopyByDefault); } +void cmGlobalXCodeGenerator::AddEmbeddedExtensionKitExtensions( + cmXCodeObject* target) +{ + static const auto dstSubfolderSpec = "16"; + + this->AddEmbeddedObjects(target, "Embed App Extensions", + "XCODE_EMBED_EXTENSIONKIT_EXTENSIONS", + dstSubfolderSpec, RemoveHeadersOnCopyByDefault, + "$(EXTENSIONS_FOLDER_PATH)"); +} + bool cmGlobalXCodeGenerator::CreateGroups( std::vector<cmLocalGenerator*>& generators) { @@ -4482,6 +4494,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( this->AddEmbeddedFrameworks(t); this->AddEmbeddedPlugIns(t); this->AddEmbeddedAppExtensions(t); + this->AddEmbeddedExtensionKitExtensions(t); // Inherit project-wide values for any target-specific search paths. this->InheritBuildSettingAttribute(t, "HEADER_SEARCH_PATHS"); this->InheritBuildSettingAttribute(t, "SYSTEM_HEADER_SEARCH_PATHS"); diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 856852b..1fdd189 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -218,10 +218,12 @@ private: const std::string& copyFilesBuildPhaseName, const std::string& embedPropertyName, const std::string& dstSubfolderSpec, - int actionsOnByDefault); + int actionsOnByDefault, + const std::string& defaultDstPath = ""); void AddEmbeddedFrameworks(cmXCodeObject* target); void AddEmbeddedPlugIns(cmXCodeObject* target); void AddEmbeddedAppExtensions(cmXCodeObject* target); + void AddEmbeddedExtensionKitExtensions(cmXCodeObject* target); void AddPositionIndependentLinkAttribute(cmGeneratorTarget* target, cmXCodeObject* buildSettings, const std::string& configName); diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedExtensionKitExtensions-iOS-check.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedExtensionKitExtensions-iOS-check.cmake new file mode 100644 index 0000000..576be11 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedExtensionKitExtensions-iOS-check.cmake @@ -0,0 +1,4 @@ +include(${CMAKE_CURRENT_LIST_DIR}/findAttribute.cmake) + +findAttribute(${test} "RemoveHeadersOnCopy" TRUE) +findAttribute(${test} "CodeSignOnCopy" FALSE) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedExtensionKitExtensions-iOS.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedExtensionKitExtensions-iOS.cmake new file mode 100644 index 0000000..839f842 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedExtensionKitExtensions-iOS.cmake @@ -0,0 +1 @@ +include(${CMAKE_CURRENT_LIST_DIR}/EmbedAppExtensions.cmake) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedExtensionKitExtensions-macOS-check.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedExtensionKitExtensions-macOS-check.cmake new file mode 100644 index 0000000..576be11 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedExtensionKitExtensions-macOS-check.cmake @@ -0,0 +1,4 @@ +include(${CMAKE_CURRENT_LIST_DIR}/findAttribute.cmake) + +findAttribute(${test} "RemoveHeadersOnCopy" TRUE) +findAttribute(${test} "CodeSignOnCopy" FALSE) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedExtensionKitExtensions-macOS.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedExtensionKitExtensions-macOS.cmake new file mode 100644 index 0000000..839f842 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedExtensionKitExtensions-macOS.cmake @@ -0,0 +1 @@ +include(${CMAKE_CURRENT_LIST_DIR}/EmbedAppExtensions.cmake) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedExtensionKitExtensions.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedExtensionKitExtensions.cmake new file mode 100644 index 0000000..91d207b --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedExtensionKitExtensions.cmake @@ -0,0 +1,22 @@ +add_executable(app_extensionkit_extension main.m) +set_target_properties(app_extensionkit_extension PROPERTIES + LINKER_LANGUAGE CXX + BUNDLE YES + XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO" + XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "" + XCODE_ATTRIBUTE_ENABLE_BITCODE "NO" + XCODE_ATTRIBUTE_GENERATE_INFOPLIST_FILE "YES" + MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/ExtensionKit.Info.plist.in" + MACOSX_BUNDLE_GUI_IDENTIFIER "com.example.app.app_extensionkit_extension" + XCODE_PRODUCT_TYPE "com.apple.product-type.extensionkit-extension" + XCODE_EXPLICIT_FILE_TYPE "wrapper.extensionkit-extension" +) + +add_executable(app MACOSX_BUNDLE main.m) +add_dependencies(app app_extension) +set_target_properties(app PROPERTIES + XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO" + XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "" + XCODE_EMBED_EXTENSIONKIT_EXTENSIONS app_extension + MACOSX_BUNDLE_GUI_IDENTIFIER "com.example.app" +) diff --git a/Tests/RunCMake/XcodeProject-Embed/ExtensionKit.Info.plist.in b/Tests/RunCMake/XcodeProject-Embed/ExtensionKit.Info.plist.in new file mode 100644 index 0000000..573aa22 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/ExtensionKit.Info.plist.in @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>EXAppExtensionAttributes</key> + <dict> + <key>EXExtensionPointIdentifier</key> + <string>com.apple.background-asset-downloader-extension</string> + <key>EXPrincipalClass</key> + <string>BackgroundDownloadHandler</string> + </dict> +</dict> +</plist> diff --git a/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake index f3a6918..a7bccee 100644 --- a/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake @@ -64,6 +64,25 @@ function(TestAppExtension platform) ) endfunction() +function(TestExtensionKitExtension platform) + set(testName EmbedExtensionKitExtensions-${platform}) + if(NOT platform STREQUAL "macOS") + set(RunCMake_TEST_OPTIONS -DCMAKE_SYSTEM_NAME=${platform}) + endif() + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${testName}-build) + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(${testName}) + run_cmake_command(${testName}-build + ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR} + --config Debug + --target app + ) +endfunction() + # Isolate device tests from host architecture selection. unset(ENV{CMAKE_OSX_ARCHITECTURES}) @@ -74,3 +93,11 @@ if(XCODE_VERSION VERSION_GREATER_EQUAL 8) TestAppExtension(macOS) TestAppExtension(iOS) endif() + +if(XCODE_VERSION VERSION_GREATER_EQUAL 14.1) + # The various flag on/off combinations are tested by the EmbedFrameworks... + # tests, so we don't duplicate all the combinations here. We only verify the + # defaults, which is to remove headers on copy, but not code sign. + TestAppExtension(macOS) + TestAppExtension(iOS) +endif() |