No such module 'shared'

Hello

I’m stuck with this error below in ch1.

스크린샷 2022-07-02 오후 4.57.49

I did every solution in other website, but still getting errors.
Do I miss something?

That is usually caused by not building in Intellij.

@kevindmoore
So you mean, I need to use Intellij instead of Android studio?

No. Either one works. Just make sure you build there before going into xcode

1 Like

I did build on emulator in android studio first, though.
So I got bunch of files on build folder.

스크린샷 2022-07-04 오전 10.53.34

Do I need anything more?
I’m still learning Android studio and Kotlin, so if I miss something, please let me know.

That should work. I would next check to make sure Xcode has a reference to the “shared” library. Do a search in Xcode

1 Like

It seems to have shared library on pods.

스크린샷 2022-07-04 오후 3.03.57

The search result is like this.

스크린샷 2022-07-04 오후 3.04.50

A couple of comments:

  1. You shouldn’t need to run the app from xcode. You can run it from Android Studio
  2. Have you tried running the final project? (Try that first)

I downloaded the latest version of Android Studio (Chipmunk) and tested it on the final project. Everything went well.
I would do this and if it works, it means you probably missed something in building your app.
Compare the two projects and see what is different.

1 Like

Hi @kevindmoore

In the chapter Introduction in section 1.3 you stated:

Open Xcode. From the File menu, choose Open and navigate to your project and into the iosApp folder. Select the workspace file (iosApp.xcworkspace). For the project to run without errors, you’ll need to build in Xcode. Select Product ▸ Build or press Command-B . Once the project is built, open ContentView.swift .

Is this step no longer required as you now state the app shouldn’t need to run in Xcode ? I’m encountering the same issue myself and would like to understand how to navigate through is issue to get the project to build in both android studio dolphin 2021.3.1 and Xcode 14.

Running from Xcode is no longer required. I just downloaded AS Dolphin, created a new project and ran both Android and iOS without any problems. (I have XCode 14)

Hi @kevindmoore

Thank you for the reply, I’m attempting to run the iOS build from Android studio and still am encountering the error from Xcode.

error: cannot find ‘Greeting’ in scope
let greet = Greeting().greeting()

I don’t know how much work you have done yet, but try to create a new project and see if works.

1 Like

My issue was a didn’t have a JDK installed. I used whichjdk.com to figure out I needed to download and install Adoptium Eclipse Temurin 17. After that, the build script phase of the Xcode Project went off without a hitch.

As a fellow iOS developer, I certainly feel a lot more comfortable poking around Xcode than Android Studio + Gradle. The Kotlin Multiplatform Mobile tutorials on Kotlin’s website showcase running KMM from Android Studio.

1 Like

Hi, I solved this by doing pod install. At first even I thought it might be a problem of not building first in Android Studio/IntelliJ. Even after doing that It wasnt solved so I did the following and my issue was resolved.

  1. Open terminal and navigate to your project’s ‘ios’ folder.
  2. run this : ‘pod install’