Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions Sources/SWBCore/XCFramework.swift
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,17 @@ extension XCFramework.Library {

extension XCFramework {
/// Determines the location that the processed xcframework output should go to.
public static func computeOutputDirectory(_ scope: MacroEvaluationScope) -> Path {
///
/// The output directory includes a subdirectory named after the xcframework to ensure
/// that multiple xcframeworks containing libraries with the same name don't conflict.
/// For example, `Sentry.xcframework` outputs to `build/Debug/Sentry/` while
/// `Sentry-Dynamic.xcframework` outputs to `build/Debug/Sentry-Dynamic/`.
///
/// - Parameters:
/// - scope: The macro evaluation scope for build settings.
/// - xcframeworkPath: Path to the xcframework, used to derive the output subdirectory name.
/// - Returns: The path where the xcframework's library should be copied to.
public static func computeOutputDirectory(_ scope: MacroEvaluationScope, xcframeworkPath: Path) -> Path {

let subfolder: Path
if scope.evaluate(BuiltinMacros.DEPLOYMENT_LOCATION) {
Expand All @@ -677,8 +687,8 @@ extension XCFramework {
subfolder = scope.unmodifiedTargetBuildDir
}

// Trim any trailing slashes, as the result is directly combined in spec files.
return subfolder.withoutTrailingSlash()
let xcframeworkName = xcframeworkPath.basenameWithoutSuffix
return subfolder.join(xcframeworkName).withoutTrailingSlash()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ package final class SourcesTaskProducer: FilesBasedBuildPhaseTaskProducerBase, F
return nil
}

let outputPath = XCFramework.computeOutputDirectory(scope)
let outputPath = XCFramework.computeOutputDirectory(scope, xcframeworkPath: xcframeworkPath)
let libraryTargetPath = outputPath.join(library.libraryPath)

// Check if the architectures provided by the xcframework have at least all of the ones we're building for, but only emit a note if this isn't the case since it may still be link-compatible. In future this could be made an error if we can confidently replicate the linker's rules on what architectures are link-compatible (CompatibilityArchitectures is NOT necessarily 1:1 with those rules).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ final class XCFrameworkTaskProducer: StandardTaskProducer, TaskProducer {
return nil
}

let outputDirectory = XCFramework.computeOutputDirectory(context.settings.globalScope)
let outputDirectory = XCFramework.computeOutputDirectory(context.settings.globalScope, xcframeworkPath: xcframeworkPath)

return (library, outputDirectory)
}
Expand Down
Loading