DEV Community

Lucas Schiavini
Lucas Schiavini

Posted on • Originally published at betterprogramming.pub on

Some Errors I’ve Found Developing With KMM

The list of the ones I solved and the one that still bugs me

So you are trying to code a Kotlin Multiplatform module.

After setting up a build gradle file for the Android project with this new module, you are led to believe that you will:

  • Build on android.
  • Then run pod install to install this new precompiled module into an iOS project.
  • Then you go on Xcode, run build, and everything should work out. Right?

Wrong!

As of today, Kotlin Multiplatform isn’t in Beta yet. So there have been some errors along the way. Here’s some that I’ve found.

MAC Problems with Access

Make sure these Applications have full Access to folders (or at least the folders required by the android and iOS projects):

Terminal, Xcode, Android Studio.

MAC Cannot find PodFile

If you haven’t created one already, one blueprint for one is:

https://medium.com/media/937ac78eadd1ad3cec816488504a6ecd/href

If you have a PodFile already, there’s a few things that can happen:

  • Android Studio can’t find PodFile declared in the build.gradle.kts because it isn’t there.
  • Android Studio doesn’t have permission to search that folder.

Example:

https://medium.com/media/4838ced1357cdf02ca9b793b018de6ac/href

In this case, check if the file exists there and it is the correct path.

Also, check if Android Studio has permission to access that path.

If nothing works you can delete that line declaring the podfile on build.gradle.kts, run pod install manually after you build on android.

MAC M1 Problems

Installing Cocoapods for the M1

Check out this answer:

How to install Cocoapods on Apple Silicon M1 computers? by Nikolay Nikonov

Simulator + M1

If you are on a Mac M1 and are gonna build for the simulator, here’s what you should do.

https://medium.com/media/273fb3549ba005d7420edd7c9302b0ae/href

If you are running with the physical iPhone, no need for Rosetta.

M1 + Room Library

You should change your room dependency value:

From: ext.room_version = '2.3.0' 
To: ext.room_version = '2.4.0-alpha03'
Enter fullscreen mode Exit fullscreen mode

JAVA_HOME on Xcode M1

Download OpenJDK from Azul’s M1 OpenJDK builds. Make it that the default version used is no greater than 11. XCode bugs with greater than 11 version during building Gradle.

Here’s a more detailed answer.

Cannot find [yourSharedModule].klib in XCode

See if you gave access for Xcode and Terminal to search in the android folder’s project.

Delete .gradle from the android project.

Delete .konan from ios project.

Go in gradle folder in your android project and type

chmod -R +x * 
-R means recursive through directories 
+x means add to every file the permission to be executed
* means all files and directories in the current folder
Enter fullscreen mode Exit fullscreen mode

Rebuild all of them. (Build Android, Pod install, Build iOS).

Now I found some Mac Intels that just don’t like this .klib file and can’t seem to find it. I’m still trying to solve this for a particular annoying mac, you can check how it’s going here.

That’s it, that sums up about a month of hitting my head on the desk to solve each individual problem that the KMM had so far.

Originally published at https://skiraindustries.com


Top comments (0)