Dominaezzz
02/08/2019, 11:02 PMjuancho
02/10/2019, 2:35 PMiosX64("ios") {
compilations.main.outputKinds("framework")
binaries {
framework {
export "org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:0.10.0"
}
}
}
My question:
Is there any way that I can avoid doing this and add this dependency in the iOS project? (using the kotlinx repository which is bintray right now)
I’m asking this as I would like to start creating more Frameworks that depends on this serialization runtime but I don’t want to include it in every framework, specially if those frameworks are going to be used in the same iOS project.jmullin
02/10/2019, 7:06 PMJoakimForslund
02/11/2019, 8:26 AMmain
to something else from the build script? Im guessing there is something better than rename the output files afterwards?Nico Buescher
02/12/2019, 1:36 AMtypedef struct {
const char *str;
} Example;
What is the intended way to store a string literal in str
from Kotlin?
Using "String".cstr
doesn't work since str
is a CPointer<ByteVar>
, and String.cstr
is a CValues<ByteVar>
, and when I use memScoped { ... }
with getPointer(memScope)
, the CString is obviously freed as soon as the scope is finished, leaving me with an empty string in the struct member.Roman
02/12/2019, 9:26 AMmarchuck
02/12/2019, 10:34 AM(String)-> Unit
it messes in Swift files into KotlinUnit
object. Can I deal with this in more elegant way?conner
02/12/2019, 3:06 PMRoman
02/13/2019, 3:54 AMdef
. Great, I found examples of usage
http://asmcourse.cs.msu.ru/wp-content/uploads/2013/04/gcc-inline-asm.pdf
https://ru.stackoverflow.com/questions/829868/%D0%90%D1%81%D1%81%D0%B5%D0%BC%D0%B1%D0%BB%D0%B5%D1%80%D0%BD%D0%B0%D1%8F-%D0%B2%D1%81%D1%82%D0%B0%D0%B2%D0%BA%D0%B0-%D0%B2-%D0%A1%D0%B8
but an error crashes:
<inline asm>2️⃣11: error: unknown token in expression
mov eax, %ecx
^
<inline asm>3️⃣11: error: unknown token in expression
add eax, %edx
^
<inline asm>4️⃣6: error: unknown token in expression
mov %ecx, eax
^
LLVM ERROR: Error parsing inline asm
Prompt is a mistake in the syntax or you still can not do so.
This is the def
file itself:
---
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
int prin() {
int a = 1;
int b = 2;
int c;
__asm(".intel_syntax noprefix\n\t" // директива GAS, включаем Intel синтаксис.
"mov eax, %1\n\t" // перемещаем в eax значение переменной a.
"add eax, %2\n\t" // прибавляем значение переменной b к eax.
"mov %0, eax\n\t" // перемещаем в переменную c значение eax.
:"=r"(c) // список выходных параметров.
:"r"(a), "r"(b) // список входных параметров.
: "eax" // список разрушаемых регистров.
);
printf("%d + %d = %d\n", a, b, c);
return 0;
}ivan.savytskyi
02/13/2019, 5:27 PMbob
02/13/2019, 7:21 PMspierce7
02/13/2019, 11:29 PMRoman
02/14/2019, 11:47 AMsafa
02/14/2019, 12:31 PM.so
KN runtime? Under the hood, I see program.bc runtime.bc and hello.bc being combined and linked. Our project needs to generate a lot of shared libs for interop and runtime loading, and it quickly grows in size considering the same stuff being put into all of them. Ideally I'd look into generating a shared runtime and lightweight libraries that are dynamically linked to that.
@olonho @svyatoslav.scherbina @jb.igor.chevdar thanksahmedre
02/14/2019, 1:54 PMfromPreset(presets.iosX64, 'ios') {
compilations.main.outputKinds('FRAMEWORK')
}
in order to get one framework, but I notice that:
1. I have to have code within this module in order for it to build a framework
2. the framework doesn’t include the dependencies
I’ve tried also adding the set of dependencies explicitly under iosMain
(with api
instead of implementation
and the implementation
counterparts in commonMain
), and tried adding a block with:
iosX64("ios").binaries {
framework {
export project(":one")
export project(':two')
export project(":three")
transitiveExport = true
}
}
but the framework i am getting only has the files from this specific module without the dependencies. if i explicitly reference a class from one of these dependent modules, the header file that is generated grows, but i want a way to include them without manually referencing something from each module.
may someone point me to the right direction on how to combine the klibs from these multiple modules into one single iOS framework?kpgalligan
02/14/2019, 3:33 PMSlackbot
02/14/2019, 3:55 PMDiego
02/14/2019, 4:59 PM./gradlew clean build
I got the following error:
> Task :common:linkTestDebugExecutableIOS
ld: framework not found MyUtils
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld invocation reported errors
Here is the iOS part of my build.gradle
file:
kotlin {
targets {
fromPreset(presets.iosArm32, 'iOS') {
def frameworksDir = "${projectDir}/Frameworks"
binaries {
framework("p2p_common") {
linkerOpts "-F${frameworksDir}"
}
}
compilations.main.extraOpts '-Xembed-bitcode-marker'
compilations.main.cinterops {
MyUtils {
defFile "src/iOSMain/c_interop/MyUtilsFramework.def"
packageName "com.acme.utils"
includeDirs "${frameworksDir}/MyUtils.framework/Headers"
}
}
}
fromPreset(presets.android, 'android')
}
...
MyUtilsFramework.def
language = Objective-C
headers = MyUtils-Swift.h
compilerOpts = -framework MyUtils
linkerOpts = -framework MyUtils
excludeDependentModules = true
I can see the p2p-common-cinterop-MyUtils.klib
is generated and actually I can see the classes of the framework from the kotlin code inside the folder iOSMain
but as I said before the build fails.
Has anyone a clue why this happens and how I can fix this problem?Nathan
02/14/2019, 7:53 PMDiego
02/15/2019, 5:02 PM@objc
. I updated my build.gradle file to add the cinterops
configuration and the problem is that when I try to build the project I get the following error:
> Task :p2p-common:cinteropCryptoCocoaIOS FAILED
Exception in thread "main" java.lang.Error: CryptoCocoa.framework/Headers/CryptoCocoa-Swift.h:203:4: error: expected a type
[CryptoCocoa-Swift.h
](https://gist.github.com/dfpalomar/0322a839ba2bd4b5959be3ca9d58c3eb#gistcomment-2837982) is a file generated by Xcode. The line 203 is - (NSData * _Nonnull)generateAESKeyWithKeySize:(NSInteger)keySize SWIFT_WARN_UNUSED_RESULT;
Am I using an unsupported swift feature? Any idea about how can I sort this out?conner
02/15/2019, 8:24 PMKClass.members
is available on native, but https://github.com/JetBrains/kotlin-native/blob/master/runtime/src/main/kotlin/kotlin/reflect/KClass.kt seems to suggest otherwise (and I cannot compile). Is this a mismatch in documentation, or am I somehow using it incorrectly? I'm using gradle with kotlin 1.3.21Landerl Young
02/16/2019, 4:46 AMMarkup Sweep
algorithm to detect dead code. But I found that the shrink phase must be operated on bit code instead of IR in order to shrink library code.
However the bitcode contains much more data than simply class and methods (lke java byte code), which makes the shrink phase much hard.
Especially the TypeInfo, OC export, CStubs, etc... That makes Class/Function removal more hard.
And also, it seems impossible to remove virtual methods, since which would change the vtable structure, and make the existing method index invalid.
I’m new to K/N compiler (but experienced on K/N itself), the compiler do steps like SourceCode -> PSI -> IR -> bitcode.
I’m curiousied that what is the IR. Is it LLVM-IR, or just a Jetbrain defined IR shared with Kotlin/JVM?
To sum up, my questions is:
1. How to deal with OCExport,CStubs etc, when a Class/Function is removed.
2. How to remove virtual methods.
3. What is the DFG?
4. To shrink bitcode, can I take advantage of DFG or IR in the Context
?GarouDan
02/16/2019, 11:51 PMjuancho
02/17/2019, 3:12 PMclass MyException(
val myCustomProp: Boolean
): Throwable()
in iOS with Swift:
} catch let error as MyException {
print("custom value: \(error.myCustomProp)")
} catch let error {
print(error.localizedDescription)
}
but it always go to the latest catchAlexander Suslov
02/18/2019, 9:58 AM@ThreadLocal
annotation? I have a code:
...
object FooObject {
@ThreadLocal
var bar: String = "first"
}
fun testObj() {
val before = FooObject.bar
println("before = $before")
FooObject.bar = "second"
val after = FooObject.bar
println("after = $after")
}
...
But when I run it, I receive a error:
before = first
Instances of kotlin.Error, kotlin.RuntimeException and subclasses aren't propagated from Kotlin to Objective-C/Swift.
Other exceptions can be propagated as NSError if method has or inherits @Throws annotation.
Uncaught Kotlin exception: kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen org.kotlin.mpp.mobile.FooObject@398928
at 0 CoreModule 0x000000010bd9ff36 kfun:kotlin.Exception.<init>(kotlin.String?)kotlin.Exception + 70
at 1 CoreModule 0x000000010bd9fea6 kfun:kotlin.RuntimeException.<init>(kotlin.String?)kotlin.RuntimeException + 70
at 2 CoreModule 0x000000010bda17a6 kfun:kotlin.native.concurrent.InvalidMutabilityException.<init>(kotlin.String)kotlin.native.concurrent.InvalidMutabilityException + 70
at 3 CoreModule 0x000000010bdc6da3 ThrowInvalidMutabilityException + 275
at 4 CoreModule 0x000000010bde18f2 MutationCheck + 50
at 5 CoreModule 0x000000010bd97c63 kfun:org.kotlin.mpp.mobile.FooObject.<set-bar>(kotlin.String) + 67
at 6 CoreModule 0x000000010bd9ed56 kfun:org.kotlin.mpp.mobile.testObj() + 342
at 7 CoreModule 0x000000010bd9eb2e kfun:org.kotlin.mpp.mobile.platformName()kotlin.String + 62
at 8 CoreModule 0x000000010bd9ea82
...
Why the bar
variable is frozen in this case?yusuf3000
02/18/2019, 2:33 PMiosArm64
klib it can’t find the corresponding actual
class for an expect
class but it works fine when building an iosX64
klib?tapchicoma
02/20/2019, 8:32 AMGarouDan
02/20/2019, 2:43 PMThe IvyArtifactRepository.layout(String, Action) method has been deprecated. This is scheduled to be removed in Gradle 6.0. Please use the IvyArtifactRepository.patternLayout(Action) method instead.
Could not create an instance of type org.jetbrains.kotlin.gradle.dsl.KotlinNativeBinaryContainer.
> org.gradle.util.WrapUtil.toNamedDomainObjectSet(Ljava/lang/Class;[Lorg/gradle/api/Named;)Lorg/gradle/api/NamedDomainObjectSet;
This is related with the last message, but for now I would like to try to latest supported version of gradle too.basher
02/21/2019, 1:53 AMInt
(or other primitive) without using alloc
in memScoped
? I'm trying to do it useing usePinned
, but i'm having trouble navigating the types. Is the the right direction?ivan.savytskyi
02/21/2019, 2:52 AMDroidconKotlin
by Touchlab https://github.com/touchlab/DroidconKotlin/blob/kotlin-1.3.20/sessionize/lib/src/iosMain/kotlin/co/touchlab/sessionize/platform/Functions.kt#L49 it uses ThreadLocal wrapper.
The question why not just do this instead:
override operator fun <T> invoke(query: Database.() -> T, callback: (T) -> Unit) {
worker.execute(TransferMode.SAFE, { QueryTask(database, query, callback).freeze() }) { task ->
val result = task.query(task.database)
dispatch_async_f(
queue = dispatch_get_main_queue(),
context = DetachedObjectGraph { QueryTaskResult(result.freeze(), task.callback) }.asCPointer(),
work = staticCFunction { it: COpaquePointer? ->
initRuntimeIfNeeded()
val result = DetachedObjectGraph<Any>(it).attach() as QueryTaskResult<T>
result.callback(result.result)
}
)
}
}
Am I missing something, and there is something wrong with the code above? It seems workingivan.savytskyi
02/21/2019, 2:52 AMDroidconKotlin
by Touchlab https://github.com/touchlab/DroidconKotlin/blob/kotlin-1.3.20/sessionize/lib/src/iosMain/kotlin/co/touchlab/sessionize/platform/Functions.kt#L49 it uses ThreadLocal wrapper.
The question why not just do this instead:
override operator fun <T> invoke(query: Database.() -> T, callback: (T) -> Unit) {
worker.execute(TransferMode.SAFE, { QueryTask(database, query, callback).freeze() }) { task ->
val result = task.query(task.database)
dispatch_async_f(
queue = dispatch_get_main_queue(),
context = DetachedObjectGraph { QueryTaskResult(result.freeze(), task.callback) }.asCPointer(),
work = staticCFunction { it: COpaquePointer? ->
initRuntimeIfNeeded()
val result = DetachedObjectGraph<Any>(it).attach() as QueryTaskResult<T>
result.callback(result.result)
}
)
}
}
Am I missing something, and there is something wrong with the code above? It seems workingyshrsmz
02/21/2019, 3:17 AMivan.savytskyi
02/21/2019, 4:02 AMJobWrapper(backJob, mainJobHolder).freeze()
.olonho
02/21/2019, 5:00 AMContinuator
solves problem of non-freezing the callbackyshrsmz
02/21/2019, 6:02 AMivan.savytskyi
02/21/2019, 4:30 PMfreeze
operation does for the closure / callback especially if it passed from let’s say swift realm, what implications of freezing passed callback?olonho
02/21/2019, 5:03 PMkpgalligan
02/21/2019, 7:26 PMhttps://www.youtube.com/watch?v=yhvsKlxPZPQ&feature=youtu.be▾
ivan.savytskyi
02/25/2019, 5:45 PM