JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16.21k stars 1.17k forks source link

Unable to run iOS after build #3239

Closed JSpiner closed 1 month ago

JSpiner commented 1 year ago

Describe the bug I was trying to build an ios app with compose. I followed [this guide], and build a simple compose app using Android Studio. However, after a successful build, only the following message appears and it does not run. Even if I run the targeted ios simulator directly, nothing is installed.

/Users/smith.jspiner/android/KRepository/build/ios/Debug-iphonesimulator/iosApp.app

Android works fine. I think something is wrong with the communication with xcode. Because when I try to close android studio, 'waiting for process detach' message comes out and it goes into an infinite waiting state.

Affected platforms

Versions\

Additional context I tried just build a simple iOS app in xCode, it works fine. I checked kdoctor, it says fine. I changed ios simulator several versions, it works fail. I updated macOS version, it works fail. I updated xCode to 14.3.1, it works fail. I tried reboot android studio, xCode and mac but it failed.

m-sasha commented 1 year ago

What is the guide you followed?

JSpiner commented 1 year ago

@m-sasha I tried two project First, clone this repository and try build & run. Second, create new empty project from android studio and try build & run. I also checked kotlin multiplatform mobile plugin is installed. I'm using 0.6.0(222)-13 version.

Which one should I check?

JSpiner commented 1 year ago

@m-sasha I have tried several ways but nothing succeeded with android studio. However, when I opened the iosApp folder with xcode and ran it with xcode, it worked normally. It would be possible as a suboptimal solution, but it seems inconvenient. Is there any way to do it in android studio?

pablichjenkov commented 1 year ago

The same happens to me. I believe xCode sets something somewhere that Android Studio doesn't.

m-sasha commented 1 year ago

Hmm, I just followed the instructions in that repo (for the first time) and it worked for me. Can you say exactly what steps you did? Preferably with screenshots.

pablichjenkov commented 1 year ago

Hmm, I just followed the instructions in that repo (for the first time) and it worked for me. Can you say exactly what steps you did? Preferably with screenshots.

I am not following any tutorial, just clone the template or the examples and modify them from Android Studio. I have noticed that if I don't open the iOSApp module with xCode it doesn't run. Once I open the project once, then it starts working. Also Android Studio doesn't recognize my physical device. It does work well with the emulator tho.

benjamin-cheng commented 1 year ago

I met the same issue and it has been resolved by running the following command: sudo chown [username] ~/Library/LaunchAgents Solution was found here

cnickh commented 10 months ago

I am having the same issue as described by @JSpiner. Following this guide.

Some Info:

Compose Multiplatform version:  0.8.1
OS version: macOS 13.0.1 Ventura
OS architecture (x86 or arm64): arm64 (M1)
JDK : 17.07

I tried the solution referred to by @benjamin-cheng, and it did not work. The output from the logs (retrieved by following steps in the solution) are the following. I have not been able to resolve this issue...


2023-12-14 17:29:54,969 [  31689] SEVERE - #c.j.c.e.deviceSupport - Assertion failed: Attempted to use an uninitialized connection
java.lang.Throwable: Assertion failed: Attempted to use an uninitialized connection
    at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:258)
    at com.jetbrains.cidr.xcode.XPCServiceConnection.invokeService(XPCServiceConnection.kt:236)
    at com.jetbrains.cidr.xcode.XPCServiceConnection$getValue$3.invoke(XPCServiceConnection.kt:232)
    at com.jetbrains.cidr.xcode.XPCServiceConnection$getValue$3.invoke(XPCServiceConnection.kt:232)
    at com.jetbrains.cidr.xcode.XPCServiceConnection.getValue$lambda$11(XPCServiceConnection.kt:213)
    at com.jetbrains.cidr.ObjCHelper.performWithCallback(ObjCHelper.java:143)
    at com.jetbrains.cidr.xcode.XPCServiceConnection.getValue(XPCServiceConnection.kt:213)
    at com.jetbrains.cidr.xcode.XPCServiceConnection.getValue(XPCServiceConnection.kt:232)
    at com.jetbrains.cidr.execution.JBDeviceFramework$Companion$getValue$1.invokeSuspend(JBDeviceFramework.kt:62)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:284)
    at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
    at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
    at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
    at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
    at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
    at com.jetbrains.cidr.execution.JBDeviceFramework$Companion.getValue(JBDeviceFramework.kt:60)
    at com.jetbrains.cidr.execution.JBDeviceFramework.getValue(JBDeviceFramework.kt)
    at com.jetbrains.cidr.execution.AppleProcessHandler.lambda$new$4(AppleProcessHandler.java:187)
    at com.jetbrains.cidr.execution.AppleProcessHandler.startProcess(AppleProcessHandler.java:263)
    at com.jetbrains.cidr.execution.AppleProcessHandler.lambda$new$5(AppleProcessHandler.java:186)
    at com.intellij.util.concurrency.QueueProcessor$RunnableConsumer.consume(QueueProcessor.java:296)
    at com.intellij.util.concurrency.QueueProcessor$RunnableConsumer.consume(QueueProcessor.java:293)
    at com.intellij.util.concurrency.QueueProcessor.lambda$wrappingProcessor$0(QueueProcessor.java:80)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:249)
    at com.intellij.util.concurrency.QueueProcessor.lambda$wrappingProcessor$1(QueueProcessor.java:80)
    at com.intellij.util.concurrency.QueueProcessor.lambda$startProcessing$3(QueueProcessor.java:223)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:249)
    at com.intellij.util.concurrency.QueueProcessor.lambda$startProcessing$4(QueueProcessor.java:223)
    at com.intellij.util.concurrency.AppJavaExecutorUtil$executeOnPooledIoThread$1$1.invoke(executor.kt:19)
    at com.intellij.util.concurrency.AppJavaExecutorUtil$executeOnPooledIoThread$1$1.invoke(executor.kt:19)
    at com.intellij.openapi.progress.CancellationKt.withCurrentJob$lambda$0(cancellation.kt:17)
    at com.intellij.openapi.progress.Cancellation.withCurrentJob(Cancellation.java:60)
    at com.intellij.openapi.progress.CancellationKt.withCurrentJob(cancellation.kt:17)
    at com.intellij.openapi.progress.CoroutinesKt.blockingContext(coroutines.kt:193)
    at com.intellij.util.concurrency.AppJavaExecutorUtil$executeOnPooledIoThread$1.invokeSuspend(executor.kt:19)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
    at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
2023-12-14 17:29:54,970 [  31690] SEVERE - #c.j.c.e.deviceSupport - Android Studio Hedgehog | 2023.1.1  Build #AI-231.9392.1.2311.11076708
2023-12-14 17:29:54,970 [  31690] SEVERE - #c.j.c.e.deviceSupport - JDK: 17.0.7; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o.
2023-12-14 17:29:54,970 [  31690] SEVERE - #c.j.c.e.deviceSupport - OS: Mac OS X
2023-12-14 17:29:54,970 [  31690] SEVERE - #c.j.c.e.deviceSupport - Plugin to blame: Kotlin Multiplatform Mobile version: 0.8.1(231)-23
2023-12-14 17:29:58,930 [  35650]   INFO - #c.i.u.MemTester - not supported: not an executable file: null
2023-12-14 17:30:08,191 [  44911]   WARN - #c.j.c.xcode - Could not retrieve service endpoint for JBDevice.framework/Versions/A/Resources/JBDeviceService
2023-12-14 17:30:08,247 [  44967]   INFO - #c.j.c.xcode - dyld[6994]: Symbol not found: _$s10CoreDevice06RemoteB0C07acquireB14UsageAssertion10withReason7optionsAA0beF0CSS_AA0eF7OptionsVtYaKF
2023-12-14 17:30:08,247 [  44967]   INFO - #c.j.c.xcode - Referenced from: <C16FF0DD-0D1D-3230-8CFB-973AA18710B3> /Users/nick/Library/Application Support/Google/AndroidStudio2023.1/plugins/kmm/bin/JBDevice.framework/Versions/A/Resources/JBDeviceService
2023-12-14 17:30:08,247 [  44967]   INFO - #c.j.c.xcode - Expected in:     <3F15E8A3-08F3-3428-9BF3-42CA3F6475E6> /Library/Developer/PrivateFrameworks/CoreDevice.framework/Versions/A/CoreDevice
serj113 commented 10 months ago

i had same issue, but then i added java home path to xcode as custom path and it worked, i'm using java from sdkman

image
asahelk commented 8 months ago

Any updates about this issue? I'm getting the exact same error.

OS version: MacOS Monterey 12.7.3 OS architecture: x86_64 JDK (for desktop issues): java 21.0.2 Android Studio version(s): Android Studio Iguana 2023.2.1 RC 2. I migrated from Android Studio Hedgehog | 2023.1.1 Patch 2 Kotlin Multiplatform Mobile plugin: 0.8.2(232)-20 Xcode version: 14.2

Kdoctor:

[✓] Operation System
  ➤ Version OS: macOS 12.7.3
    CPU: Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz

[✓] Java
  ➤ Java (openjdk version "21.0.2" 2024-01-16 LTS)
    Location: /Users/asahel/.sdkman/candidates/java/current/bin/java
  ➤ JAVA_HOME: /Users/asahel/.sdkman/candidates/java/current

[✓] Android Studio
  ➤ Android Studio (AI-232.10227.8.2321.11429013)
    Location: /Applications/Android Studio.app
    Bundled Java: openjdk 17.0.9 2023-10-17
    Kotlin Plugin: 232-1.9.0-release-358-AS10227.8.2321.11429013
    Kotlin Multiplatform Mobile Plugin: 0.8.2(232)-20
  i Note that, by default, Android Studio uses bundled JDK for Gradle tasks execution.
    Gradle JDK can be configured in Android Studio Preferences under Build, Execution, Deployment -> Build Tools -> Gradle section

[✓] Xcode
  ➤ Xcode (14.2)
    Location: /Applications/Xcode.app
  i Xcode JAVA_HOME: /Users/asahel/.sdkman/candidates/java/current
    Xcode JAVA_HOME can be configured in Xcode -> Settings -> Locations -> Custom Paths

[✓] CocoaPods
  ➤ ruby (ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin21])
  ➤ ruby gems (3.2.3)
  ➤ cocoapods (1.15.2)

[✓] Synthetic generated project
  ➤ Template project build was successful

[✓] Project: /Users/asahel/StudioProjects/sick_trainer
  ➤ Gradle (8.4)
  ➤ Gradle plugins:
    com.android.application:8.2.0
    com.android.library:8.2.0
    org.jetbrains.compose:1.5.12
    org.jetbrains.kotlin.multiplatform:1.9.22
    org.jetbrains.kotlin.plugin.serialization:1.9.21

Recommendations:
  ➤ IDE doesn't suggest running all tests in file if it contains more than one class
    More details: https://youtrack.jetbrains.com/issue/KTIJ-22078
Conclusion:
  ✓ Your operation system is ready for Kotlin Multiplatform Mobile Development!

stat ~/Library/LaunchAgents

  16777220 1532314 drwxr-xr-x 4 asahel staff 0 128 "Feb 26 18:42:27 2024" "Feb 26 18:42:27 2024" "Feb 26 18:42:27 2024" "Feb 19 17:15:15 2024" 4096 0 0 /Users/asahel/Library/LaunchAgents
dima-avdeev-jb commented 8 months ago

This problem is not related with Compose Multiplatform. It relates to Kotlin tooling in IDE.

@asahelk @serj113 @cnickh
Can you please describe your problem here: http://kotl.in/issue

It is good to attach newly created YouTrack issue to current Issue on GitHub. Thanks!

okushnikov commented 2 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.