Franco
09/12/2020, 1:44 AMTim Malseed
09/12/2020, 5:41 AMshared
and desktop
.
'Shared' is the typical multiplatform
gradle project, declaring commonMain
and jvmMain
sourcesets.
'Desktop' depends on 'shared', via:
implementation(project(":shared"))
However, the 'shared' source files don't seem to be available to the 'desktop' module. Do I need to do something special to 'publish' shared, or otherwise make it accessible to other modules?Franco
09/12/2020, 8:08 AMIgnoring dependency of module <MPP Lib> on module <JVM Module>. Java modules cannot depend on Android modules
Any idea why this would happen?
It seems like the JVM module is trying to import the Android target of the multiplatform library instead of the JVM one.louiscad
09/12/2020, 11:31 AMThe Kotlin source set androidAndroidTestRelease was configured but not added to any Kotlin compilation. You can add a source set to a target's compilation by connecting it with the compilation's default source set using 'dependsOn'.
See <https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html#connecting-source-sets>
dan.the.man
09/12/2020, 6:05 PMankushg
09/13/2020, 1:42 AMbod
09/13/2020, 1:57 PMUnresolved reference assertEquals
in my unit tests. I have these dependencies:
commonTest {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
Googling a bit it looks like I'm not the only one [1] - but I'm a bit surprised, this seems like a major problem. So I guess my question is: does anyone have a basic example project, with tests, that works?
[1] = https://youtrack.jetbrains.com/issue/KT-40571william
09/13/2020, 3:50 PMIbrahim Ali
09/14/2020, 11:35 AMval commonMain by getting {
dependencies {
implementation("org.jsoup:jsoup:1.13.1")
}
}
Maximilian Fehrentz
09/15/2020, 7:28 AMaleksey.tomin
09/15/2020, 9:08 AMcocoapods
into build.gradle.kts
2. I’ve called build
3. I’ve called podspec
and library.podspec
was created
4. I’ve called podBuildDependenciesMacos
podSetupBuildMacos
- was created cocoapods dir with framework
5. I’ve called podInstall
- but was not pod into list: $ pod list
returns 0 pods were found
. What do I wrong?
How can I create library for use in Xcode?Daniele B
09/15/2020, 3:51 PMStateFlow
!!!
I can easily say 85% of the code is on Kotlin Multiplatform, and 15% only on the platform-specific declarative UI (Compose and SwiftUI)!
on Android, it uses Compose's `collectAsState`:
@Composable
fun MainLayout(coreModel: CoreViewModel) {
val appState by coreModel.stateFlow.collectAsState()
...
}
on iOS, it uses a very simple class extending ObservableObject
, where a StateFlow “listener” is initialized:
class AppViewModel: ObservableObject {
let coreModel : CoreViewModel = CoreViewModel()
@Published var appState : AppState = AppState()
init() {
coreModel.onChange { newState in
self.appState = newState
}
}
}
this is the shared `ViewModel`:
class CoreViewModel {
internal val mutableStateFlow: MutableStateFlow(AppState())
val stateFlow: StateFlow<AppState>
get() = mutableStateFlow
fun onChange(provideNewState: ((AppState) -> Unit)) {
stateFlow.onEach {
provideNewState.invoke(it)
}.launchIn(CoroutineScope(Dispatchers.Main))
}
}
diesieben07
09/15/2020, 4:59 PMposix
in code shared between Linux/OSX. However I cannot get this to work at all. I have set kotlin.mpp.enableGranularSourceSetsMetadata=true
and kotlin.native.enableDependencyPropagation=false
like described in the docs. Then I have created a nativeMain
source set:
val nativeMain by creating {
dependsOn(commonMain)
}
Then I have configured the linuxX64Main
and osxX64Main
source sets to depend on nativeMain
. However I still cannot use posix
in nativeMain
.
This issue happens both when trying to compile with Gradle as well as in IntelliJ (types / functions cannot be resolved).
What am I missing?Matteo Wohlrapp
09/16/2020, 6:34 AMMaximilian Fehrentz
09/16/2020, 8:45 AMChristian Jensen
09/16/2020, 9:51 AMAlberto
09/16/2020, 2:24 PMChristopher Elías
09/16/2020, 4:55 PMzalewski.se
09/17/2020, 3:47 AMoutput:
Undefined symbols for architecture x86_64:
"_objc_setHook_setAssociatedObject", referenced from:
_platform_objc_objc_setHook_setAssociatedObject_wrapper100 in libobjc-cache.a(result.o)
(maybe you meant: _platform_objc_objc_setHook_setAssociatedObject_wrapper100, knifunptr_platform_objc100_objc_setHook_setAssociatedObject )
ld: symbol(s) not found for architecture x86_64
Any idea how to fix this? 😓Elka
09/17/2020, 4:58 AMIvann Ruiz
09/17/2020, 5:24 PMCoroutineDispatcher
I'm using for iOS. There's a few variants out there, but this specific implementation allows for using delay()
calls in suspend function. I keep this object inside my SharedViewModel
and use it to define the viewModelScope
for iOS coroutines.Daniele B
09/17/2020, 5:54 PMAndroid
and iOS
, I was able to run the shared ViewModel on Web
too!
I admit I never used React
before, but with Kotlin it was incredibly easy to setup it up!
I was actually thinking to use Vue.js
for the web, because I was interested in a lightweight web framework, whose main capability is to provide a declarative UI, similar to what Compose and SwiftUI provide in mobile.
But I was not aware of how simple Kotlin makes it to work with React! I am still astonished now.
Kotlin hides most React complexity, and Android Studio even spins a node.js server on localhost to test the app, with no setup!
My project uses a shared ViewModel, which means that changes to the app state only happen in the shared code.
Such changes are then propagated via StateFlow
to the platform-specific app code.
In Kotlin/React it’s as simple as this to observe the app state changes via StateFlow:
fun myAppState() : AppState {
val appDependencies = useContext(AppDependenciesContext)
val (state, setState) = useState(appDependencies.coreModel.stateFlow.value)
useEffectWithCleanup {
val job = appDependencies.coreModel.stateFlow.onEach { setState(it) }.launchIn(GlobalScope)
return@useEffectWithCleanup { job.cancel() }
}
return state
}
jean
09/18/2020, 12:21 PMpublishing {
publications {
MyPublication(MavenPublication) {
from components.java
groupId 'org.jfrog.gradle.sample'
artifactId 'gradle-project'
version '1.1'
}
}
}
Where does MyPublication
comes from?Samuel Michael
09/18/2020, 1:53 PMAntónio Bastião
09/18/2020, 2:08 PMVivek Subramanian
09/18/2020, 5:20 PMld: warning: ignoring file /Users/vivek/AndroidStudioProjects/kmm-sample/shared/build/xcode-frameworks/shared.framework/shared, building for iOS Simulator-arm64 but attempting to link with file built for iOS Simulator-x86_64
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_SharedGreeting", referenced from:
objc-class-ref in ContentView.o
"_OBJC_CLASS_$_SharedCalculatorCompanion", referenced from:
objc-class-ref in ContentView.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I am able to open the xcodeproject in XCode and run it on the iphone Simulator there.jeggy
09/19/2020, 10:42 PMallprojects
and this works fine, but as soon as I add a include
to my settings.gradle.kts
file I immedietally get this error: Extension with name 'kotlin' does not exist. Currently registered extension names: [ext]
.
Does anyone know how to setup a multiplatform multi project using kotlin gradle script? or is this something that's not possible yet?Samuel Michael
09/20/2020, 4:58 PMSamuel Michael
09/20/2020, 6:40 PMSiggi Gunnarss
09/21/2020, 1:50 PMReason: AMDeviceSecureInstallApplicationBundle failed with err = -402653177(The argument is invalid.)
The error is similar to https://youtrack.jetbrains.com/issue/OC-17572 which is no longer valid.Siggi Gunnarss
09/21/2020, 1:50 PMReason: AMDeviceSecureInstallApplicationBundle failed with err = -402653177(The argument is invalid.)
The error is similar to https://youtrack.jetbrains.com/issue/OC-17572 which is no longer valid.Samuel Michael
09/21/2020, 2:58 PMxcodebuild -project ...
command it is running in the terminal and see if there is any additional debugging infoSiggi Gunnarss
09/22/2020, 6:51 AMJake
09/22/2020, 12:38 PMSiggi Gunnarss
09/23/2020, 6:58 AM