Christian Sousa
04/03/2020, 9:29 AMunresolved reference: platform
in a mpp project? It seems that this happens according to the weather or something like that, sometimes it works fine and I can use autocomplete for the platform
but other time it simply doesn’t. I already tried invalidating caches and restart, tried removing some folder that I saw in a random stackoverflow thread, but it still happens.Christian Sousa
04/03/2020, 11:40 AMGoogleTagManager
DataLayer in a kotlin multiplatform project, and I got it working for the Android easily.
Problem is with iOS, following their guide I need to use the GoogleTagManager cocoapod: https://developers.google.com/tag-manager/ios/v3/swift
I also needed to create a BridgingHeader as their tutorial says.
What I did was:
Create a BridgingHeader.framework myself, with the following headers that are here: https://github.com/jigish/GoogleTagManager/tree/master/GoogleTagManager/Library plus a BridgingHeader-umbrella.h as follows:
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
#import "TAGManager.h"
#import "TAGContainer.h"
#import "TAGContainerOpener.h"
#import "TAGDataLayer.h"
#import "TAGLogger.h"
Added a module.modulemap like so:
framework module BridgingHeader {
export *
umbrella header "BridgingHeader-umbrella.h"
header "TAGContainer.h"
header "TAGContainerOpener.h"
header "TAGContainerOpener.h"
header "TAGDataLayer.h"
header "TAGLogger.h"
header "TAGManager.h"
}
And my BridgingHeader.def is:
language = Objective-C
modules = BridgingHeader
compilerOpts = -framework BridgingHeader
linkerOpts = -framework BridgingHeader
But it doesn’t seem right. Anyone had something similar like this that could provide some insight?
Also, thanks to @magnumrocha for his help with this issue before 🙂John O'Reilly
04/03/2020, 8:53 PMushort
04/04/2020, 2:56 AMjudrummer
04/04/2020, 2:53 PMKweku
04/04/2020, 3:25 PMDamiano Giusti
04/04/2020, 7:47 PMCould not find method npm() for arguments [cheerio] on object of type org.jetbrains.kotlin.gradle.plugin.mpp.DefaultKotlinDependencyHandler.
I’m using the Groovy DSLritesh
04/05/2020, 10:11 AMGunslingor
04/06/2020, 3:24 AMphldavies
04/06/2020, 8:55 AMChristian Sousa
04/06/2020, 4:00 PM.framework
into one single file? So I wouldn’t need to provide both versions, one for simulator and one for devices.
I tried using the following script:
# create folder where we place built frameworks
mkdir build
# create folder to store compiled framework for simulator
mkdir build/simulator
# copy compiled framework for simulator into our build folder
cp -r debugFramework/MyLib.framework build/simulator
# create folder to store compiled framework for simulator
mkdir build/devices
# copy compiled framework for simulator into our build folder
cp -r releaseFramework/MyLib.framework build/devices
# create folder to store compiled universal framework
mkdir build/universal
####################### Create universal framework #############################
# copy device framework into universal folder
cp -r build/devices/MyLib.framework build/universal/
# create framework binary compatible with simulators and devices, and replace binary in unviersal framework
lipo -create build/simulator/MyLib.framework/MyLib build/devices/MyLib.framework/MyLib -output build/universal/MyLib.framework/MyLib
# copy simulator Swift public interface to universal framework
cp build/simulator/MyLib.framework/Modules/MyLib.swiftmodule/* build/universal/MyLib.framework/Modules/MyLib.swiftmodule
But it fails with:
fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: build/simulator/MyLib.framework/MyLib and build/devices/MyLib.framework/MyLib have the same architectures (x86_64) and can't be in the same fat output file
Sean Keane
04/06/2020, 5:44 PMUnresolved reference: json
Unresolved reference: json
Unresolved reference: JsonFeature
Unresolved reference: serializer
Unresolved reference: KotlinxSerializer
Unresolved reference: JsonFeature
Unresolved reference: serializer
Unresolved reference: KotlinxSerializer
Every time I build I get the above errors.
As far as I can see im not missing anything and my IDE doesnt complain.
These are the dependacies I have installed.
const val kotlin = "1.4-M1"
const val ktor = "1.3.2-1.4-M1-2"
const val coroutinesCore = "1.3.5-1.4-M1"
const val serializationCommon = "0.20.0-1.4-M1"
The network request itself is very simple.
private val client: HttpClient by lazy {
return@lazy HttpClient {
install(JsonFeature) {
serializer = KotlinxSerializer()
}
}
}
override fun getVersion(onSuccess: (Version) -> Unit, onError: (KarhooError) -> Unit) {
coroutineScope.launch {
val resp: Version = client.get(VERSION_METHOD)
onSuccess.invoke(resp)
}
}
The imports are added with no issues and I can see the build libs. Just very lost as to why it can't locate the files during a build?Gunslingor
04/06/2020, 8:33 PMcoletz
04/06/2020, 9:54 PMOlenyov Kirill
04/06/2020, 9:59 PMGunslingor
04/07/2020, 5:05 PMJess Brent
04/07/2020, 7:44 PMinline fun <reified T> withResult(
method: Result<T>,
onFailure: (errors: List<Throwable>) -> Unit
): T {
@Suppress("IMPLICIT_CAST_TO_ANY")
val methodResult = when (method) {
is Result.Success -> { method.t }
is Result.Failure -> { onFailure.invoke(method.errors) }
}
return methodResult as T
}
usage:
val r = withResult(method) { return Result.Failure(it) }
i can get this function to work on jvm, however it does not work on js. it results in a ClassCastException
the transpiled js appears to show that instead of invoking onFailure
it is only assigned to methodResult
.
also, this is a custom sealed class Result
not kotlin.Result
i’m hoping i’m missing something obvious here. 😅Gunslingor
04/08/2020, 6:24 AMGunslingor
04/08/2020, 8:57 AMedenman
04/08/2020, 9:51 PMNikolay Kasyanov
04/09/2020, 6:53 AMiosX64Main { ...dependencies... }
iosArm64Main {
dependsOn iosX64Main
}
with this:
ios {
iosArm64Main.dependsOn it
iosX64Main.dependsOn it
...dependencies...
}
moving iOS-only source files from iosX64Main
to ios
folder accordingly.
Now all imports starting with platform.
are highlighted red in the IDE all the time, builds fine though. Is this a known issue?ivano
04/09/2020, 7:19 AMKevin S
04/09/2020, 1:25 PMduplicate symbols for architecture
error since there are two versions of things like Kotlin.Any
Christian Sousa
04/09/2020, 1:57 PMbuild.gradle.kts
like:
android {
...
...
compileOptions {
kotlinOptions {
...
}
}
}
But I get unresolved reference to kotlinOptions.. anyone can give a little help? Thanks!Olenyov Kirill
04/09/2020, 2:20 PMsaket
04/09/2020, 7:38 PMcurioustechizen
04/10/2020, 12:56 PMsyncFramework
gradle task manually? Where do all the parameters for it come from? ($HEADER_SEARCH_PATHS
, $OTHER_CFLAGS
etc)?
My objective is to build the framework manually and publish it to a remote cocoapods repo.taso
04/10/2020, 1:59 PMGunslingor
04/10/2020, 7:21 PMcurioustechizen
04/11/2020, 10:30 AMcurioustechizen
04/11/2020, 10:30 AMeskatos
04/11/2020, 10:48 AMkotlin-test
. Then with >= 1.3.70 you’ll be able to run them in an ios simulator out of the box.curioustechizen
04/11/2020, 10:49 AMeskatos
04/11/2020, 10:49 AMhttps://d3nmt5vlzunoa1.cloudfront.net/kotlin/files/2021/02/js-native-test.gif▾
basher
04/11/2020, 2:30 PM