I manage to create an ios framework file and manua...
# kotlin-native
j
I manage to create an ios framework file and manually include it in my ios app but that quite time consuming, is there a way of automatically update the xcode project eachtime a new framework is build? Or something similar to a maven repo from the java world? I tried to use cocoapod but it does not work properly, I get a lot of errors
a
Hi, @jean! There are two most popular approaches. The first one is using the cocoapods plugin(as described in the documentation). Another option is to write a Gradle task packing the framework somewhere Xcode project will find it, and then execute this task from the Xcode(as a custom Run Script Build phase). An example of this can be found at the official kmm-sample(Also available at the Android Studio as KMM Application option when you create a new proejct). What was the problem you faced with cocoapods?
👍 1
j
I’m reporting what ios guys told me, one of the main issue with cocoapod dependency was this
/Users/teamcity/buildAgent/work/f01984a9f5203417/runtime/src/main/cpp/ObjCExport.mm:346: runtime assert: Unable to add 'toKotlin:' method to NSBlock class
another problem regarding the task itself is that we had to create one for ios targets and one for tvos targets. Is there a way to condense everything in one check ? I mean on this lines in the task :
Copy code
val sdkName = System.getenv("SDK_NAME") ?: "iphonesimulator"
val targetName = "ios" + if (sdkName.startsWith("iphoneos")) "Arm64" else "X64"
ideally we would need something that check for one of
iosArm64
or
iosX64
or
tvosArm64
or
tvosX64
a
Seems similar to https://kotlinlang.slack.com/archives/C3SGXARS6/p1593807054139000 and https://github.com/ktorio/ktor/issues/1786#issuecomment-613941124. Maybe there was something with
build/
dir being corrupted, worth filing n issue with a project to play with
About 4 targets. I would guess it can be derived from
SDK_NAME
envvar contents, just don’t know how it looks for the tvOS.
j
The problem is how to differentiate for simulator, since it will be empty for both. Or use two task like we have done 😕
g
Hi @jean, have you looked into Swift Package Manager and XCFrameworks? I made a Gradle plugin that helps generating both https://github.com/ge-org/multiplatform-swiftpackage