Skip to content

Commit

Permalink
-Pod Initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
KhubaibKhan4 committed Jan 5, 2025
1 parent 1c95562 commit cf11d00
Show file tree
Hide file tree
Showing 9 changed files with 374 additions and 209 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ plugins {
alias(libs.plugins.kotlinx.serialization).apply(false)
alias(libs.plugins.compose.compiler).apply(false)
id("com.google.gms.google-services") version "4.4.2" apply false
alias(libs.plugins.kotlinCocoapods) apply false
}
54 changes: 54 additions & 0 deletions composeApp/MyCocoaPod.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
Pod::Spec.new do |spec|
spec.name = 'MyCocoaPod'
spec.version = '1.0'
spec.homepage = 'Link to a Kotlin/Native module homepage'
spec.source = { :http=> ''}
spec.authors = ''
spec.license = ''
spec.summary = 'Some description for a Kotlin/Native module'
spec.vendored_frameworks = 'build/cocoapods/framework/composeApp.framework'
spec.libraries = 'c++'



if !Dir.exist?('build/cocoapods/framework/composeApp.framework') || Dir.empty?('build/cocoapods/framework/composeApp.framework')
raise "
Kotlin framework 'composeApp' doesn't exist yet, so a proper Xcode project can't be generated.
'pod install' should be executed after running ':generateDummyFramework' Gradle task:
./gradlew :composeApp:generateDummyFramework
Alternatively, proper pod installation is performed during Gradle sync in the IDE (if Podfile location is set)"
end

spec.xcconfig = {
'ENABLE_USER_SCRIPT_SANDBOXING' => 'NO',
}

spec.pod_target_xcconfig = {
'KOTLIN_PROJECT_PATH' => ':composeApp',
'PRODUCT_MODULE_NAME' => 'composeApp',
}

spec.script_phases = [
{
:name => 'Build MyCocoaPod',
:execution_position => :before_compile,
:shell_path => '/bin/sh',
:script => <<-SCRIPT
if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then
echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\""
exit 0
fi
set -ev
REPO_ROOT="$PODS_TARGET_SRCROOT"
"$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \
-Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \
-Pkotlin.native.cocoapods.archs="$ARCHS" \
-Pkotlin.native.cocoapods.configuration="$CONFIGURATION"
SCRIPT
}
]
spec.resources = ['build/generated/libres/apple/libres-bundles']
end
39 changes: 36 additions & 3 deletions composeApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType

plugins {
alias(libs.plugins.multiplatform)
Expand All @@ -10,12 +11,13 @@ plugins {
alias(libs.plugins.libres)
alias(libs.plugins.compose.compiler)
id("com.google.gms.google-services")
alias(libs.plugins.kotlinCocoapods)
}
kotlin {
androidTarget {
compilations.all {
kotlinOptions {
jvmTarget = "19"
jvmTarget = "20"
}
}
}
Expand All @@ -38,6 +40,37 @@ kotlin {
}
}


cocoapods {
// Required properties
// Specify the required Pod version here. Otherwise, the Gradle project version is used.
version = "1.0"
summary = "Some description for a Kotlin/Native module"
homepage = "Link to a Kotlin/Native module homepage"

// Optional properties
// Configure the Pod name here instead of changing the Gradle project name
name = "MyCocoaPod"

framework {
// Required properties
// Framework name configuration. Use this property instead of deprecated 'frameworkName'
baseName = "composeApp"

// Optional properties
// Specify the framework linking type. It's dynamic by default.
isStatic = false
// Dependency export
// Uncomment and specify another project module if you have one:
// export(project(":<your other KMP module>"))
transitiveExport = false // This is default.
}

// Maps custom Xcode configuration to NativeBuildType
xcodeConfigurationToNativeBuildType["CUSTOM_DEBUG"] = NativeBuildType.DEBUG
xcodeConfigurationToNativeBuildType["CUSTOM_RELEASE"] = NativeBuildType.RELEASE
}

sourceSets {
commonMain.dependencies {
implementation(compose.runtime)
Expand Down Expand Up @@ -131,11 +164,11 @@ kotlin {

android {
namespace = "org.company.app"
compileSdk = 35
compileSdk = 34

defaultConfig {
minSdk = 28
targetSdk = 35
targetSdk = 34

applicationId = "org.company.app.androidApp"
versionCode = 1
Expand Down
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ android.nonTransitiveRClass=true

#Web
kotlin.js.generate.typedarrays=false

#iOS
compose.ios.resources.sync=false

android.suppressUnsupportedCompileSdk=35
3 changes: 2 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,5 @@ buildConfig = { id = "com.github.gmazzo.buildconfig", version.ref = "buildConfig
kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
sqlDelight = { id = "app.cash.sqldelight", version.ref = "sqlDelight" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
libres = { id = "io.github.skeptick.libres", version.ref = "libres" }
libres = { id = "io.github.skeptick.libres", version.ref = "libres" }
kotlinCocoapods = { id = "org.jetbrains.kotlin.native.cocoapods", version.ref = "kotlin" }
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 3 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#Sat Aug 03 14:19:03 PKT 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit cf11d00

Please sign in to comment.