https://kotlinlang.org logo
#ios
Title
# ios
a

Allen

05/22/2022, 7:50 PM
Hello guys, I am working in Kmm library. I am in iOS part and using cocoapods as dependency manager. I am new in ios and kmm. I am reading the cocoapods doc in kotlin. I am adding my gradle code in the thread. I am understand that my cocoapod code is generating .podspec file. But there is no instructions given in doc to generate framework. I want to use pod private spec, but I don't understand what I need to share in the repo. Can someone help me how can I generate framework and what files I can share in private pod sec repo. Any working examples will be great. Thanks
👀 1
Copy code
plugins {
     kotlin("multiplatform") version "1.6.21"
     kotlin("native.cocoapods") version "1.6.21"
     id("com.android.library")
     id("maven-publish")
 }
 
 val libraryVersion = "0.0.4"
 var libraryGroup = "com.ab"
 var libraryArtifactId = "kmm-module"
 
 repositories {
     google()
     mavenCentral()
 }
 
 kotlin {
     android {
         publishLibraryVariants("release", "debug")
     }
     cocoapods {
         // Required properties
         // Specify the required Pod version here. Otherwise, the Gradle project version is used.
         version = "0.0.1"
         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 = "MyFramework"
 
             // Optional properties
             // Dynamic framework support
             isStatic = false
 
         }
     }
     iosX64()
     iosArm64()
     iosSimulatorArm64()
     sourceSets {
         val commonMain by getting
         val androidMain by getting
         val iosX64Main by getting
         val iosArm64Main by getting
         val iosSimulatorArm64Main by getting
         val iosMain by creating {
             dependsOn(commonMain)
             iosX64Main.dependsOn(this)
             iosArm64Main.dependsOn(this)
             iosSimulatorArm64Main.dependsOn(this)
         }
     }
 }
r

ribesg

05/23/2022, 9:33 AM
Just running the gradle
build
task should generate multiple frameworks in your
build
folder but you shouldn’t have to care about that. You just need to setup your kmm lib as a cocoapods dependency in your XCode project, like any other normal cocoapods dependency you could have in a normal XCode project
Like inside your XCode project folder, next to your
.xcodeproj
and
.xcworkspace
folders, you should have a
Podfile
with something like
pod "yourKmmLib", :path => './path/to/folder/containging/podspec'
and then run
pod install
in there
v

Vivek Modi

05/23/2022, 11:01 AM
Hey @ribesg this is not my question but I am looking same kind of answer as well. When I build my project and I check inside build folder cocoapods generate some
framework
+
publish
folder. Actually I want to create private pod repo. So what should I need to share in that repo with
.podspec
file?
r

ribesg

05/23/2022, 12:39 PM
I don’t know I guess you just follow https://guides.cocoapods.org/making/private-cocoapods.html the podspec file is generated for you by the Gradle build
In my usage my “Kotlin lib” is completely local to my XCode project so it’s just a local pod dependency, can’t help with the remote stuff
a

Allen

05/23/2022, 1:54 PM
Great @ribesg great answer. Thank you
m

matej

08/11/2022, 1:12 PM
@Allen did you manage to find a solution? We're in the same boat. Want to generate a framework file and host it in a private repo, and consume it in our iOS project as any other pod library.
5 Views