4

I am a first timer on KMM and have just created a new KMM application project on Macbook M1 Pro. No code changes, this is just the hello world app that I am using. I have been able to successfully build the project for android platform, and it runs fine on the android emulator. However, when I try to build it for the ios platform, it is failing with the below error message:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':shared'.
> The project must have a target for at least one of the following platforms: ios_simulator_arm64.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 553ms
** BUILD FAILED **


The following build commands failed:
    PhaseScriptExecution [CP-User]\ Build\ shared /Users/manajit/Projects/Learning/App/KMMExperiment/build/ios/Pods.build/Debug-iphonesimulator/shared.build/Script-4552119A071AC6BAB7327E6434237EC3.sh (in target 'shared' from project 'Pods')
(1 failure)
Command PhaseScriptExecution failed with a nonzero exit code.
Phil Dukhov
  • 67,741
  • 15
  • 184
  • 220

1 Answers1

6

Currently, the base application created by the KMM plugin has commented out support for the ARM simulator because there are some libraries that do not yet support it. This is most likely due to Ktor, which only recently added its support.

Go to shared/build.gradle.kts and uncomment all lines containing iosSimulatorArm64.

Phil Dukhov
  • 67,741
  • 15
  • 184
  • 220
  • There is no line with iosSimulatorArm64 in the shared/build.gradle.kts. The file content is: buildscript { repositories { gradlePluginPortal() google() mavenCentral() } dependencies { classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0") classpath("com.android.tools.build:gradle:7.0.3") } } allprojects { repositories { google() mavenCentral() } } tasks.register("clean", Delete::class) { delete(rootProject.buildDir) } – Manajit Rath Nov 29 '21 at 02:15
  • @ManajitRath no, this looks like a content of `projectDir/build.gradle.kts`, make sure you're looking at shared module one – Phil Dukhov Nov 29 '21 at 02:43
  • I am so sorry, yes, I checked the shared/build,gradle.kts and found iosSimulatorArm64 and uncommented the same throughout. Now the build fails with the error:e: /Users/manajit/Projects/Learning/App/KMMFirst/shared/build.gradle.kts:13:25: Unresolved reference: sure e: /Users/manajit/Projects/Learning/App/KMMFirst/shared/build.gradle.kts:13:30: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: public val NamedDomainObjectProvider.all: Set defined in org.gradle.kotlin.dsl – Manajit Rath Nov 29 '21 at 02:58
  • 1
    @ManajitRath line 13 contains note about why it was commented, you can delete string "sure all ios dependencies support this target" – Phil Dukhov Nov 29 '21 at 03:01
  • Yayyy... This worked fine. The emulator did start up for ios.. However, once the emulator starts up it throws an error.. "Android Studio quit unexpectedly." and it asks me to restart AndroidStudio.. – Manajit Rath Nov 29 '21 at 03:11
  • @ManajitRath I haven't faced such problem, try running it from Xcode. – Phil Dukhov Nov 29 '21 at 04:27
  • It throws an error while building on xcode. "ld: framework not found Pods_iosApp clang: error: linker command failed with exit code 1 (use -v to see invocation)" – Manajit Rath Dec 01 '21 at 07:12
  • @ManajitRath try runing `pod install` from `project/iosApp` – Phil Dukhov Dec 01 '21 at 07:14
  • I ran pod install. It ran successfully, but the build still fails on xCode and same behaviour on AS. – Manajit Rath Dec 02 '21 at 14:36
  • @ManajitRath it's hard to say with these details. Upload the project on GitHub, I'll take a look – Phil Dukhov Dec 02 '21 at 14:42