-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate Kotlin and Swift at the same time as generating TS/C++ #149
Comments
I believe you can run the bindings at the same time, though I do not know if they share the process state or not (I would assume they would, but I'm just not sure since it hasn't been our need). Our app uses the Swift bindings in our NotificationExtension and the typescript bindings in the foreground app. They both share the same data store (sqlite) for coordination. |
Interesting. Eyeballing the code, I was under the impression that just generating the extra bindings was necessary but not sufficient for running in the same process. I am expecting that this would require changes to how callback interfaces work. Still, that is for another issue :) |
Don't app extensions on iOS run in their own process (and with limited system resources) anyway? From what I know they can only share certain storage locations with the main app but not the same system process. |
Yes that's correct about extensions, they are isolated and only share storage and keychain access. But theoretically you could have swift code and react native code in the library both talking to the same binary. Not sure if it's a large use case though? |
Oh, I see what you mean now. Hm, yeah I suppose there could be a use case when you want to combine the bindings with some native APIs without having to poke out to TS and back in to another library. |
I recently got to the point where I needed to use matrix-rust-sdk in an iOS Notification Service Extension (NSE). Generating the Swift bindings with slight adaptions to https://github.com/matrix-org/matrix-rust-sdk/blob/main/xtask/src/swift.rs#L212 and some help from @zzorba wasn't complicated. The headers and (consolidated) module map need to be included in the xcframework that UBRN created. The Swift files and the xcframework can then be included in the NSE. The only other thing I had to do was
To get this into UBRN, we'd have to make it call uniffi-rs to generate the headers, module map and Swift files and then move these files around accordingly. For a library created with UBRN, I don't think we'd want the Swift files to be included in its pod. The latter depends on further RN libs which would be inconvenient to include in an app extension because it is subject to resource limits. Maybe we could generate a second pod for holding just the Swift files? Consumers would then link the main pod into their main app and the other pod (plus the xcframework from the main pod) into their extension. Alternatively it might be possible to consume the Swift files from |
@jhugman I'm curious about your thoughts on how to best integrate this into ubrn, starting with the Swift side. We could just call The build command currently has a Alternatively we could also reassemble the framework during |
Hmm. I hadn't thought much about when to generate this. I had thought that we should have a If we need to generate Swift before the xframework is made— are we going to have to invoke a swift compiler? I think my preference would be to generate the swift as part of the build, rather than moving the lipo/xcodebuild part to the If not that, then adding another This new task would be run as part of What do you think? |
No, I don't think so. It's basically all done by
Ok, let me try it like this because I think it'll also be less changes than the other option. If needed, we can always consider rearranging the steps later. |
@zzorba has been asking for this for a lilttle while.
While the main React Native app requires typescript and C++, iOS extensions still require Swift.
Can we generate the Swift from the Rust at the same time as generating the Typescript and C++?
This issue just covers the generating and building of the Kotlin and Swift generation.
@almost adds this question: can we run the Kotlin and Swift bindings at the same time as the Typescript? This enables a host of new capabilities.
The text was updated successfully, but these errors were encountered: