Hi, you all! I’m new to kotlin development, and i’...
# ios
h
Hi, you all! I’m new to kotlin development, and i’m trying to build an xcframework with KMM. I use the multi platform library template, and these are in my build.gradle which seems right. I know this is very basic question, but anyone have an idea that how can I get the .xcframework file? I don’t see any save path defined in gradle file. After I click “make project” in Android Studio, I can’t find any .xcframework file in my project directory. So where is the generated .xcframework after the build? Thanks!
j
Use the
assembleLibNameXCFramework
gradle task to build the XCFramework. It will be located in the build/XCFrameworks directory.
h
Hi, thanks for the help! But if I run this task, it will fail on recognize my cocoapod dependency. And should this task already be registered by including those config in build.gradle?
j
This gradle task is created by registering the
XCFramework()
in the build.gradle.kts as you are. But this mechanism conflicts with the CocoaPods plugin, which has its own mechanism to build an XCFramework. Try removing the code you shared and replace with just declaring the iOS targets:
Copy code
iosX64()
iosArm64()
iosSimulatorArm64()
Then run the
podPublishXCFramework
gradle task.
h
I’m new to gradle, so does it mean build.gradle registering tasks doesn’t actually execute them. we still need to execute it manually in terminal?
By the way, I found my podPublishXCFramework works well, but assembleXCFramework always fails in my cocoapod dependency
j
Yes. Your build configuration configures various build tasks, which can depend on one another. Then you execute specific tasks as needed and Gradle handles executing the dependent tasks as necessary in the correct order.
It makes sense the
assembleXCFramework
task won't work when using the CocoaPods plugin, as it configures conflicting tasks. So you should use
podPublishXCFramework
if using the CocoaPods plugin.
h
So if my understanding is right, podPublishXCFramework and assembleXCFramework are conflict with each other. In this case, how do we get the xcframework binary after run podPublishXCFramework?
j
podPublishXCFramework
publishes the XCFramework to build/cocoapods/publish.
🙏 1