saket
10/03/2021, 6:59 PMWaqas Tahir
10/04/2021, 8:59 AMSlackbot
10/04/2021, 11:27 AMHamza Ahmad
10/04/2021, 11:38 AMmport org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
plugins {
kotlin("multiplatform")
kotlin("plugin.serialization") version "1.5.0"
id("com.android.library")
id("com.squareup.sqldelight")
}
repositories {
google()
mavenCentral()
}
kotlin {
android()
val iosTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true)
::iosArm64
else
::iosX64
iosTarget("ios") {
binaries {
framework {
baseName = "shared"
}
}
}
sourceSets {
val ktorVersion = "1.5.4"
val commonMain by getting {
dependencies {
// implementation("com.facebook.android:facebook-android-sdk:[5,6)")
// implementation("com.google.android.material:material:1.3.0")
// implementation("com.google.firebase:firebase-messaging:10.2.1")
// implementation("com.google.android.gms:play-services:10.2.1")
// implementation("com.google.android.gms:play-services-ads:10.2.1")
// implementation("com.google.firebase:firebase-core:10.2.1")
// implementation("com.google.firebase:firebase-auth:10.2.1")
// implementation("com.github.siyamed:android-shape-imageview:0.9.+@aar")
// implementation("com.github.barteksc:android-pdf-viewer:3.1.0-beta.1")
// implementation("org.apache.commons:commons-io:1.3.2")
// Logger
implementation("com.github.aakira:napier:1.4.1")
implementation("io.ktor:ktor-client-core:$ktorVersion")
implementation("io.ktor:ktor-client-serialization:$ktorVersion")
implementation("io.ktor:ktor-client-logging:$ktorVersion")
implementation("com.squareup.sqldelight:runtime:1.5.0")
// implementation("com.google.android.material:material:1.3.0")
// implementation("androidx.appcompat:appcompat:1.2.0")
// implementation("androidx.legacy:legacy-support-v13:1.0.0")
// implementation("androidx.core:core:1.0.0")
// implementation("androidx.legacy:legacy-support-v4:1.0.0")
// implementation("androidx.constraintlayout:constraintlayout:1.1.3")
// implementation("com.android.support.constraint:constraint-layout:")
// implementation("com.google.firebase:firebase-messaging:10.2.1")
// implementation("com.google.android.gms:play-services:10.2.1")
// implementation("com.google.android.gms:play-services-ads:10.2.1")
// implementation("com.google.firebase:firebase-core:10.2.1")
// implementation("com.google.firebase:firebase-auth:10.2.1")
// implementation("com.github.siyamed:android-shape-imageview:0.9.+@aar")
// implementation("com.facebook.android:facebook-android-sdk:[5,6)")
// implementation("androidx.mediarouter:mediarouter:1.0.0")
// implementation("androidx.vectordrawable:vectordrawable:1.0.0")
// implementation("com.github.barteksc:android-pdf-viewer:3.1.0-beta.1")
// implementation("org.apache.commons:commons-io:1.3.2")
// implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.30")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val androidMain by getting {
dependencies {
implementation("com.squareup.sqldelight:android-driver:1.5.0")
implementation("io.ktor:ktor-client-okhttp:$ktorVersion")
implementation("androidx.multidex:multidex:2.0.0")
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
implementation(files("libs/ksoap2-android-assembly-3.3.0-jar-with-dependencies.jar"))
implementation(files("libs/pinchzoom.jar"))
implementation(files("libs/org.apache.commons.net_2.0.0.v200905272248.jar"))
implementation(files("libs/StartAppInApp-3.4.2.jar"))
implementation(files("libs/picasso-2.5.2.jar"))
implementation("com.google.android.material:material:1.3.0")
implementation("androidx.appcompat:appcompat:1.2.0")
implementation("androidx.appcompat:appcompat:1.0.0")
implementation("androidx.legacy:legacy-support-v13:1.0.0")
implementation("androidx.core:core:1.0.0")
implementation("androidx.legacy:legacy-support-v4:1.0.0")
implementation("androidx.constraintlayout:constraintlayout:1.1.3")
implementation("com.android.support.constraint:constraint-layout:")
implementation("com.google.firebase:firebase-messaging:10.2.1")
implementation("com.google.android.gms:play-services:10.2.1")
implementation("com.google.android.gms:play-services-ads:10.2.1")
implementation("com.google.firebase:firebase-core:10.2.1")
implementation("com.google.firebase:firebase-auth:10.2.1")
implementation("com.github.siyamed:android-shape-imageview:0.9.+@aar")
implementation("com.facebook.android:facebook-android-sdk:[5,6)")
implementation("androidx.mediarouter:mediarouter:1.0.0")
implementation("androidx.vectordrawable:vectordrawable:1.0.0")
implementation("com.github.barteksc:android-pdf-viewer:3.1.0-beta.1")
implementation("org.apache.commons:commons-io:1.3.2")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.30")
}
}
val androidTest by getting {
dependencies {
implementation(kotlin("test-junit"))
implementation("junit:junit:4.13.2")
}
}
val iosMain by getting {
dependencies {
implementation("io.ktor:ktor-client-ios:$ktorVersion")
implementation("com.squareup.sqldelight:native-driver:1.5.0")
}
}
val iosTest by getting
}
}
apply { plugin("com.google.gms.google-services") }
android {
compileSdkVersion(30)
sourceSets["main"].manifest.srcFile("src//androidMain//AndroidManifest.xml")
defaultConfig {
minSdkVersion(17)
targetSdkVersion(30)
}
}
val packForXcode by tasks.creating(Sync::class) {
val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
val framework = kotlin.targets.getByName<KotlinNativeTarget>("ios").binaries.getFramework(mode)
val targetDir = File(buildDir, "xcode-frameworks")
group = "build"
dependsOn(framework.linkTask)
inputs.property("mode", mode)
from({ framework.outputDirectory })
into(targetDir)
}
tasks.getByName("build").dependsOn(packForXcode)
//dependencies {
// implementation(files("/Users/mbp/AndroidStudioProjects/PashtoLibrary/androidApp/libs/ksoap2-android-assembly-3.3.0-jar-with-dependencies.jar"))
// implementation(files("/Users/mbp/AndroidStudioProjects/PashtoLibrary/androidApp/libs/org.apache.commons.net_2.0.0.v200905272248.jar"))
// implementation(files("/Users/mbp/AndroidStudioProjects/PashtoLibrary/androidApp/libs/picasso-2.5.2.jar"))
// implementation(files("/Users/mbp/AndroidStudioProjects/PashtoLibrary/androidApp/libs/pinchzoom.jar"))
// implementation(files("/Users/mbp/AndroidStudioProjects/PashtoLibrary/androidApp/libs/StartAppInApp-3.4.2.jar"))
//}
sqldelight {
database("LibraryApp"){
packageName = "com.example.app.core.database"
sourceFolders = listOf("db")
dialect="sqlite:3.24"
}
}
Kurt Renzo Acosta
10/04/2021, 1:35 PMArchitecture i386 is not supported for platform iphonesimulator14.5
Joffrey
10/04/2021, 4:52 PMTarika Chawla
10/05/2021, 4:31 PMmain -> fixture -> android/ios
. and the module is in mmain -> kmm -> kmmtestmodule
The pod istall and import works fine, but xcode build fails and I cant call any functions from the kotlin pod.
Xcode Build Error:
build.gradle.kts' line: 3
* What went wrong:
Plugin [id: 'org.jetbrains.kotlin.multiplatform'] was not found in any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (plugin dependency must include a version number for this source)
Konstantin Tskhovrebov
10/05/2021, 5:34 PMCRamsan
10/05/2021, 5:37 PMwillyrs
10/06/2021, 6:39 AManuj
10/06/2021, 12:59 PMkavi
10/07/2021, 2:01 PMassembleXCFramework
– called AnymoCore.xcframework
2. This is then added as a framework to an iOS project (an SDK that I’m creating) which itself produces a framework – called Anymo.framework
3. The final sdk framework is then consumed by apps – currently just a sample/test app
So far my sample app seems to be running fine on the simulator but crashes when trying to run on a device…
dyld: Library not loaded: @rpath/AnymoCore.framework/AnymoCore
Referenced from: /private/var/containers/Bundle/Application/A863B34D-6A54-4D8E-A3A1-69BB07344DE5/iosApp.app/iosApp
Reason: image not found
If i add my xcframework to my test app directly and try to import some code from AnymoCore
(rather than Anymo
) then it works so i think i’m just going wrong at step 2 maybe? I suspect it’s some xcode config or flag that i need to set correctly but am running out of ideas and would appreciate any tips 🙏🏾Brian G
10/07/2021, 3:16 PMJoffrey
10/07/2021, 6:05 PM@BeforeClass
/ @AfterClass
in multiplatform common tests? AFAICT these annotations are JVM-only at the moment 😞
I could add cleanup after each test, but that's a bit overkill, and may not work for every use case.Waqas Tahir
10/07/2021, 7:03 PMMarkRS
10/08/2021, 9:20 AMMJegorovas
10/08/2021, 10:23 AMInt64
to KotlinLong?
, example in thread.Joffrey
10/08/2021, 2:34 PMA compileOnly dependency is used in the Kotlin/Native target 'iosArm64'
The commonMain
source set indeed declares kotlinx-serialization-json
as a compileOnly
dependency. This is what I want for non-native targets (JVM, JS browser, JS node...) because it's supposed to be used this way (I don't want to force this JSON-specific dependency onto users that want to use other serialization formats).
So I have a couple questions:
1. is this actually a problem? I mean, by default it's supposed to compile the native targets to a klib
(not a linked binary) so why is this a problem? Shouldn't it be a problem on the consumer side when actually building a final binary?
2. if it is a problem, how can I solve it? I tried to add this dependency as implementation
inside the iosMain
source set, but it doesn't seem to solve the warning
I'm tempted to just disable the warning with kotlin.native.ignoreIncorrectDependencies=true
but I'd like to understand better if it's really a problem first.Jim
10/08/2021, 5:28 PMhsyogesh
10/08/2021, 7:39 PMMejdi
10/08/2021, 9:00 PMSharedFlow
on iOS, do we need to use the -native-mt
version of kotlinx coroutines ? Same goes with the Mutex
APIs. Both don’t seem to work using the core version of it. I want to verify this before setting any conclusion.
In the docs we set the common
label against them, would that mean that these are supported in all platforms ?Eric Ampire [MOD]
10/09/2021, 12:31 PMpererikbergman
10/09/2021, 2:25 PMCommand PhaseScriptExecution failed with a nonzero exit code
Seem to work from Android Studio, even the iOS build… 🤔
If I dig down a little bit into the logs in XCode I find this:
> Task :shared:linkDebugFrameworkIos FAILED
e: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors
Please try to disable compiler caches and rerun the build. To disable compiler caches, add the following line to the gradle.properties file in the project's root directory:
kotlin.native.cacheKind.iosX64=none
Also, consider filing an issue with full Gradle log here: <https://kotl.in/issue>
The /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld command returned non-zero exit code: 1.
output:
ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/13.0.0/lib/darwin//libclang_rt.ios.a, missing required architecture x86_64 in file /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/13.0.0/lib/darwin//libclang_rt.ios.a (4 slices)
Undefined symbols for architecture x86_64:
"___cpu_model", referenced from:
polyHash_x86(int, unsigned short const*) in libstdlib-cache.a(result.o)
ld: symbol(s) not found for architecture x86_64
FAILURE: Build failed with an exception.
I am totally lost, anyone have any idea or where to start looking?John O'Reilly
10/09/2021, 6:02 PMGrégory Lureau
10/10/2021, 1:38 PMopen class BaseClass(internal val internalVal: String)
class FooBar(val exposedVar: Int) : BaseClass("internalValue")
In Kotlin I only see one and only one FooBar constructor with the Int
param. But the header from XCFramework exposes 2 constructors
__attribute__((swift_name("BaseClass")))
@interface KmpTestBaseClass : KmpTestBase
- (instancetype)initWithInternalVal:(NSString *)internalVal __attribute__((swift_name("init(internalVal:)"))) __attribute__((objc_designated_initializer));
@end;
__attribute__((objc_subclassing_restricted))
__attribute__((swift_name("FooBar")))
@interface KmpTestFooBar : KmpTestBaseClass
- (instancetype)initWithExposedVar:(int32_t)exposedVar __attribute__((swift_name("init(exposedVar:)"))) __attribute__((objc_designated_initializer));
- (instancetype)initWithInternalVal:(NSString *)internalVal __attribute__((swift_name("init(internalVal:)"))) __attribute__((objc_designated_initializer)) __attribute__((unavailable));
@property (readonly) int32_t exposedVar __attribute__((swift_name("exposedVar")));
@end;
I know I could make the BaseClass constructor private to avoid that export, but it doesn't feel adequate to exposes this 2nd constructor on FooBar anyway... What am I missing?
Also I noticed the unavailable
not sure what this means 😕KamilH
10/11/2021, 12:26 PMembedAndSignAppleFrameworkForXcode
task? I’m using Kotlin 1.5.31
and simply I can’t see this task in my shared
module.Gus Ward
10/12/2021, 9:34 AMKotlin 1.5.31
, AGP 4.1.3
and its a library project for iOS & Android.chi
10/12/2021, 10:42 AMval commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
implementation("io.insert-koin:koin-test:${versions.koin}")
implementation("io.insert-koin:koin-test-junit4:${versions.koin}")
implementation("io.mockk:mockk-common:1.12.0")
}
}
What could be wrong here?Danish Ansari
10/12/2021, 2:54 PMraulraja
10/12/2021, 9:19 PMexpect
declarations only in common main and have multiple actual
different impl on each platform. For example 3 JVM modules that provide 3 different actual
impls for the common main and same for other platforms like JS. The use case is that users may define programs over the common library but choose different runtime impl in actual typealias F<A> = CustomImpl<A>
data types for a given expect class depending on how they want their programs to run. Essentially I’d like to push the responsibility to declare the actual typealias
to the user and not be forced to provide an impl myself. Can this be accomplished with multiplatform modules? Any help is appreciated, I realise this is an odd case and potentially trying to abuse expect / actual for ad-hoc resolution. Thanks!raulraja
10/12/2021, 9:19 PMexpect
declarations only in common main and have multiple actual
different impl on each platform. For example 3 JVM modules that provide 3 different actual
impls for the common main and same for other platforms like JS. The use case is that users may define programs over the common library but choose different runtime impl in actual typealias F<A> = CustomImpl<A>
data types for a given expect class depending on how they want their programs to run. Essentially I’d like to push the responsibility to declare the actual typealias
to the user and not be forced to provide an impl myself. Can this be accomplished with multiplatform modules? Any help is appreciated, I realise this is an odd case and potentially trying to abuse expect / actual for ad-hoc resolution. Thanks!Mejdi
10/12/2021, 9:37 PMrusshwolf
10/12/2021, 10:10 PMinterface
rather than an expect class
for this scenario.raulraja
10/13/2021, 3:02 PM