最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

android - Kotlin Multiplatform: cannot find 'MainViewControllerKt' in scope MainViewControllerKt.MainViewControl

programmeradmin3浏览0评论

I've updated my multi-module KMP project to use cocoapods according to kotlinlang. But after syncing, building, and running the ios app (either using Android Studio or Xcode 16.2), I encounter the following error:

Inside build.gradle.kts of :composeApp module, I've added the following code:

kotlin {
    cocoapods {
        summary = "Some description for the Shared Module"
        homepage = "Link to the Shared Module homepage"
        version = "1.0"
        ios.deploymentTarget = "16.2"
        podfile = project.file("../iosApp/Podfile")
        framework {
            baseName = "ComposeApp"
            isStatic = false
            transitiveExport = false // This is default.
        }
    }
}

And Podfile inside iosApp directory looks like this:

target 'iosApp' do
  use_frameworks!
  platform :ios, '16.2'
  pod 'composeApp', :path => '../ComposeApp'
end

What I have already tried:

  1. Invalidating cache & restart
  2. Cleaning the project and making it again
  3. Running pod deintegrate then pod install again
  4. The solution said here: Open file *.xcworkspace, then building using +B (which leads to build failure)

I've updated my multi-module KMP project to use cocoapods according to kotlinlang. But after syncing, building, and running the ios app (either using Android Studio or Xcode 16.2), I encounter the following error:

Inside build.gradle.kts of :composeApp module, I've added the following code:

kotlin {
    cocoapods {
        summary = "Some description for the Shared Module"
        homepage = "Link to the Shared Module homepage"
        version = "1.0"
        ios.deploymentTarget = "16.2"
        podfile = project.file("../iosApp/Podfile")
        framework {
            baseName = "ComposeApp"
            isStatic = false
            transitiveExport = false // This is default.
        }
    }
}

And Podfile inside iosApp directory looks like this:

target 'iosApp' do
  use_frameworks!
  platform :ios, '16.2'
  pod 'composeApp', :path => '../ComposeApp'
end

What I have already tried:

  1. Invalidating cache & restart
  2. Cleaning the project and making it again
  3. Running pod deintegrate then pod install again
  4. The solution said here: Open file *.xcworkspace, then building using +B (which leads to build failure)
Share Improve this question edited Feb 16 at 12:31 mohammad fakhraee asked Feb 16 at 12:11 mohammad fakhraeemohammad fakhraee 3223 silver badges12 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

It seems Android Studio build's log doesn't show the specific errors. By checking the xcode I can see a build issue:

Which the issue is with room's config for IOS. By adding the following line in framework block inside cocoapods block, the build is successfull:

kotlin {
    cocoapods {
        summary = "Some description for the Shared Module"
        homepage = "Link to the Shared Module homepage"
        version = "1.0"
        ios.deploymentTarget = "16.2"
        podfile = project.file("../iosApp/Podfile")
        framework {
            baseName = "ComposeApp"
            isStatic = false
            transitiveExport = false // This is default.
            linkerOpts.add("-lsqlite3") // I had to add this line
        }
    }
}
发布评论

评论列表(0)

  1. 暂无评论