简体   繁体   中英

How to configure an iOS Application for Kotlin Multiplatform in Android Studio?

I want to add a Run/Debug Configuration for an iOS Application for a Kotlin Multiplatform Mobile application in Android Studio 4.1.2. However, there seems to be a problem with the configuration for iOS.

In the screenshot below you can see the problem. In the dialog "Run/Debug Configuration" Android Studio complains about

Error: Please specify Xcode project location in xcodeproj property of gradle.properties

Using the "Fix" button does not solve the problem. Android Studio just adds an additional xcodeproj to gradle.properties and the complains about a duplicate parameter.

I also tried different paths (relative and absolute) for xcodeproj . No luck.

If I remember correctly, it used to work out of the box. A new Kotlin Multiplatform Mobile project was automatically configured for Android and iOS. I'm not sure what changed. Probably something was updated.

Is this a bug with the KMM plugin? Or is there something I can do on my system to fix this?

在此处输入图像描述

don't do that with Android Studio.

Just open Xcode, click on 'open another project...', locate to the iosApp folder that named it when creating your project on Android Studio.

after that, just click run and have fun.

在此处输入图像描述

If the project doesn't run right away even on opening it from Xcode and shows the shared framework is missing , Then try generating the shared framework for iOS platform using terminal. Navigate to the project folder and execute
Command: ./gradlew packForXcode Now the shared framework should have a xcode-frameworks product and you should be able to build and run the project through Xcode.

I fixed it by downgrading the Kotlin version from 1.4.30 to 1.4.21. You can check this thread here . To downgrade, download the version you want from the plugin store and choose the install plugin from disk as in the picture below从光盘截图安装插件

If you don't wanna use Xcode:

Look like there is some IDE issues in this versions, one option would be to downgrade the Kotlin version.

What worked for me was to download the latest Canary Android Studio and setup my KMM project there.

Hopefully soon this will be stable for the next versions

Same as here: https://stackoverflow.com/a/66941077/3117650

Look like there is some IDE issues in this versions, one option would be to downgrade the Kotlin version.

What worked for me was to download the latest Canary Android Studio and setup my KMM project there.

Hopefully soon this will be stable for the next versions

Upgrading Android Studio version to 4.2.1, KMM plugin version to 0.2.6, creating new KMM project with KMM plugin, the problem can be fixed automatically.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM