Hey all, could somebody assist me with running my ...
# multiplatform
a
Hey all, could somebody assist me with running my Multiplatform app on an actual iPad? It seems to run using the simulator, but I keep getting this: ld: framework not found Pods_iosApp clang: error: linker command failed with exit code 1 (use -v to see invocation) When I try to build in xcode
k
You should post your config. It seems possible you’re not building the architecture you need, or that architecture is not getting packaged correctly, but there’s a whole bunch of possible reasons why it won’t work on a real device.
a
What config do you need? build.gradle?
My understanding is that I should just be able to run the app straight from Xcode or Android studio no problem, without having to run buildForXcode anymore, but maybe I'm mistaken
k
We mostly use cocoapods or spm to include frameworks, so somebody with more experience with that direct integration method would need to comment here. You should be able to run the app from Xcode (I don’t use the AS plugin as regularly myself, but that should work too).
However, the more you can post the better (as far as config). Ideally a repo with the project. Otherwise debugging is rough, unless the cause is really obvious.
a
We have cocoapods integrated actually. I was able to run the app but only from Simulator. Real device doesn't work. I was working on integrating SQLDelight and it wasn't working until I added -lsqlite3 to the 'Other Linker Flags' section in Xcode. Not sure if that is normal to do if your using Cocoapods or not?
Like right now I just ran it from AS no problem but on the simulator. I tried to run it in Xcode on simulator and got: ld: framework not found Pods_iosApp
Ld /Users/andrew.ohart/Library/Developer/Xcode/DerivedData/iosApp-ebwyujdebfckhnclltfacayolifx/Build/Products/Debug-iphonesimulator/iosApp.app/iosApp normal (in target 'iosApp' from project 'iosApp')
k
Well, I wrote the driver for that, and updated the issue talking about it recently: https://github.com/cashapp/sqldelight/issues/1442#issuecomment-1048131450. Summary, yes. The linker needs to have an implementation of sqlite it can link against. How it gets added varies.
It isn’t weird to add it directly in Xcode, but there are situation where it may be carried over from cocoapods instead.
a
Oh yeah thats where I seen the solution actually, didn't realise it was you haha, so thanks for the solution for that!
k
“framework not found” may be the weird double-tap cocoapods thing. Run pod install, try to run the app (fail), run pod install again, then run the app again. It may be that, but hard to say for sure. It’s a long standing issue, and I’m not sure what the cause of fix is.
a
So you mentioned the issue has '
Copy code
Reason: image not found
I did see that when I updated my xcode with the examples from the gradle plugin thing I posted above. So your saying maybe I just need to run pod install ?
k
You may need to run it twice, actually.
Run that, try to run the app, then run pod install again.
Generally speaking, when things go bad, I delete the
Pods
folder and run
pod install
a
Thanks, I'll try that. Small question, in your XCode, in Framework Search Paths, do you have "${PODS_ROOT}/../../shared/build/cocoapods/framework"
We have that at the moment, but from this integration: https://github.com/Kotlin/kmm-integration-sample/commit/c23a52feabe4e95262d53f6a0245b0bde7652111 It looks like they don't have it but use "$(SRCROOT)/../shared/build/xcode-frameworks/$(CONFIGURATION)/$(SDK_NAME)"; instead
k
Generally speaking, if you’re using cocoapods to pull in kotlin, don’t touch the framework search paths (again, generally speaking).
I’ll look, though..
Cocoapods is weird, though. It creates it’s own target project with a framework wrapping all of the other frameworks, and includes it differently than just directly adding a framework. It’s complicated to configure manually, but generally you don’t need to (that’s kind of the tradeoff)
a
I see, I really have no experience with Cocoapods since I've been an Android developer for years, only dipping into it now because I'm working on KMM in work. When you say you generally delete the Pods folder, you mean the Pods folder that you see in the Xcode sidebar, with the schema folder and Products and frameworks folders too?
k
a
Ok sweet I can leave that the same then. Have you personally done the setup for embedAndSignAppleFrameworkForXcode ?
k
I see, I really have no experience with Cocoapods since I’ve been an Android developer for years, only dipping into it now because I’m working on KMM in work.
This is a major internal training issue we have. We recruit most people from the Android side, and very few have significant iOS toolchain experience. I spent years doing J2objc before KMP/M, so I was like extra ready for this.
a
Yeah same here, we are hiring people and looking to take on people with Android experience first even though will be working on KMM
k
When you say you generally delete the Pods folder, you mean the Pods folder that you see in the Xcode sidebar, with the schema folder and Products and frameworks folders too?
I would not delete things in xcode. It’s weird. In the file system, wherever you have the
Podfile
there will be a folder that cocoapods adds called
Pods
. that’s where it does it’s work. Delete that (and just that), in the file system navigator (or from AS, or the terminal, just not from Xcode).
a
Ah yeah I was looking at that just there and thought maybe that makes more sense
Going to build now
k
Have you personally done the setup for embedAndSignAppleFrameworkForXcode
Maybe once, but not really. I’m currently doing optimized XCFramework publishing in CI to be consumed by cocoapods and SPM. I probably wouldn’t recommend anybody do direct framework integration (although some teams want it, so the Kotlin team needs to support both).
a
So I deleted and did pod install, tried to run xcode but it can't find the library now. With KMM are you supposed to try and build on android first or something to generate the shared lib for ios? This is something that confuses me
k
Run pod install again, and try to run again. That’s the double thing I was talking about. Ironically, I almost never run the android side now because all of my work is packaging for iOS
a
it ran from AS no problem on simulator, but still fails in xcode, very odd
k
Huh. dumb question, but did you open the workspace or the project file?
In Xcode I mean
a
Xcode I opened xcodeproj
k
Ah, no. That’s a cocoapods thing. Look for *.xcworkspace and open that
a
Ok, opened it now, but I can't seem to build, no Scheme, and I don't see any iosApp classes, just all the Pods stuff
k
Screenshot? I think going through the cocoapods tutorial (no kotlin) would be useful. Debugging otherwise will probably be difficult.
All the scheme stuff is getting into the Xcode weeds, so no comment on that.
a
k
What’s the Podfile look like?
a
In general when I do the UI side of stuff I use the xcodeproj, This is what the xcodeproj looks like for me
Podfile looks like this
k
Weird that the workspace shows that. I don’t know anybody that opens the
xcodeproj
directly with cocoapods. You’re really only supposed to use the workspace.
Not to push our own thing, but if you want to see what it’s supposed to look like, clone and run this: https://github.com/touchlab/KaMPKit
Docs need a refresh, but open
KaMPKitiOS.xcworkspace
in Xcode (from the
ios
folder). If you’re lucky, you won’t even need to run
pod install
. We put the
Pods
folder into github to make it easy, but generally I wouldn’t check that into source for a real project.
a
Oh I'm well aware of KaMPKit, helped me so much when trying to figure out sqldelight and sqlcipher stuff, I believe we talked about that before 😄
k
Ah, OK!
a
Yeah i'm taking a look at it here, it looks like the xcodeproj has the iOS UI stuff, you can't access that from the xcworkspace ?
k
I was just saying “I don’t know”, but I do. Make sure you close the Xcode that has iosApp
If it’s currently open in another Xcode window, I don’t think it’ll show it.
So, kill Xcode completely, then open just the workspace in Xcode.
a
oh yeah your dead right, just did that and now i can see that, its probably why my app didnt show it
yep, can see the ios stuff now in my app. will try build again
Hmm I got a 'cannot install' error. Says this is the issue: Unable to install "iosApp" Domain: com.apple.dt.MobileDeviceErrorDomain Code: -402620375 User Info: {   DVTErrorCreationDateKey = "2022-02-23 171519 +0000";   IDERunOperationFailingWorker = IDEInstalliPhoneLauncher; } -- The code signature version is no longer supported. Domain: com.apple.dt.MobileDeviceErrorDomain
one thing after the next 😄
k
Oh. That looks more like a signing issue. That’s in the werid iOS area where you need to have a team and a cert that lets you install on a device, etc. https://developer.apple.com/forums/thread/679182
That’s getting into regular iOS dev hell territory.
😅 1
a
haha lovely, I will contact the admins then and see, its a new app so perhaps hasn't been added to company account. For the linking stuff for sqldelight, would you personally recommend the
-lsqlite3
 to 
