Hi, I have a cocoa pod made of KMM library, hosted...
# multiplatform
s
Hi, I have a cocoa pod made of KMM library, hosted on private repo, and it installs successfully. The problem is I can only run it on real device, not on simulator. I am using M1 Pro machine. I found that I need to put
iosSimulatorArm64
in
build.gradle.kts
but it didnt help. I am getting these kind of errors:
Copy code
Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_CLWorkerType", referenced from:
      objc-class-ref in WorkerListViewController.o
due to
Copy code
Undefined symbols for architecture x86_64
a
Kindly share your
build.gradle.kts
m
Given the error states that x86_64 is missing i think
iosX64
is the architecure you need to add. Edit: Missed that you have a M1 Pro, so i don’t think my answer applies
s
here it is @ayodele
s
Can you share a Screenshot of your Xcode Build Settings with the Architectures Settings?
If you can run it on a real Device but not on a Simulator on an M1 Mac then it must be something with your Build Settings.
l
Even though you're running on an M1, the simulator can still run x86 under certain conditions. Check your excluded architectures in build settings. If arm64 is there, the app is building for x86
You can also start the simulator and check the cpu type in activity monitor.
s
@Landry Norris @Sebastian Muggelberg Here is the architecture stuff from Build Settings:
s
You have to remove
arm64
from the excluded architectures then it will work
l
Alternatively you can add iosX64 to your build gradle to compile the kotlin module for x86 simulators.
s
Ok, tnx, I will try. Do I also need to remove this from my Podfile?
s
Yes. Seems like this is the “root” problem.
s
Unfortunately removing arm64 didnt help. I am facing the same 49 errors related to OBJC_CLASS again. I am now pretty sure that the problem is way I created this framework…
l
Is there any chance this project is on GitHub?
s
yes it is, but private
is there any way to create the Xcframework with GUI or something.
xcodebuild archive
commands creates wrong frameworks for me. It created framework related to
spec.dependency 'SQLCipher', '4.5.2'
which is in my Podspec, but not the framework itself.
t
Workaround is to run Xcode under Rosetta which then uses the x64 simulator. Slower, but at least you can run with the existing framework.
s
that hack with Rosetta also doesnt help
k
Your build and config is rather complicated. I don’t know why you’re running the sync tasks for fat frameworks, or
xcodebuild archive
. In theory, you can just build the XCFramework zip (You have
XCFramework()
in the code). Also, you are declaring each framework architecture twice, as you have the cocoapods plugin and you’re explicitly declaring framework binaries. That will very likely mess with the build on some level. It’s possible you’re avoiding that by calling specific tasks, but still (description of the issue: https://touchlab.github.io/KMMBridge/TROUBLESHOOTING).
We published a library designed for private (and public) KMP iOS framework publishing if you want to check it out. For CocoaPods and SPM. https://touchlab.github.io/KMMBridge/intro. Docs are getting an update (today-ish). I would stick to this (https://touchlab.co/quick-start-with-kmmbridge-1-hour-tutorial/) until that update happens (look for 0.3.2 release, currently 0.3.1)
t
Also, I asked this during your KMM talk - did you ever figure out how to create a combined Binary+Source XCFramework? That is, the binary kmm module plus some common Swift wrappers to make it easier for clients to use it?
s
thanks @kpgalligan, can you please explain this:
Copy code
In theory, you can just build the XCFramework zip (You have XCFramework() in the code)
I think I did this way already. After successful running of the app, I have opened in finder the .framework file and zipped it, then pushed it to the private repo - is that what you mean? However, if I do it this way it would work only on real device if the app was ran on real device, and it would work only on simulator if framework was created while app was running on simulator.