kevin.cianfarini
02/14/2022, 9:35 PMkotlinx.uuid
library? I know we want to keep the Kotlin stdlib small, but not having an ecosystem default for utilities as universal as UUID makes fragmentation within the ecosystem annoying for library maintainers.
I know in the past there was a prior discussion about absorbing the above library into the stdlib, which Jetbrains was receptive to, but it didn't seem to go anywhere. I'd like to revisit this issue 🙂kierans777
02/15/2022, 5:55 AMsuspend
functions? For example if I have a Kotlin function
suspend fun doSomething(something: suspend (String) -> String): String {
...
something("hello")
...
return "world"
}
I want to write a function in Swift and pass it to the Kotlin function ie:
let swiftSomething = // create a Swift function
ModuleKt.doSometthing(swiftSomething)
However I'm not sure if that sort of idea is possible, or how to go about implementing it.wbertan
02/15/2022, 12:02 PM1.5.31
to Kotlin 1.6.10
, and we are having an issue where the bitcode
is not being included 👀
:x: ld: bitcode bundle could not be generated because '/Users/me/project-native/modules/iosframework/build/xcode-frameworks/Debug/iphoneos15.0/SharedCode.framework/SharedCode' was built without full bitcode. All frameworks and dylibs for bitcode must be generated from Xcode Archive or Install build file '/Users/me/project-native/modules/iosframework/build/xcode-frameworks/Debug/iphoneos15.0/SharedCode.framework/SharedCode' for architecture arm64
:x: clang: error: linker command failed with exit code 1 (use -v to see invocation)
Our config is:
kotlin {
ios {
binaries {
framework {
baseName = "SharedCode"
embedBitcode(BitcodeEmbeddingMode.BITCODE)
Found this message about the same case: https://kotlinlang.slack.com/archives/C3PQML5NU/p1639075566171200
Could it be a regression in the plugin?Grégory Lureau
02/15/2022, 3:38 PMAdrian Witaszak
02/15/2022, 5:28 PM** BUILD FAILED **
The following build commands failed:
PhaseScriptExecution Run\ Script /Users/adrianwitaszak/Projects/KMP/MyApplication/build/ios/iosApp.build/Debug-iphonesimulator/iosApp.build/Script-7555FFB5242A651A00829871.sh (in target 'iosApp' from project 'iosApp')
> Task :shared:linkDebugFrameworkIosX64 FAILED
e: Compilation failed: Could not initialize class llvm.llvm
* Source files:
* Compiler version info: Konan: 1.6.10 / Kotlin: 1.6.10
* Output kind: FRAMEWORK
e: java.lang.NoClassDefFoundError: Could not initialize class llvm.llvm
Igor Milakovic
02/15/2022, 10:33 PMinterface SignInUseCase {
@Throws(Exception::class)
suspend fun execute(email: String, password: String): Whatever
}
When I call this from iOS, I get
signInUseCase.execute(email: email, password: password) { whatever, error in
// Handle completion
}
Is there a way to have a custom error here, instead of NSError? Ideally, I'd like to have maybe a class or data class
data class Error(
val title: String
val detail: String
}
Sterling Albury
02/16/2022, 9:06 AMmoduleA
and then moduleB
which has A as a dependency. moduleA
has InterfaceA
and a class that returns this type, class A { fun getInterfaceA(): InterfaceA = SomeImpl() }
, and in moduleB
, I have a class that takes this interface as a param, so class B(interfaceA: InterfaceA)
.
Now over in iOS land, I have a class Foo
with an instance of class B
like so, let var beeClass: B = B(interfaceA: interfaceA)
where interfaceA
is a member variable assigned during init, so var interfaceA: InterfaceA
and init(interfaceA: InterfaceA) { self.interfaceA = interfaceA }
.
Lastly, when I try to create in instance of Foo
with the help of an instance of class A
like so, lazy var foo: Foo = Foo(a.getInterfaceA())
,
I get complaints from xcode about the argument types not conforming to the expected types because InterfaceA
is now called AInterfaceA
. Moreover, if I go to the definition of class B
in xcode, InterfaceA
is named something like BAInterfaceA
. Casting only seems to cause the app to crash and that's what xcode is suggesting I do.
not sure if anyone followed that and has some idea what is going on. is there maybe some way to help the kotlin compiler with binding names or something? This doesn't really feel like a situation where the compiler should be changing the name of this interface and almost wonder if this could be a bugCharles Prado
02/16/2022, 11:50 AMInstanceCreateException
on my iOS app when I try to do a request to an API from the shared module.
Uncaught Kotlin exception: org.koin.core.error.InstanceCreationException: Could not create instance for [Singleton:'com.test.remote.BookingApi']
Any idea why this is not being recognized on the iOS-side? (My Koin.kt
and BookingAPI.kt
files are described in the thread),Nathan Bedell
02/16/2022, 1:54 PMKotlin {
platformA {
// apply plugins for platformA here
}
platformB {
// apply plugins for platformB here
}
}
but this seems to cause issues. Right now, I get the error "The java plugin has been applied, but it is not compatible with the Android plugins".
It seems as though it is trying to apply the plugins during the initial gradle config, not when building a specific platform.
Is it possible to do what I am trying to do here?Roger Kreienbühl
02/17/2022, 7:18 AMld: building for iOS Simulator, but linking in dylib built for iOS, file '../../../../../shared/build/bin/iosArm64/debugFramework/shared.framework/shared' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
> Task :iosApp:buildIosAppMain FAILED
The following build commands failed:
Ld /Users/rogerkreienbuehl/Programmieren/HelloWorld/iosApp/build/bin/iosApp/Debug-iphonesimulator/HelloWorld.app/HelloWorld normal (in target 'iosApp' from project 'iosApp')
(1 failure)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':iosApp:buildIosAppMain'.
> Process 'command 'xcrun'' finished with non-zero exit value 65
I work on a MacBook Pro M1 with macOS 12.1 and xCode 13.2.1.
How can I fix this linking error?darkmoon_uk
02/17/2022, 11:20 AMkevin.cianfarini
02/17/2022, 4:03 PMe: java.lang.AssertionError: typeParameters = [] size != typeArguments = [org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl@ccfbb239, org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl@6b488739] size
at org.jetbrains.kotlin.ir.overrides.IrOverridingUtilKt.buildFakeOverrideMember(IrOverridingUtil.kt:70)
at org.jetbrains.kotlin.ir.overrides.FakeOverrideBuilderStrategy.fakeOverrideMember(IrOverridingUtil.kt:28)
at org.jetbrains.kotlin.ir.overrides.IrOverridingUtil.buildFakeOverridesForClass(IrOverridingUtil.kt:148)
at org.jetbrains.kotlin.backend.common.overrides.FakeOverrideBuilder.buildFakeOverrideChainsForClass(FakeOverrides.kt:104)
at org.jetbrains.kotlin.backend.common.overrides.FakeOverrideBuilder.provideFakeOverrides(FakeOverrides.kt:166)
at org.jetbrains.kotlin.backend.common.overrides.FakeOverrideBuilder.provideFakeOverrides(FakeOverrides.kt:174)
at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker.postProcess(KotlinIrLinker.kt:207)
at org.jetbrains.kotlin.ir.backend.js.KlibKt.loadIr(klib.kt:351)
at org.jetbrains.kotlin.ir.backend.js.KlibKt.loadIr$default(klib.kt:232)
at org.jetbrains.kotlin.ir.backend.js.CompilerKt.compile(compiler.kt:97)
at org.jetbrains.kotlin.ir.backend.js.CompilerKt.compile$default(compiler.kt:42)
at org.jetbrains.kotlin.cli.js.K2JsIrCompiler.doExecute(K2JsIrCompiler.kt:306)
at org.jetbrains.kotlin.cli.js.K2JSCompiler.doExecute(K2JSCompiler.java:182)
at org.jetbrains.kotlin.cli.js.K2JSCompiler.doExecute(K2JSCompiler.java:75)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:92)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1574)
at jdk.internal.reflect.GeneratedMethodAccessor101.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
colintheshots
02/17/2022, 7:59 PMimplementation(project(":shared"))
at the top of my Android build.gradle.kts
file’s dependencies list. The project builds and runs fine, but I get syntax errors in the IDE, Problems pane, and when I try to commit it warns me about all of the fake errors in changed files. This started when I first upgraded to Bumblebee. The same issues do not occur with any code referenced from commonMain. Does anyone have any ideas how I can resolve this?jean
02/17/2022, 9:44 PMCould not open init generic class cache for initialization script ‘/private/var/folders/1f/_13x62m52cd0b42d6ss7kpy00000gn/T/wrapper_init.gradle’ (/Users/jeantuffier/.gradle/caches/7.1/scripts/dpq13m6f9134zige235n01ule).
> BUG! exception in phase ‘semantic analysis’ in source unit ‘_BuildScript_’ Unsupported class file major version 61
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
David Nedrow
02/18/2022, 3:41 AMkhairil.ushan
02/18/2022, 6:51 AMShowing All Messages
> Task :mylibrary:embedAndSignAppleFrameworkForXcode FAILED
/Users/username/Library/Developer/Xcode/DerivedData/MyApp-macOS-bcjmruopehjfwogkwonshzamndam/Build/Products/Debug/MyApp-macOS.app/Contents/Frameworks/MyLibrary.framework/MyLibrary: replacing existing signature
/Users/username/Library/Developer/Xcode/DerivedData/MyApp-macOS-bcjmruopehjfwogkwonshzamndam/Build/Products/Debug/MyApp-macOS.app/Contents/Frameworks/MyLibrary.framework/MyLibrary: bundle format is ambiguous (could be app or framework)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':mylibrary:embedAndSignAppleFrameworkForXcode'.
> Process 'command 'codesign'' finished with non-zero exit value 1
Is there anything extra that I should do to link the framework to the macOS app properly?ynsok
02/18/2022, 11:50 AMMatti MK
02/18/2022, 1:00 PMspierce7
02/18/2022, 4:41 PMDispatchers.Main
right?bod
02/18/2022, 5:14 PMInheritance from an interface with '@JvmDefault' members is only allowed with -Xjvm-default option
error when implementing an interface which doesn’t have any default methods (okio’s Source) 🤔. What am I missing?
(have this on an MP project, works without issue on a regular JVM project)Matti MK
02/18/2022, 9:49 PMKtor
HttpClient
.
Tests work just fine on Android, but on iOS getting:
kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen kotlinx.coroutines.test.TestScopeImpl@338a688
I pretty much copy+pasted the ktor test sample. Source in comments. Any tips would be welcome 👍Michael Paus
02/19/2022, 11:49 AM<https://youtrack.jetbrains.com/issue/KTIJ-18408>
but the mentioned workaround does not work for me because I cannot build my project anymore if I apply it. I wonder though why nobody else seems to care and why this bug is flagged as obsolete. I am using the latest EA build of IntelliJ in a multi-platform Compose project (desktop & android) which was basically created from the IntelliJ template.Alen Kirm
02/20/2022, 9:31 AMConrad Kramer
02/20/2022, 11:25 PMlibllvmstubs.dylib
stub is seemingly not ABI stable, because it fails to load:
$ ./gradlew :Shared:linkReleaseFrameworkIosArm64
…
> Task :Shared:linkReleaseFrameworkIosArm64 FAILED
e: Compilation failed: Can't load library: /Users/conradev/.konan/kotlin-native-prebuilt-macos-aarch64-1.6.10/konan/nativelib/3037511274092129360/libllvmstubs.dylib
* Source files:
* Compiler version info: Konan: 1.6.10 / Kotlin: 1.6.10
* Output kind: FRAMEWORK
e: java.lang.UnsatisfiedLinkError: Can't load library: /Users/conradev/.konan/kotlin-native-prebuilt-macos-aarch64-1.6.10/konan/nativelib/3037511274092129360/libllvmstubs.dylib
…
the underlying link error seems to be something like this (in libc++):
error: dlopen(/Users/conradev/.konan/kotlin-native-prebuilt-macos-aarch64-1.6.10/konan/nativelib/3037511274092129360/libllvmstubs.dylib, 0x0002): Symbol not found: __ZNKSt3__114error_category10equivalentERKNS_10error_codeEi
Referenced from: /Users/conradev/.konan/kotlin-native-prebuilt-macos-aarch64-1.6.10/konan/nativelib/3037511274092129360/libllvmstubs.dylib
Expected in: unknown
Conrad Kramer
02/21/2022, 6:18 AMassembleAppleFrameworkForXcode
somewhere. I needed to use it to depend on a Kotlin framework from an iOS framework, because embedAndSignAppleFrameworkForXcode
only works in app targetsStefan Oltmann
02/21/2022, 8:18 AMAndrew O Hart
02/21/2022, 5:04 PMSterling Albury
02/21/2022, 6:41 PMstately
questions. So I have an object with two IsolateState
fields and two setter functions:
object FooIos {
actual val fooList = IsolateState { mutableListOf<MyInterface>() }
actual val fooString = IsolateState { DataClassWithVarStringField("") }
actual fun setStringValue(fooStringValue: String) {
fooString.access { it.varField = fooStringValue }
}
actual fun addMyInterfaceCollection(myInterfaceCollection: Collection<MyInterface>) {
fooList.access { it }.addAll(myInterfaceCollection.toList())
}
actual fun doStuff() {
fooList.access { item -> // fooList is empty
println("fooList item: $item")
}
explicitTag.access { objWithStr ->
println("objWithStr: $objWithStr") // not empty...prints expected value
}
}
}
So far this seems to work. I set the values on the main thread and I can see that the fields are populated, however, later on when I try to use these, fooList is empty regardless of what thread I'm on. I've been trying a number of different things but for some reason I keep loosing the list. What am I missing? I haven't tried the stately collections yet.
Second thing is when I try to access the stately field like val strValue = fooString.access { it }
, it crashes. The exception is
FreezingException: freezing of Ok(result=DataClassWithVarStringField(varField=test)) has failed, first blocker is DataClassWithVarStringField(varField=test)
Tony Kazanjian
02/22/2022, 2:05 AMNativeViewModel
and have my iOS network implementation done separately in an interface using URLSession
. Is there anything within the Kotlin/Native concurrency model that makes calling a URLSession
with a completion handler callback impossible? I'm pretty sure I've done everything I can to make my data state immutable.
class SearchViewModel(
private val repository: SearchRepository,
private val onSearchState: (SearchState) -> Unit
): KoinComponent {
private val scope = MainScope(Dispatchers.Main)
private val _searchStateFlow = MutableStateFlow(SearchState())
init {
ensureNeverFrozen()
observeQueries(_searchStateFlow.value.query)
}
@OptIn(FlowPreview::class)
@Throws(Exception::class)
fun observeQueries(query: String) {
_searchStateFlow.value = SearchState(
query = query,
isLoading = true)
scope.launch {
repository.searchGames(_searchStateFlow.asStateFlow())
.collect { state ->
onSearchState(state)
}
}
}
}
The error happens on the completion handler that is called in the IOSSearchInteractor
's URLSession callback:
class IOSSearchInteractor: SearchInteractor {
func searchGames(query: String, completion: @escaping (Result<String, Error>) -> Void) {
var request ...
let task = URLSession.shared.dataTask(with: request) { data, response, error in
// error happens here on completion handler
let str = String(decoding: data!, as: UTF8.self)
completion(.success(str))
}
task.resume()
}
vishal G
02/22/2022, 6:37 AMvishal G
02/22/2022, 6:37 AMalex009
02/22/2022, 1:46 PMvishal G
02/22/2022, 1:48 PMDavid Nedrow
02/23/2022, 6:53 PM