Ewerton Pontini
01/19/2024, 5:06 PMcommonMain
directory into a library for iOS, apparently in the form of a .framework
. However, when running the task, I receive a generalized Gradle error that doesn't provide much insight into what might be wrong. I would like to know if my configuration is correct for my purpose of creating a .framework
to be imported by an external iOS application.Ewerton Pontini
01/19/2024, 5:06 PMEwerton Pontini
01/19/2024, 5:07 PMplugins {
id 'kotlin-multiplatform'
id 'com.android.library'
id 'kotlin-kapt'
id 'org.jetbrains.kotlin.native.cocoapods'
}
android {
compileSdkVersion Config.compileSdk
defaultConfig {
minSdkVersion Config.minSdk
targetSdkVersion Config.targetSdk
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
packagingOptions {
resources {
excludes += ['META-INF/LICENSE.md', 'META-INF/LICENSE-notice.md']
}
}
}
kotlin {
android()
iosArm64()
iosX64()
iosSimulatorArm64()
cocoapods {
version = "1.9.22"
}
sourceSets {
commonMain {
dependencies {
// Add common dependencies here
}
}
commonTest {
dependencies {
// Add common test dependencies here
}
}
androidMain {
dependencies {
// Add Android main dependencies here
}
}
androidTest {
dependencies {
// Add Android test dependencies here
}
}
iosMain {
dependencies {
// Add iOS main dependencies here
}
}
iosTest {
dependsOn iosMain
}
}
}
task generateFramework {
dependsOn 'cocoapodsInstall'
doLast {
// Destination path for the generated framework
def targetFrameworkDir = "${project.buildDir}/kmmFramework"
// If the path doesn't exist, create the directory
file(targetFrameworkDir).mkdirs()
// Your code to copy the generated framework to the desired destination
copy {
from "build/cocoapods" // Make sure this is the correct path for the generated framework
into targetFrameworkDir
include '**/*.framework'
include '**/*.h'
}
}
}
Ewerton Pontini
01/19/2024, 5:07 PMEwerton Pontini
01/19/2024, 5:08 PMPablichjenkov
01/19/2024, 5:11 PMpodPublishXCFramework
Give it a try to see if it generates what you want.Ewerton Pontini
01/19/2024, 6:27 PMEwerton Pontini
01/19/2024, 6:27 PMplugins {
id 'org.jetbrains.kotlin.multiplatform'
id 'com.android.library'
id 'org.jetbrains.kotlin.native.cocoapods'
}
android {
compileSdkVersion Config.compileSdk
defaultConfig {
minSdkVersion Config.minSdk
targetSdkVersion Config.targetSdk
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
packagingOptions {
resources {
excludes += ['META-INF/LICENSE.md', 'META-INF/LICENSE-notice.md']
}
}
}
kotlin {
android()
ios {
binaries {
framework {
baseName = "YourFrameworkName"
}
}
}
cocoapods {
version = "1.11.2" // Versão desejada do CocoaPods
summary = "Your framework summary"
homepage = "<https://your-framework-homepage.com>"
}
}
task generateFramework {
dependsOn 'cocoapodsInstall'
doLast {
def targetFrameworkDir = "${project.buildDir}/kmmFramework"
file(targetFrameworkDir).mkdirs()
copy {
from "build/cocoapods"
into targetFrameworkDir
include '**/*.framework'
include '**/*.h'
}
tasks.podPublishXCFramework.dependsOn 'generateFramework'
}
}
Ewerton Pontini
01/19/2024, 6:27 PMPablichjenkov
01/19/2024, 6:35 PMPablichjenkov
01/19/2024, 6:37 PMPablichjenkov
01/19/2024, 6:39 PMEwerton Pontini
01/19/2024, 6:52 PMEwerton Pontini
01/19/2024, 6:53 PMEwerton Pontini
01/19/2024, 6:54 PMPablichjenkov
01/19/2024, 7:25 PMPablichjenkov
01/19/2024, 7:26 PMSettings/Experimental
Ewerton Pontini
01/19/2024, 8:18 PMThis part does not exist in my kmm module. I'll try to see how to add it
Pablichjenkov
01/19/2024, 8:29 PMAndrew Reed
01/19/2024, 9:55 PMkhalid64927
01/20/2024, 1:23 AMEwerton Pontini
01/22/2024, 4:52 PMThanks for your help, it's working correctly now