Skip to content

xtask: Use a single Swift module when building the bindings. - #6388

Merged
Hywan merged 1 commit into
mainfrom
doug/xcode-26.4
Apr 1, 2026
Merged

Hywan merged 1 commit into
mainfrom
doug/xcode-26.4

Conversation

@pixlwave

@pixlwave pixlwave commented Mar 31, 2026 •

Copy link
Copy Markdown
Member

Xcode 26.4 didn't like the modulemap we were generating. It used to look like so:

module matrix_sdkFFI {
    header "matrix_sdkFFI.h"
    export *
    use "Darwin"
    use "_Builtin_stdbool"
    use "_Builtin_stdint"
}

module matrix_sdk_cryptoFFI {
    header "matrix_sdk_cryptoFFI.h"
    export *
    use "Darwin"
    use "_Builtin_stdbool"
    use "_Builtin_stdint"
}

module matrix_sdk_ffiFFI {
    header "matrix_sdk_ffiFFI.h"
    export *
    use "Darwin"
    use "_Builtin_stdbool"
    use "_Builtin_stdint"
}

module matrix_sdk_commonFFI {
    header "matrix_sdk_commonFFI.h"
    export *
    use "Darwin"
    use "_Builtin_stdbool"
    use "_Builtin_stdint"
}

module matrix_sdk_baseFFI {
    header "matrix_sdk_baseFFI.h"
    export *
    use "Darwin"
    use "_Builtin_stdbool"
    use "_Builtin_stdint"
}

module matrix_sdk_uiFFI {
    header "matrix_sdk_uiFFI.h"
    export *
    use "Darwin"
    use "_Builtin_stdbool"
    use "_Builtin_stdint"
}

I think the main issue was that this defines modules that don't match the MatrixSDKFFI name defined by the Package.swift files (SDK / Components). It seems this is now not allowed.

This PR updates the consolidation to a single module containing all of the headers:

module MatrixSDKFFI {
    header "matrix_sdkFFI.h"
    header "matrix_sdk_cryptoFFI.h"
    header "matrix_sdk_ffiFFI.h"
    header "matrix_sdk_commonFFI.h"
    header "matrix_sdk_baseFFI.h"
    header "matrix_sdk_uiFFI.h"
    export *
    use "Darwin"
    use "_Builtin_stdbool"
    use "_Builtin_stdint"
}

To make this work we then need to make sure all the of .swift files import MatrixSDKFFI now instead of whatever their corresponding UniFFI module name was.

Fixes matrix-org/matrix-rust-components-swift#32
Fixes element-hq/element-x-ios#5321

  • I've documented the public API Changes in the appropriate CHANGELOG.md files.
  • This PR was made with the help of AI.

@pixlwave
pixlwave requested a review from a team as a code owner March 31, 2026 18:56
@pixlwave
pixlwave requested review from Hywan and removed request for a team March 31, 2026 18:56
@codecov

codecov Bot commented Mar 31, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.88%. Comparing base (c04a97f) to head (44db10d).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6388      +/-   ##
==========================================
+ Coverage   89.86%   89.88%   +0.02%     
==========================================
  Files         377      377              
  Lines      103167   103167              
  Branches   103167   103167              
==========================================
+ Hits        92710    92734      +24     
+ Misses       6893     6883      -10     
+ Partials     3564     3550      -14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@codspeed

codspeed Bot commented Mar 31, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 50 untouched benchmarks


Comparing doug/xcode-26.4 (44db10d) with main (c04a97f)

Open in CodSpeed

@Hywan Hywan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Thank you for fixing the problem.

Comment thread xtask/src/swift.rs
}

if let Some(last_header_position) = last_header_position {
lines.splice(last_header_position + 1..last_header_position + 1, extra_headers);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice trick to insert a vec in a vec.

@Hywan
Hywan merged commit 4071a55 into main Apr 1, 2026
53 checks passed
@Hywan
Hywan deleted the doug/xcode-26.4 branch April 1, 2026 07:20
lucasfeijo added a commit to lucasfeijo/matrix-rust-components-swift that referenced this pull request Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Building with Xcode 26.4 fails with MatrixRustSDK compilation errors Build issues with Xcode 26.4 beta 1 & 2

2 participants