Skip to content

Add Swift UIKit utils cinterop support for iOS#3233

Merged
Vendula Švastalová (svastven) merged 7 commits into
jb-mainfrom
svastven/CMP-10440
Jul 20, 2026
Merged

Add Swift UIKit utils cinterop support for iOS#3233
Vendula Švastalová (svastven) merged 7 commits into
jb-mainfrom
svastven/CMP-10440

Conversation

@svastven

Copy link
Copy Markdown

Adds a separate CMPUIKitSwiftUtils static library alongside the existing Objective-C CMPUIKitUtils library, so Swift-only iOS APIs can be exposed to Kotlin/Native through an Objective-C-compatible generated Swift header.

Fixes CMP-10497 [iOS] Add Swift UIKit utils cinterop support

Release Notes

N/A

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

IMO we can rename this target to CMPUIKitObjcUtils

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Let's rename it right away!

Comment thread compose/ui/ui-uikit/build.gradle

@ASalavei Andrei Salavei (ASalavei) Jul 20, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

TBH, I would love to see at least one simple swift class + simple Kotlin test to ensure the interop works.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

test added to iosTest

@ASalavei

Copy link
Copy Markdown

Vendula Švastalová (@svastven) , could you please also verify (or confirm that you did it) that compose is still compiles and can be used is CMP project. To verify so, you need:

  • Create Swift class in the CMPUIKitSwiftUtils
  • Use it somewhere from Kotlin (like `ComposeSceneMediator)
  • Publish Compose to maven local
  • Use this version of Compose from the CMP project from Wizard.

@svastven

Copy link
Copy Markdown
Author

Andrei Salavei (@ASalavei) I have confirmed that using Swift class from CMPUIKitSwiftUtils inside Kotlin works - I have tried in ComposeSceneMediator. I have not tried to publish and use it in a new project. I can check that.

@ASalavei

Andrei Salavei (ASalavei) commented Jul 20, 2026

Copy link
Copy Markdown

Andrei Salavei (Andrei Salavei (@ASalavei)) I have confirmed that using Swift class from CMPUIKitSwiftUtils inside Kotlin works - I have tried in ComposeSceneMediator. I have not tried to publish and use it in a new project. I can check that.

Yes please check that. Need to ensure that all required compiler/linker flags correctly propagated to the final user's projects. Would be great to test that project with Debug mode runns on simulator/device as well as Archive project for iOS device target.

@svastven

Vendula Švastalová (svastven) commented Jul 20, 2026

Copy link
Copy Markdown
Author

Need to ensure that all required compiler/linker flags correctly propagated to the final user's projects. Would be great to test that project with Debug mode runns on simulator/device as well as Archive project for iOS device target.

I published a dev Maven build with temporary test logging added in ComposeSceneMediator.init

val box = CMPUIKitSwiftInteropBox(seed = 7)
val interop: CMPUIKitSwiftInteropProtocol = box
println("CMPUIKitSwiftInterop: ${interop.seed()}, ${box.seed()}")
println("CMPUIKitSwiftInterop: ${interop.combinedValueWithSuffix("swift")}, ${box.combinedValueWithSuffix("kotlin")}")

, which uses types from CMPUIKitSwiftUtils (similar to the test in this PR swiftImplementationIsAvailableThroughObjcInterop). I then integrated this build in a newly generated app from Wizard. I validated that the app was built successfully, launched successfully, and emitted the expected logs. This should confirm that the required compiler/linker flags are propagated to the final consumer project. Archive was also successful.

@igordmn

Copy link
Copy Markdown
Collaborator

Vendula Švastalová (svastven) requested a review from Igor Demin (igordmn) 21 minutes ago

The build changes LGTM. If you don't need from me to look at the rest of the code, it is good to merge

@svastven
Vendula Švastalová (svastven) merged commit 4807235 into jb-main Jul 20, 2026
21 checks passed
@svastven
Vendula Švastalová (svastven) deleted the svastven/CMP-10440 branch July 20, 2026 19:12
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.

3 participants