Simon BRUNOU
05/10/2021, 12:25 PMMap
to an objective-c CFDictionary
using CFDictionaryCreate
. The main issue is using the pointers to go back and forth between Kotlin and Objective-C. Here’s my code so far (not generic for now will be later)
fun Map<CFStringRef?, Any?>.toCFDictionary(): CFDictionaryRef? {
return CFDictionaryCreate(
kCFAllocatorDefault,
keys,
values,
size.toLong(),
kCFTypeDictionaryKeyCallBacks,
kCFTypeDictionaryValueCallBacks
)
}
There is a type mismatch for the second, third, fifth and sixth arguments.
Second and third arguments should be CValuesRef<COpaquePointerVar>? but are currently Set<CPointer<__CFString>?> and Collection<Any?>.
The last two arguments should be CValuesRef<CFDictionaryKeyCallBacks>? and CValuesRef<CFDictionaryValueCallBacks>? but are CFDictionaryKeyCallBacks and CFDictionaryValueCallBacks.
I do not know how to convert those values to the expected ones, can anyone help me plase ?
Thank you for your time.Daniele B
05/10/2021, 5:05 PMandylamax
05/11/2021, 8:33 PMAnthony Pages
05/31/2021, 8:51 AM_
at the end of one of them in the header.
interface A {
val foo: Int
}
interface B {
val foo: Int?
}
I will have the following header:
__attribute__((swift_name("A")))
@protocol A
@required
@property (readonly) int32_t foo __attribute__((swift_name("foo"))); // <----- foo: OK
@end;
__attribute__((swift_name("B")))
@protocol B
@required
@property (readonly) KotlinInt * _Nullable foo_ __attribute__((swift_name("foo_"))); // <----- foo with an underscore: NOK
@end;
I didn't find any issue on https://youtrack.jetbrains.com/ So I ask to you here before opening one.
_P.S: if props have the same type, there is no collision and no `_`_ added.gbasile
06/21/2021, 6:08 PMStateFlow
on the Swift side and I come up with this idea in order to translate the stream into a Combine
Producer.
I have the feeling that I’m reinventing the wheel 🤔 Is there any better alternative already available to achieve these adapters seamlessly?
https://gist.github.com/gbasile/955b22e7334dc5c5dcbef8ed0e7fccdeFabio Santo
07/08/2021, 9:15 AMKartik Prakash
08/01/2021, 2:00 AMribesg
08/20/2021, 10:11 AMCAGradientLayer
in Kotlin/Native? I really can’t get it to work even on a simple view and I feel like I checked all the problems people usually encounter when using it in ObjC/Swiftnhaarman
08/26/2021, 9:13 AMNikolay Kasyanov
08/31/2021, 3:02 PMcompletionHandler
not on the same thread the “coroutine” method was called on, I get illegal sharing exception:
class DependencyImpl: FooBarDependency {
func getName(completionHandler: @escaping (String?, Error?) -> Void) {
...
}
}
When thread stays the same, it’s all good. I’m using coroutines 1.5.1-native-mt.
Kotlin code in comments.Nikolay Kasyanov
09/01/2021, 9:36 AMXCFramework
extension function from build.gradle
(no KTS)?
Importing import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework
doesn’t work:
unable to resolve class org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework
Nikolay Kasyanov
09/06/2021, 11:35 AMpublic expect class PlatformDecimal
public expect value class Decimal(public val impl: PlatformDecimal)
// in iosMain:
@Suppress("CONFLICTING_OVERLOADS")
public actual typealias PlatformDecimal = NSDecimalNumber
public actual value class Decimal(public val impl: NSDecimalNumber) {
If I make a framework out of it, all instances of Decimal
have type of id
(I’d expect NSDecimalNumber
there) in the generated Objective-C header. Is this a known limitation?Pat Teruel
09/16/2021, 12:13 AMpampanet
09/20/2021, 6:36 PMInfo.plist
missing entries about NSExtension. Is it possible to create these entries for handling custom Intents with a kotlin project?Pat Teruel
09/22/2021, 7:43 AMobject ClientWrapper{
val api = PetApi()
}
While it did work, now we have some adjustments on our own client. It needs to have a Bearer Token. In order to that, I need to call the setBearerToken()
function inside the api
.
But I can’t do that when it’s wrapped in an immutable class. So I had to instantiate the Api object everytime I need to set the bearer token. The thing is, it’s not working at all in iOS. It gives me off an error of “Frozen Mutability Exception”, it’s kind of pointing out on the lazy variables. While I get the gist of the problem, what I’m not sure of is how to do some workarounds to solve this problem. Putting a @ThreadLocal
on the client wrapper itself doesn’t seem to work at all. Has anyone ever solved this?
I’m seeing certain youtrack posts that it will not be solved until Kotlin changes some memory stuff, but I’m not sure. I hope someone can help me figure this out. Thank you.Bastian
09/29/2021, 4:31 PMshared.h
header file though.
Do you have any idea how I might be able to make these functions available to my iOS App code?Bastian
10/05/2021, 12:43 PMcinterop multiplatform dependency
into the shared.framework
for my iOS app (to make them available). The dependency uses cinterop
as it's wrapping a C library. I'm already trying to export
it via the Gradle setup (see setup in the thread). Though when building in either Xcode or AppCode, I get an error about missing symbols for architecture x86_64
and a warning that the dependency can't be exported
(see error log in the thread).
I tried fixing this by including the .def
file of the wrapping dependency and the include
folder of the C library itself and making the export transitive
. But this didn't help.
I'm using Kotlin 1.5.31.Fudge
10/07/2021, 4:00 PMIvan Đorđević
10/12/2021, 11:12 AMembedAndSignAppleFrameworkForXcode
task defined? I'm running the kmm-integration-samples
test project, and when I simply run the iOS target it builds successfully:
> Task :shared:linkDebugFrameworkIosX64
> Task :shared:assembleDebugAppleFrameworkForXcodeIosX64
> Task :shared:embedAndSignAppleFrameworkForXcode
BUILD SUCCESSFUL in 13s
4 actionable tasks: 4 executed
But I can't see such a task in Gradle tasks, and when I try to run the task manually, Gradle can't seem to find it:
$ ./gradlew :shared:embedAndSignAppleFrameworkForXcode
> Configure project :shared
Kotlin Multiplatform Projects are an Alpha feature. See: <https://kotlinlang.org/docs/reference/evolution/components-stability.html>. To hide this message, add 'kotlin.mpp.stability.nowarn=true' to the Gradle properties.
FAILURE: Build failed with an exception.
* What went wrong:
Task 'embedAndSignAppleFrameworkForXcode' not found in project ':shared'.
marzelwidmer
10/21/2021, 6:17 PMsalomonbrys
11/04/2021, 7:07 PMWill Hess
11/09/2021, 7:15 PMkotlin.native.cacheKind=none
I also have a post install script inside of my podfile which was working when I was only consuming the kotlin generated framework in iosSdk
and iosSdkUx
. But when trying to add the third it fails (iosSdkSampleApplication
). (SEE THREAD FOR PODFILE)
Here is the error I am getting:
objc[29904]: Class ISSDouble is implemented in both /Users/ME/Library/Developer/Xcode/DerivedData/iosSdk-ftsmsdlkscvzlmdbohckpjheeupx/Build/Products/Debug-iphonesimulator/iosSdkUx.framework/iosSdkUx (0x110508d60) and /Users/ME/Library/Developer/CoreSimulator/Devices/7C739BFB-DFD9-4F88-A2D4-4185065B258D/data/Containers/Bundle/Application/C98D5D0A-45C5-43F5-A4AA-70C42E3E283F/iosSdkSampleApplication.app/iosSdkSampleApplication (0x103bbb2f0). One of the two will be used. Which one is undefined.
Michael Langford
11/15/2021, 5:45 PMalexeenkoff
11/17/2021, 2:07 PMcrumpf
11/18/2021, 6:28 PMimport org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework
val bitcode: String = if ("release".equals(configuration, true)) "bitcode" else "marker"
val iosFrameworkName = "FooFramework"
kotlin {
val xcf = XCFramework(iosFrameworkName)
ios {
binaries.framework {
xcf.add(this)
}
}
val iosTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget = when {
System.getenv("SDK_NAME")?.startsWith("iphoneos") == true -> ::iosArm64
System.getenv("NATIVE_ARCH")?.startsWith("arm") == true -> ::iosSimulatorArm64
else -> ::iosX64
}
iosTarget("ios") {}
cocoapods {
summary = "summary here"
homepage = "<https://www.example.com>"
ios.deploymentTarget = "10.0"
podfile = project.file("../iosApp/Podfile")
framework {
baseName = iosFrameworkName
freeCompilerArgs += listOf("-module-name", "FOO")
embedBitcode(bitcode)
}
pod("AFNetworking", "~> 4.0.1")
}
}
First question: Am I doing it wrong? 😀
Second question: Is it right to configure the framework (baseName, module-name, etc) inside the cocoapods
extension instead of the ios
target?
Third question: When set up this way, the iosTarget
workaround to for the IDE in conjunction with cocoapods reports exceptions about the x64 architecture already having a binary:
Cannot add binary podDebugFramework dependency to default fat framework
java.lang.IllegalArgumentException: This fat framework already has a binary for architecture `x64` (podDebugFramework for target `iosX64`)…
Cannot add binary podReleaseFramework dependency to default fat framework
java.lang.IllegalArgumentException: This fat framework already has a binary for architecture `x64` (podReleaseFramework for target `iosX64`)…
Even though things seem to build successfully, even with these pod<config>Framework exceptions, is there a possibility of a problem rearing its head? Is there something I can do to clean the exceptions up?
references:
Build XCFramework: https://kotlinlang.org/docs/mpp-build-native-binaries.html#build-xcframeworks
iOS dependencies with CocoaPods: https://kotlinlang.org/docs/kmm-add-dependencies.html#with-cocoapods
Note for iOS dependencies needing workaround to get code completion/highlighting in the IDE for the 3rd party libs
https://kotlinlang.org/docs/kmm-add-dependencies.html#workaround-to-enable-ide-support-for-the-shared-ios-source-setAlexis Hernandez
11/24/2021, 5:57 PMNikolay Kasyanov
11/25/2021, 2:05 PMIain Merrick
12/02/2021, 5:12 PMBrian G
12/06/2021, 11:51 PMBrian G
12/07/2021, 1:02 AMBrian G
12/07/2021, 1:02 AMKonrad Sztenderski
12/08/2021, 12:50 PMapple {
iosApp {
dependencies {
implementation(project(":project_with_cocoapods"))
}
}
}
If cocoapods are located in the same project then they are automatically added.Brian G
12/08/2021, 4:45 PM