Home > OS >  Cannot find 'Greeting' in scope Kotlin Multiplatform Moblie
Cannot find 'Greeting' in scope Kotlin Multiplatform Moblie

Time:03-23

I've added a KMM module in my Android Studio project. My project builds successfully. I have added shared module in your dependencies of

App level build.gradle.kts

it looks like this :-

implementation(project(":kotlinmultiplatformsharedmodule"))

I am adding my project directory

enter image description here

My project inside this directory

> /Users/vmodi/AndroidStudioProjects/KotlinCocoapods

I created a xcode project and create a pod file using

pod init

PodFile

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'IosCocoapods' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for IosCocoapods
   pod 'kotlinmultiplatformsharedmodule', :path => '/Users/vmodi/AndroidStudioProjects/KotlinCocoapods/kotlinmultiplatformsharedmodule'

end

I run the command in new terminal and go to ios project directory

  cd /Users/vmodi/Xcode/IosCocoapods

then

pod install --verbose

enter image description here

My Ios project structure look like this

enter image description here

I open project and import module then I write Greeting().greeting() it gives error

Cannot find 'Greeting' in scope

enter image description here

CodePudding user response:

With Cocoapods you need to open *.xcworkspace file instead of *.xcodeproj, more info can be found here.

Then you need to run build with B. This will run a script that builds the KMM framework, and after building (if successful) and completing the indexing, you should not see any error.

  • Related