Hi everyone, I have a somewhat strange problem: up...
# kotlin-native
u
Hi everyone, I have a somewhat strange problem: up until now I’ve used the cocoapods plugin in combination with
isStatic = true
to integrate our shared module into the iOS app. However, I now have to make shared dynamic due to some third party library issue which can only be worked around with that due to this Kotlin native issue: https://youtrack.jetbrains.com/issue/KT-50982#focus=Comments-27-5741956.0-0 Apart from that, it seems that using dynamic frameworks is the preferred way anyway, so I am generally fine with that workaround:
Copy code
cocoapods {
        ios.deploymentTarget = "14.1"

        framework {
            summary = "Shared Module"
            baseName = "shared"
            isStatic = false
            embedBitcode(BITCODE)
            podfile = project.file("../iosApp/Podfile")
        }
    }
All is good and well and the app builds as it should until I try to export the archive which now fails with the following error message:
Copy code
shared not found in dylib search path
Any idea what I might need to change to make this work?
Interestingly I found that the
bitcode-build-tool
arguments didn’t have the shared framework as an argument 🤔 (I am using bitrise for building btw).
k
Apart from that, it seems that using dynamic frameworks is the preferred way anyway
I wouldn’t generally assume this. I default to static, and I would say in general iOS app dev, it’s far from a “most teams recommend this” situation. I know that doesn’t help with your current situation, and I wouldn’t say you should avoid dynamic, but I would definitely not call it “preferred” either
Haven’t seen that issue, but very not excited about that. 1.7 is a bit down the road. Ugh, but OK.
u
Yeah, the issue is a problem, but I also just encountered it for that one library (OneSignal) to be fair. Regarding “preferred” - I am not an iOS Pro, so that might be just me in my little bubble having read about dynamic frameworks more often than not and thus misinterpreting the state of things. 😅
In the meantime I think I got closer to the issue by trying to get archive to work locally on my machine. I stumbled on one thing there (which funny enough doesn’t seem to happen on CI). Archive doesn’t work here at all, I’m running into the following:
Copy code
ld: warning: directory not found for option '-F/Users/ubuntudroid/Library/Developer/Xcode/DerivedData/MyApp-exiyzzachjfrvmbualscrdesogez/Build/Intermediates.noindex/ArchiveIntermediates/MyApp-Debug/BuildProductsPath/Release-iphoneos'
ld: bitcode bundle could not be generated because '/Users/ubuntudroid/projects/github/ubuntudroid/myApp/shared/build/cocoapods/framework/shared.framework/shared' was built without full bitcode. All frameworks and dylibs for bitcode must be generated from Xcode Archive or Install build file '/Users/ubuntudroid/projects/github/ubuntudroid/myApp/shared/build/cocoapods/framework/shared.framework/shared' for architecture arm64
The first warning might be caused by using non-default schemes/configurations (MyApp-Debug/MyApp-Stage/MyApp) - but I am not sure whether it is actually a problem. The second error seems to be more problematic. However, I don’t know why I am even getting this, because as you can see in my first post bitcode embedding is enabled. 🤔
k
On static/dynamic, I’m not an expert either (well, I guess my expertise is very siloed, but on the tradeoffs between static/dynamic, I’m more “mid level”). I tend to agree with this, though. Static linking has faster loading and (potentially) smaller binary, so without a reasonable argument to the contrary, I prefer static (https://bpoplauschi.github.io/2021/10/25/Advanced-static-vs-dynamic-libraries-and-frameworks.html). I believe SwiftUI updates needed dynamic, which kind of makes sense (although I’m not sure if that’s true anymore). At one point we couldn’t get Xcode to debug static Kotlin frameworks, but that’s also not true anymore (or last time I checked, anyway).
u
Sounds reasonable, but then again, as you already pointed out: I don’t really have a choice right now. 😉
s
Another non ios dev chiming in: I couldn't export an ios archive of our app after we switched to embedandsign... I had to switch to dynamic due to some signing issue. The only reason I was static linking was for sqldelight/sqlite3, which i though preferred it. Everything seems to work so far so I wont worry about it for now. Will be keeping an eye on that youtrack issue and this thread though...