Other Liker Flags
 in your 
Bulid Settings
method you mentioned on github?
or by doing it build.gradle?
Also, while were talking here, wondering if you experienced this issue when running iOS tests: This API is only supported for experimental K/N memory model I think some update new experimental coroutine api might of broke it or something, but you seem well versed in KMM so maybe you know
k
I don’t know that I have a recommendation. The build.gradle linker flags may be needed for testing, but I don’t think they get carried over into the podspec. What I usually is try to build and if I get the sqlite link error, I add
-lsqlite3
to Xcode. Then I forget about it entirely 🙂
KaMP Kit has it in there manually, for example
Some of that is added by cocoapods (the
-Objc
, for example), but not the sqlite3. So, I guess I’d say add it in Xcode. If you don’t need it, it should be ignored (unless you’re using sqlciper, then definitely do not do that).
a
Ah I see, your a good man Kevin thanks for the help! hopefully it all works once I get the admins to update the certs!
Might be back here tomorrow if it doesn't work 😄
k
Good luck!
a
Also, I remember when were talking about SQLCipher you said you'd like to learn of any findings, I wrote a medium article on it if it interests you: https://medium.com/@andyohart/kotlin-multiplatform-static-library-without-cocoapods-5b728449ec3e Writing one about the migration process also
I know this use case was fairly specific because we wanted to not use cocoapods, so this is what worked for us
k
Interesting. I’ll take a look. Thanks.
a
No worries, cheers
869 Views