apple / apple/swift-async-algorithms

Archive Fails When Building XCFramework from Swift Package when using swift-async-algorithms

Open
#376 2 comments 4 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
3.7k
Forks
226
Avg merge
10d 3h
Merged PRs (30d)
1

Description

We have a Swift package that consumes the swift-async-algorithms package, and it works as expected in Xcode. We are trying to generate an XCFramework(Swift Package) for Objective-C bridging. While the build process in Xcode works without issues, the archive process via xcodebuild fails with multiple errors.

**Steps to Reproduce:**

1. Create a Swift package that depends on swift-async-algorithms.
2. Open the package in Xcode and verify that it builds successfully.
3. Run the following xcodebuild command to archive and create an XCFramework:

`xcodebuild -project "Library.xcodeproj" archive \
-scheme "Library" \
-configuration Release \
-archivePath "build/Library-ios.xcarchive" \
-destination "generic/platform=iOS" \
-derivedDataPath "build" \
-IDECustomBuildProductsPath="" \
-IDECustomBuildIntermediatesPath="" \
ENABLE_BITCODE=NO \
SKIP_INSTALL=NO \
BUILD_LIBRARY_FOR_DISTRIBUTION=YES`

4. Observe the errors during the xcodebuild archive step.

**Expected Behavior:**

The Swift package should be successfully archived, allowing us to generate the XCFramework for use in Objective-C projects.

**Actual Behavior:**

The following errors occur during the archive step:

`EmitSwiftModule normal arm64 (in target 'InternalCollectionsUtilities' from project 'swift-collections')
cd ....

/....Sources/InternalCollectionsUtilities/autogenerated/LifetimeOverride.swift:107:6: error: a function cannot return a ~Escapable result
) -> T {
^
/....Sources/InternalCollectionsUtilities/autogenerated/LifetimeOverride.swift:104:2: error: '@_lifetime' attribute is only valid when experimental feature Lifetimes is enabled
@_lifetime(immortal)
^
/....Sources/InternalCollectionsUtilities/autogenerated/LifetimeOverride.swift:125:6: error: a function cannot return a ~Escapable result
) -> T {
^
/....Sources/InternalCollectionsUtilities/autogenerated/LifetimeOverride.swift:120:2: error: '@_lifetime' attribute is only valid when experimental feature Lifetimes is enabled
@_lifetime(borrow source)
^
/....Sources/InternalCollectionsUtilities/autogenerated/LifetimeOverride.swift:143:6: error: a function cannot return a ~Escapable result
) -> T {
^
/....Sources/InternalCollectionsUtilities/autogenerated/LifetimeOverride.swift:138:2: error: '@_lifetime' attribute is only valid when experimental feature Lifetimes is enabled
@_lifetime(copy source)
^
/....Sources/InternalCollectionsUtilities/autogenerated/LifetimeOverride.swift:163:6: error: a function cannot return a ~Escapable result
) -> T {
^
/....Sources/InternalCollectionsUtilities/autogenerated/LifetimeOverride.swift:162:12: error: a function cannot have a ~Escapable 'inout' parameter 'source' in addition to other ~Escapable parameters
mutating source: inout U
^
/....Sources/InternalCollectionsUtilities/autogenerated/UnsafeMutableBufferPointer+Extras.swift:412:49: error: 'Span' is only available in iOS 12.2 or newer
public func _initializePrefix(copying source: Span) -> Int {
^
/....Sources/InternalCollectionsUtilities/autogenerated/UnsafeMutableBufferPointer+Extras.swift:412:15: note: add '@available' attribute to enclosing instance method
public func _initializePrefix(copying source: Span) -> Int {
^
/....Sources/InternalCollectionsUtilities/autogenerated/UnsafeMutableBufferPointer+Extras.swift:374:1: note: add '@available' attribute to enclosing extension
extension UnsafeMutableBufferPointer {
^
/....Sources/InternalCollectionsUtilities/autogenerated/UnsafeMutableBufferPointer+Extras.swift:442:63: error: 'Span' is only available in iOS 12.2 or newer
public mutating func _initializeAndDropPrefix(copying span: Span) {
^
/....Sources/InternalCollectionsUtilities/autogenerated/UnsafeMutableBufferPointer+Extras.swift:442:24: note: add '@available' attribute to enclosing instance method
public mutating func _initializeAndDropPrefix(copying span: Span) {
^
/....Sources/InternalCollectionsUtilities/autogenerated/UnsafeMutableBufferPointer+Extras.swift:374:1: note: add '@available' attribute to enclosing extension
extension UnsafeMutableBufferPointer {
^
/....Sources/InternalCollectionsUtilities/autogenerated/UnsafeMutableBufferPointer+Extras.swift:413:12: error: 'withUnsafeBufferPointer' is only available in iOS 12.2 or newer
source.withUnsafeBufferPointer { self._initializePrefix(copying: $0) }
^
/....Sources/InternalCollectionsUtilities/autogenerated/UnsafeMutableBufferPointer+Extras.swift:413:12: note: add 'if #available' version check
source.withUnsafeBufferPointer { self._initializePrefix(copying: $0) }
^
/....Sources/InternalCollectionsUtilities/autogenerated/UnsafeMutableBufferPointer+Extras.swift:412:15: note: add '@available' attribute to enclosing instance method
public func _initializePrefix(copying source: Span) -> Int {
^
/....Sources/InternalCollectionsUtilities/autogenerated/UnsafeMutableBufferPointer+Extras.swift:374:1: note: add '@available' attribute to enclosing extension
extension UnsafeMutableBufferPointer {
`

**Environment:**
Xcode version: 26.x
Swift version: 5, 6
Platform(s): iOS
swift-async-algorithms version: latest
Additional Context:
We need to archive this package into an XCFramework for Objective-C bridging. The issue only occurs during the archive step and not during the build process within Xcode.

Can you please help us ASAP. 😊

Thanks in advance.

Contributor guide

Open the contributing guide

Research direction

Reproduce the archive with the provided xcodebuild command and inspect the reported failures in swift-collections' autogenerated/LifetimeOverride.swift and autogenerated/UnsafeMutableBufferPointer+Extras.swift. Compare the successful Xcode build with the archive configuration and the swift-async-algorithms dependency setup. Done means the Swift package archives successfully for iOS and can proceed to XCFramework generation.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
build-system, mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.