https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
j

Jitendra

10/15/2023, 1:53 PM
I am trying to run iosApp of KMM project in Xcode, but i am getting error
Command PhaseScriptExecution failed with a nonzero exit code
here is the log
export variant\=normal
/bin/sh -c /Users/jitendraprajapati/Library/Developer/Xcode/DerivedData/iosApp-ftrrlcszyheexqhbvoqhhryktogx/Build/Intermediates.noindex/Previews/iosApp/Intermediates.noindex/iosApp.build/Debug-iphonesimulator/iosApp.build/Script-7555FFB5242A651A00829871.sh
The operation couldn't be completed. Unable to locate a Java Runtime.
Please visit <http://www.java.com> for information on installing Java.
Command PhaseScriptExecution failed with a nonzero exit code
I have java installed, and app is running well from androidStudio, I tried solution mentioned in this link. but no success .
k

Konstantin Tskhovrebov

10/15/2023, 10:31 PM
could you show
kdoctor -v
output?
j

Jitendra

10/16/2023, 12:07 AM
Copy code
jitendraprajapati@MB-C02HG0G8Q05F ~ % kdoctor -v
Environment diagnose:
[✓] Operation System
  ➤ Version OS: macOS 14.0
    CPU: Apple M1
  i You are currently using Rosetta 2.
    It may cause some issues while trying to install packages using Homebrew.
    Consider switching off Rosetta 2 or ignore this message in case you actually need it.

[✓] Java
  ➤ Java (openjdk version "17.0.6" 2023-01-17)
    Location: /Applications/Android <http://Studio.app/Contents/jbr/Contents/Home/bin/java|Studio.app/Contents/jbr/Contents/Home/bin/java>
  ➤ JAVA_HOME: /Applications/Android <http://Studio.app/Contents/jbr/Contents/Home|Studio.app/Contents/jbr/Contents/Home>

[✓] Android Studio
  ➤ Android Studio (AI-223.8836.35.2231.10811636)
    Location: /Applications/Android <http://Studio.app|Studio.app>
    Bundled Java: openjdk 17.0.6 2023-01-17
    Kotlin Plugin: 223-1.9.0-release-358-AS8836.35.2231.10811636
    Kotlin Multiplatform Mobile Plugin: 0.8.0(223)-25
  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 (15.0)
    Location: /Applications/Xcode.app

[✖] Cocoapods
  ➤ ruby (ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.x86_64-darwin23])
  ✖ System ruby is currently used
    CocoaPods is not compatible with system ruby installation on Apple M1 computers.
    Please install ruby via Homebrew, rvm, rbenv or other tool and make it default
    Detailed information: <https://stackoverflow.com/questions/64901180/how-to-run-cocoapods-on-apple-silicon-m1/66556339#66556339>
  ➤ ruby gems (Ignoring ffi-1.15.5 because its extensions are not built. Try: gem pristine ffi --version 1.15.5
    3.0.3.1)
  ✖ cocoapods not found
    Get cocoapods from <https://guides.cocoapods.org/using/getting-started.html#installation>

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:
  ✖ KDoctor has diagnosed one or more problems while checking your environment.
    Please check the output for problem description and possible solutions.
Instead of cocoapods, I am using regular framework
k

Konstantin Tskhovrebov

10/16/2023, 5:47 AM
Ok. Then run 'kdoctor -v -a' in the project root
j

Jitendra

10/16/2023, 6:42 AM
% kdoctor -v -a
Environment diagnose:
[✓] Operation System
➤ Version OS: macOS 14.0
CPU: Apple M1
i You are currently using Rosetta 2.
It may cause some issues while trying to install packages using Homebrew.
Consider switching off Rosetta 2 or ignore this message in case you actually need it.
[✓] Java
➤ Java (openjdk version "17.0.6" 2023-01-17)
Location: /Applications/Android <http://Studio.app/Contents/jbr/Contents/Home/bin/java|Studio.app/Contents/jbr/Contents/Home/bin/java>
➤ JAVA_HOME: /Applications/Android <http://Studio.app/Contents/jbr/Contents/Home|Studio.app/Contents/jbr/Contents/Home>
[✓] Android Studio
➤ Android Studio (AI-223.8836.35.2231.10811636)
Location: /Applications/Android <http://Studio.app|Studio.app>
Bundled Java: openjdk 17.0.6 2023-01-17
Kotlin Plugin: 223-1.9.0-release-358-AS8836.35.2231.10811636
Kotlin Multiplatform Mobile Plugin: 0.8.0(223)-25
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 (15.0)
Location: /Applications/Xcode.app
[✖] Cocoapods
➤ ruby (ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.x86_64-darwin23])
✖ System ruby is currently used
CocoaPods is not compatible with system ruby installation on Apple M1 computers.
Please install ruby via Homebrew, rvm, rbenv or other tool and make it default
Detailed information: <https://stackoverflow.com/questions/64901180/how-to-run-cocoapods-on-apple-silicon-m1/66556339#66556339>
➤ ruby gems (Ignoring ffi-1.15.5 because its extensions are not built. Try: gem pristine ffi --version 1.15.5
3.0.3.1)
✖ cocoapods not found
Get cocoapods from <https://guides.cocoapods.org/using/getting-started.html#installation>
[✓] Synthetic generated project
➤ Template project build was successful
[✓] Project:
➤ Gradle (8.0)
➤ Gradle plugins:
com.android.application:8.1.1
com.android.library:8.1.1
kotlinx-serialization:null
org.jetbrains.compose:1.5.1
org.jetbrains.kotlin.android:1.9.10
org.jetbrains.kotlin.multiplatform:1.9.10
org.jetbrains.kotlin.plugin.serialization:1.9.0
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:
✖ KDoctor has diagnosed one or more problems while checking your environment.
Please check the output for problem description and possible solutions.
I tried after removing script from xcode project
*cd* "$SRCROOT/.."
./gradlew :shared:embedAndSignAppleFrameworkForXcode
and now build success, Not sure what is the purpose of this script
k

Konstantin Tskhovrebov

10/16/2023, 8:29 AM
Why do you use the rosetta?
j

Jitendra

10/16/2023, 8:33 AM
I am not sure how rosetta configured but i did nothing for this
k

Konstantin Tskhovrebov

10/16/2023, 11:47 AM
Did you fix the issue or it still reproduces?
j

Jitendra

10/16/2023, 12:23 PM
after removing script from Run script section , I able to build, and run
k

Konstantin Tskhovrebov

10/16/2023, 12:26 PM
but you are not able to build Kotlin framework, right?
j

Jitendra

10/16/2023, 12:28 PM
For now, I able to run on both android and iOs, I Just removed the script from Xcode,
k

Konstantin Tskhovrebov

10/16/2023, 12:33 PM
the script does the thing: links the kotlin framework and embeds it to ios app 🤔
I guess it works because the framework was cached somewhere
j

Jitendra

10/16/2023, 1:07 PM
I clean the build , and again build fail, 😩. Please advise what should I do, I tried by adding the script again,
AndroidStudio giving error
/build/ios/iosApp.build/Debug-iphonesimulator/iosApp.build/Script-7555FFB5242A651A00829871.sh: line 2: cd: "/Users/jitendraprajapati/AndroidStudioProjects/BirdSafari/iosApp/..": No such file or directory
/`build/ios/iosApp.build/Debug-iphonesimulator/iosApp.build/Script-7555FFB5242A651A00829871.sh: line 3: ./gradlew: No such file or directory`
Command PhaseScriptExecution failed with a nonzero exit code
** BUILD FAILED **
The following build commands failed:
PhaseScriptExecution Run\ Script /Users/jitendraprajapati/AndroidStudioProjects/BirdSafari/build/ios/iosApp.build/Debug-iphonesimulator/iosApp.build/Script-7555FFB5242A651A00829871.sh (in target 'iosApp' from project 'iosApp')
(1 failure)
k

Konstantin Tskhovrebov

10/16/2023, 2:04 PM
/Users/jitendraprajapati/AndroidStudioProjects/BirdSafari
is it correct path to your project?
j

Jitendra

10/16/2023, 10:19 PM
Yes
k

Konstantin Tskhovrebov

10/17/2023, 8:46 AM
Could you try set JAVA_HOME in Xcode JAVA_HOME can be configured in Xcode -> Settings -> Locations -> Custom Paths
j

Jitendra

10/17/2023, 9:25 AM
which java command on terminal returns java path “/usr/bin/java” , But when I set this to Xcode it is giving error
ERROR: JAVA_HOME is set to an invalid directory: /usr/bin/java
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
I also tried by setting this Path to androidStudio bundled one
/Applications/Android\ <http://Studio.app/Contents/jre/Contents/Home|Studio.app/Contents/jre/Contents/Home>
But keep giving same error
t

Timofey Solonin

10/17/2023, 9:39 AM
Could you please try installing the latest arm64 JDK from Adoptium and removing the
JAVA_HOME
configuration from custom paths. Is there any chance you have moved from an intel machine to an M1 recently?
j

Jitendra

10/17/2023, 9:58 AM
Finally I restarted my system and able to build and run my project after setting java path in Xcode with androidStudio Bundled Java . Thanks you all for your time
gratitude thank you 1
🎉 3
🙏 1
9 Views