I finished the following tutorial.
https://kotlinlang.org/docs/multiplatform-mobile-upgrade-app.html
And I had a question below.
How to build iosApp in Xcode
I was able to run a IOSApp in AndroidStudio. So I tried to run it in Xcode as well.
But I got an error No such module 'shared'
and could not run it.
Because I want to use Swift Package Manager
, I selected Regular framework
when I created the project(not cocoa pod). If I don't select CocoaPods, can I use Xcode to Build? Or am I making some mistakes?
I need to know how to build IOSApp with Xcode.
Thanks.
CodePudding user response:
For Swift Package Manager you'll need to call the command ./gradlew createXCFramework
to build and create the framework. Then you will need to make a Package.swift
file to point to the framework file. Something like this:
let package = Package(
name: "MyLibrary",
platforms: [
.iOS(.v13),
],
products: [
.library(
name: "MyLibrary",
targets: ["shared"])
],
targets: [
.binaryTarget(
name: "shared",
path: "YOUR_PATH/build/XCFrameworks/debug/shared.xcframework"
)
]
)
You can see more details for Package.swift here.
You can also try using this gradle plugin to generate it automatically. https://github.com/ge-org/multiplatform-swiftpackage I haven't used it personally but it could be a simpler approach.