VOOZH about

URL: https://dev.to/saad4software/no-such-module-shared-fixed-for-kmp-xcode-146p

⇱ No such module 'Shared' fixed for KMP Xcode - DEV Community


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

👁 Edit build schema

  • Then add the script as a pre-build action

👁 Add prebuild script

cd "$SRCROOT/.."
./gradlew :shared:embedAndSignAppleFrameworkForXcode

and make sure to select to provide the build settings from iosApp

👁 select build settings

  • 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

👁 build script issue

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.

👁 Add user defined settings

and add the JAVA_HOME env var

👁 Set java_home

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

👁 Successful bulid