I believe you have already tried to open Kotlin multi-platform iOS project in Xcode, and voalla, No such module 'Shared'
Let's jump directly to the solution. You can also find the solution here
- Start by choosing to edit schemas in Xcode
- Then add the script as a pre-build action
cd "$SRCROOT/.."
./gradlew :shared:embedAndSignAppleFrameworkForXcode
and make sure to select to provide the build settings from iosApp
Time to try to build again, success? Good for you, same error? move on ...
Let's debug the script to find the issue
echo "Hello world"
cd "$SRCROOT/.."
./gradlew :shared:embedAndSignAppleFrameworkForXcode
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
So, couldn't find the Java runtime...
I need to set JAVA_HOME. We can do it on the system level, the script level, or on the project level. I'll choose the third.
Select your project, project properties, click the add button, and add a user-defined setting.
and add the JAVA_HOME env var
For my device, the path is
export JAVA_HOME="/Applications/Android Studio.app/Contents/jbr/Contents/Home"
It should build successfully now
Stay tuned for Networking with KMP







Top comments (0)