From 6ef8165b2cf1edde9d756307dabbbb8a73a05ca6 Mon Sep 17 00:00:00 2001 From: Adam Essenmacher Date: Sun, 23 Aug 2026 16:17:01 -0400 Subject: [PATCH] Make XCFramework creation repeatable --- common.cake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/common.cake b/common.cake index aa31073c..d53934e9 100644 --- a/common.cake +++ b/common.cake @@ -563,9 +563,10 @@ void BuildXcodeXcframework (FilePath xcodeProject, PodSpec [] podSpecs, Platform var target = podSpec.TargetName; var buildDirectory = workingDirectory.Combine (podSpec.FrameworkName); + var xcframeworkPath = workingDirectory.Combine ($"{podSpec.FrameworkName}.xcframework"); var xcodeBuildArgs = new ProcessArgumentBuilder(); xcodeBuildArgs.Append ("-create-xcframework"); - xcodeBuildArgs.Append($"-output {workingDirectory}/{podSpec.FrameworkName}.xcframework"); + xcodeBuildArgs.Append($"-output {xcframeworkPath}"); foreach (var platform in platforms) { Information ($"Building {podSpec.FrameworkName} framework with {platform.Sdk} platform SDK..."); @@ -624,6 +625,12 @@ void BuildXcodeXcframework (FilePath xcodeProject, PodSpec [] podSpecs, Platform } Information ($"Building {podSpec.FrameworkName} xcframework..."); + + // xcodebuild -create-xcframework fails when its output path already exists, + // so drop the xcframework left behind by any previous run. + if (DirectoryExists (xcframeworkPath)) + DeleteDirectory (xcframeworkPath, new DeleteDirectorySettings { Recursive = true, Force = true }); + ThrowIfProcessFailed ("xcodebuild -create-xcframework", StartProcess ("xcodebuild", new ProcessSettings { Arguments = xcodeBuildArgs })); } }