Hi! According to the Swift Export documentation, d...
# swift-export
p
Hi! According to the Swift Export documentation, direct integration is only supported and not remote integration (publishing an XCFramework). Is there a ticket that I can follow for remote integration? We are working on an SDK that is shared across multiple projects and we need to be able to publish it to a repository before we can migrate to Swift Export.
r
I don't know the status of remote integration, but one workaround might be to publish the shared module as a klib, and then have each of the consuming projects configure Swift Export separately.
p
Thank you! We want to export it to the iOS devs so they don't even have to know that it's KMP. They won't be messing with the Kotlin code at all (in 99% of the cases). By "configure Swift Export separately", do you mean that we'd need a parent KMP project and then put the iOS application inside it? That's not gonna be a very popular solution... Would it be possible to just publish an XCFramework from XCode from an empty iOS project/library that "wraps" the KMP SDK using direction integration? (I'm no iOS dev btw). I remember that I read somewhere that there's no
api
equivalent in SPM/whatever as we have in gradle so maybe that wouldn't work πŸ€”
r
What I was picturing was each application has a thin KMP project that just configures swift export for that ap. Obviously not ideal, but maybe it works as a stopgap. But maybe that wouldn't work for you if your iOS apps don't want to have to do that configuration.
I'm not sure whether you could publish an XCFramework as you describe. Give it a try and see, I guess.
p
Okay, I think I know what you mean. You place a tiny KMP project like next to or inside your main project that just exposes the SDK using
api
and
export
and then you use direct integration with that. That could actually work decently and if it's committed into the iOS app project it should be fine. But then versioning would be done in that KMP project which is alright. I just hope built times will be good. I'd still love to know if there's a ticket that I can follow though πŸ™Œ
j
I was able to generate a XCFramework from my KMP Library which I was then able to upload to GitHub and make available as a SPM dependency.
p
Cool! Is your library open source? And I assume that it's using Swift Export? Did you need to do some hacking to get it to work?
j
My library is open source. It doesn't yet use Swift Export. It uses SKIE to introduce "Swift-like" ergonomics. The only "hacking" I had to do was configure SKIE appropriately then create gradle tasks that would generate the .XCFrameworks and copy them to the SPM repo so that I can upload them to Github.
p
I see. The question was specifically about Swift Export but thanks for trying to help! I already got SKIE to work with external publishing πŸ‘
a
Hello there πŸ™‚
Is there a ticket that I can follow for remote integration?
Yes - https://youtrack.jetbrains.com/issue/KT-78747
By "configure Swift Export separately", do you mean that we'd need a parent KMP project and then put the iOS application inside it?
I would say that "remote integration" scenario(publishing an xcframework) provides you and your colleagues a subpar experience 1. you have to build a release build of kotlin on every commit. That's a heavy operation that has to rebuild the whole world and that has to be published and managed. 2. That in turn blocks you from building kotlin native in debug mode - blocking your project from using incremental builds and build caches - increasing your kotlin native build times. 3. As a sideeffect of having a separate repo that contains umbrella module - effectively you have moved a "lock file" of all your kotlin dependencies to a separate repo. This forces your iOS devs to update all the dependencies at once, and that in turn makes them suffer - gradual updates are much easier to handle, compared to "let's update the whole world" We have a demo how to setup "umbrella only" on the side of iOS, which covers the exact usecase you describe - iOS devs that don't want to touch kotlin code. Note that it reuses one repo only for demo - the android part actually does a publication to mavenLocal and iOS part reads mavenLocal. nowadays macos comes with jvm already so your iOS devs should not really notice the difference, except for the first build πŸ™‚
Would it be possible to just publish an XCFramework from XCode from an empty iOS project/library that "wraps" the KMP SDK using direction integration? (I'm no iOS dev btw).
Not sure about that, but one can look into a build folder of swift export task and find a swift PM generated package there already πŸ™‚ We never tested if it's publishable, but one can try and hack the reuse of this generation if they really need it. (not a recommended way there is would be no support for that from our side and we do not guaratee compatibility with future releases) Or wait for an official support πŸ™‚ (recommended approach)
p
Hi @Artem Olkov, thank you for your answer! I will ponder your suggestions and discuss it with the team next time the subject comes up. It challenges our current plan, likely for the better! Since you're saying that local integration is the better choice in general I'm assuming that you won't commit to SPM support any time soon?
I don't think that java/JVM is preinstalled on macOS though πŸ€” Can't find anything that confirms that
a
I'm assuming that you won't commit to SPM support any time soon?
We do not have a public timeline on that feature, yes πŸ™‚
I don't think that java/JVM is preinstalled on macOS though
I just checked - and yes, my mistake. After some googling I feel like i've hallucinated that myself. Anyway, modern java stack on macOS can be managed quite easily nowadays πŸ™‚
p
Understandable! I really enjoy following the progress on Swift export πŸ™Œ No worries at all. Its very easy to install a JVM.
kodee happy 1
@Artem Olkov I talked with my iOS colleague and he says that they just moved away from XCode dependencies and that they only want Swift packages. Will Swift Export remote integration also have good UX when it comes out or will it always remain inferior to local integration? Is the most pragmatic way forward to convince them to add the build step despite their practices?
a
Remote integration forces a setup where on every commit into KMP repo the CI needs to build a release binary - with all the problems of that. We use xcodes build phase as a way to integrate two different build systems - there is no other way to send "build" command to gradle. SPM sadly does not provide a way for us to seamlessly integrate into it πŸ™‚ When the remote integration will be done - the DX should be similar to the one available today with objective-c export and it's remote integration. No promises thou, as the design for that feature is not final πŸ™‚ > Is the most pragmatic way forward to convince them to add the build step despite their practices? Well sadly, there is no perfect solution. Having a remote integration is an understandable desire, as long as the problems of this approach(including an unknown wait time for swift export) are understood and accepted. Forcing colleagues to do anything also is not a best practice, TBH πŸ™‚ Setting interpersonal relations aside - migrating to a local integration also can take some time and bring up unexpected problems.. My personal opinion is that remote integration will always provide a suboptimal experience and enforces an org divide in mobile dev team. I personally think that relying on local integration is a better choice in general. But i cannot honestly recommend it blindly to everybody without knowing the nuances of their org structure (and I'm also not the one who will have to live with the consequences of that decision also) πŸ™‚
❀️ 1
βž• 1
p
Thank you Artem. We will have a proper discussion about this, weighing all the pros and cons. Really appreciate your responses!
kodee intensifies 1
🀞 1
a
Projects like ours, which is being developed for more than 8 years and have a larger codebase for both OSs, is difficult to introduce direct integration. After longer discussion and various steps with various stack holders, we finally got green signal for migrating only just API layer into KMP for now. Our iOS engineers didn't welcomed the KMP integration from their heart, so any additional step in iOS side just for KMP will likely be rejected by them. So, we need to maintain the API layer KMP module just a remote SPM package like other SPM packages. They even didn't allowed us to initialize KMP package (for Koin dependency, CrashKiOS etc.) in AppDelegate as it's API module so have to initialize in data module (inside repository). So, now we have to check and call initialization in every repository that uses KMP module. So, even if we wanted it very much, we cannot use swift-export due to direct integration constraint. It would be grate if KMP team introduces it with higher priority (so that complains against KMP by iOS engineers reduces). We could use SKIE but that would increase the size of our framework by 9MB, so we had to drop SKIE too.
thank you color 2