https://kotlinlang.org logo
#compose-ios
Title
# compose-ios
m

Michael Paus

06/15/2022, 9:04 AM
Does anybody know how to get the experimental example “falling-balls-mpp” from https://github.com/JetBrains/compose-jb running on the iOS simulator? I only get the following error:
Could not evaluate onlyIf predicate for task ':iosSimulatorCreateIPad'.
> Field 'dataPathSize' is required for type with serial name 'org.jetbrains.compose.experimental.uikit.internal.DeviceData', but it was missing
🛠️ 1
b

Blaž

06/15/2022, 12:35 PM
So I ran into this issue as well. What happens is that command
xcrun simctl list --json
, that gradle plugin uses under the hood excpects field
dataPathSize
to be present under device section. As you can see here https://github.com/JetBrains/compose-jb/blob/24526947ade74bc7711c8d4219b03b9c45098[…]jetbrains/compose/experimental/uikit/internal/SimctlListData.kt When I ran that command locally I had a bunch of devices where
dataPathSize
was not present and therefore JSON parsing failed. I am not sure why
dataPathSize
is there, whether it should be optional or not, but for me what solved the issue was to just remove all the existing devices by calling
xcrun simctl delete <device_id>
for all the devices in
xcrun simctl list --json
🙏 2
s

SeikoDes

06/15/2022, 1:03 PM
My team uses xcodegen to open it,like this: https://github.com/qdsfdhvh/compose-ios-bootstrap
🙏 1
m

Michael Paus

06/15/2022, 2:12 PM
@Blaž There are quite a few devices which don’t contain a “dataPathSize” and thus make the JSON parsing failing. This is a list of the devices which fail.
Copy code
"com.apple.CoreSimulator.SimRuntime.iOS-13-2"
	"name" : "iPhone 11 Pro"
	"name" : "iPhone 11 Pro Max"

"com.apple.CoreSimulator.SimRuntime.iOS-9-1"
	all
	
"com.apple.CoreSimulator.SimRuntime.iOS-8-4"
	all
	
"com.apple.CoreSimulator.SimRuntime.iOS-11-3"
	"name" : "iPhone 7"
	"name" : "iPhone 7 Plus"
	"name" : "iPhone 8"
	"name" : "iPhone 8 Plus"
	
"com.apple.CoreSimulator.SimRuntime.iOS-13-0"
	"name" : "iPhone 11 Pro"
	"name" : "iPhone 11 Pro Max"
	
"com.apple.CoreSimulator.SimRuntime.iOS-9-0"
	all

"com.apple.CoreSimulator.SimRuntime.iOS-8-3"
	all

"com.apple.CoreSimulator.SimRuntime.watchOS-2-0"
	all
	
"com.apple.CoreSimulator.SimRuntime.tvOS-9-0"
	all
The question is if a missing “dataPathSize” could be safely treated as “dataPathSize” : 0. The same problem may also occur for the “deviceTypeIdentifier”.
I have also filed an issue for this: https://github.com/JetBrains/compose-jb/issues/2114
b

Blaž

06/15/2022, 2:38 PM
There were also a bunch of devices when I ran into that issue. Even worse, I believe they are recreated every time XCode is updated. So if you delete them they will reappear with an XCode update. Looking through jb-compose source it looks like this field is never used. So the solution could be as simple as setting the default value to null.
val dataPathSize: Long? = null,
. As i don’t know the significance of that field, I’m not sure if that is the correct solution but looking at some other implementations it should be ok. For example SwiftSimctl completely ignores that field. https://github.com/ctreffs/SwiftSimctl/blob/7cda257c97cf6aecab0adca63e6b9a2816c75281/Sources/SimctlShared/SimctlShared.swift#L319
🙏 1
d

Dima Avdeev

06/18/2022, 10:02 AM
Thanks for Issue, we will fix it!
👍 4
K 1
🙏 1
I prepared PR with fix. We need to wait code review and after need to deploy new version. I'll let you know when a new version is ready for testing.
b

Blaž

06/21/2022, 8:05 AM
I saw this was already merged. Thanks @Dima Avdeev 🎉
👍 1
d

Dima Avdeev

06/21/2022, 8:07 AM
Now, we need to wait next successful build. I will let you know.
👍 2
m

Michael Paus

06/21/2022, 11:18 AM
After adding
Copy code
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1")
to the commonMain source set the falling-balls-mpp example now works on the iOS simulator again. Thanks a lot @Dima Avdeev
👍 1
d

Dima Avdeev

06/21/2022, 1:21 PM
Yeah, that buid!
Copy code
1.2.0-alpha01-dev724
👍 3
35 Views