KMM and preview for swift ui - kotlin-multiplatform

Trying out kmm with a non trivial project,
The task is to show a list of repos, and I want to have a preview of the screen in swift-ui.
I have a viewModel that get's injected a repository that will eventually query github api.
For the preview I inject a fake repository that should answer with a list of hardcoded objects.
The code is in this PR https://github.com/alexandru-calinoiu/SharedAppSample/pull/1
Preview for RepoListView will crash:
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------
Incident Identifier: 4990E330-CD93-4D80-92C9-1426BBC3FBBA
CrashReporter Key: E30E0C83-3AF1-4C22-98AC-D674ED184D1C
Hardware Model: Macmini8,1
Process: iosApp [41515]
Path: /Users/USER/Library/Developer/Xcode/UserData/Previews/Simulator Devices/0DF05C52-98D2-4DF5-AA63-6F22DBFE76C1/data/Containers/Bundle/Application/461BB8B1-6BFE-4BB1-B1FD-0882D664AE26/iosApp.app/iosApp
Identifier: orgIdentifier.iosApp
Version: 1.0 (1)
Code Type: X86-64 (Native)
Role: Foreground
Parent Process: launchd_sim [16338]
Coalition: com.apple.CoreSimulator.SimDevice.0DF05C52-98D2-4DF5-AA63-6F22DBFE76C1 [86637]
Responsible Process: SimulatorTrampoline [670]
Date/Time: 2022-10-10 17:12:15.1370 +0300
Launch Time: 2022-10-10 17:12:14.5247 +0300
OS Version: macOS 12.5.1 (21G83)
Release Type: User
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000118
Exception Codes: 0x0000000000000001, 0x0000000000000118
VM Region Info: 0x118 is not in any region. Bytes before following region: 140737487011560
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
--->
VM_ALLOCATE 7fffffeb8000-7fffffeb9000 [ 4K] r-x/r-x SM=ALI
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: SIGNAL 11 Segmentation fault: 11
Terminating Process: exc handler [41515]
Triggered by Thread: 0
Thread 0 Crashed:: Dispatch queue: BSXPCCnx:com.apple.dt.xcode-previews.systemservices (BSCnx:client:com.apple.dt.uv.agent-preview-nonui-service)
0 RepoListView.1.preview-thunk.dylib 0x13d1f7d7b Kotlin_Interop_CreateKStringFromNSString + 107
1 iosApp 0x10eb2c3cd Kotlin_ObjCExport_refFromObjC + 61
2 iosApp 0x10ea5124f objc2kotlin.1693 + 335
3 iosApp 0x10e67ec70 #nonobjc ExploreSharedRepo.init(owner:name:description:primaryLanguage:lastActivity:) + 160
4 iosApp 0x10e67e325 ExploreSharedRepo.__allocating_init(owner:name:description:primaryLanguage:lastActivity:) + 133
5 iosApp 0x10e67e1ba one-time initialization function for repos + 218 (RepoListView.swift:61)
6 libdispatch.dylib 0x110f95a3a _dispatch_client_callout + 8
7 libdispatch.dylib 0x110f96db3 _dispatch_once_callout + 20
8 iosApp 0x10e67e361 Screen_Previews.repos.unsafeMutableAddressor + 49 (RepoListView.swift:60)
9 iosApp 0x10e67e3bb one-time initialization function for viewModel + 27 (RepoListView.swift:65)
10 libdispatch.dylib 0x110f95a3a _dispatch_client_callout + 8
11 libdispatch.dylib 0x110f96db3 _dispatch_once_callout + 20
12 iosApp 0x10e67e421 Screen_Previews.viewModel.unsafeMutableAddressor + 49 (RepoListView.swift:65)
13 RepoListView.1.preview-thunk.dylib 0x13d55de5f static Screen_Previews.__preview__previews.getter + 31 (RepoListView.swift:68)
14 iosApp 0x10e67e6a9 protocol witness for static PreviewProvider.previews.getter in conformance Screen_Previews + 9
15 SwiftUI 0x1152b92a3 0x1148eb000 + 10281635
16 iosApp 0x10e67e6e5 protocol witness for static _PreviewProvider._previews.getter in conformance Screen_Previews + 37
17 SwiftUI 0x1152b9ac1 0x1148eb000 + 10283713
18 PreviewsInjection 0x10fba27f9 0x10fb78000 + 174073
19 PreviewsInjection 0x10fba26e9 0x10fb78000 + 173801
20 PreviewsInjection 0x10fb9991a 0x10fb78000 + 137498
..... (char limit was hit, so no full message)
By reading the log I guess it has something to do with converting strings from to kotlin, but what?

Try adding isStatic = false to your framework block here
The SwiftUI preview doesn't work with static frameworks produced by Kotlin. There's some discussion about it here

Related

Setting CALayer transform property causes a crash

I am building an interactive rotating disc control. When the user drags the view, I apply the rotation transform for the view. Like this:
circleView.layer.transform = CATransform3DMakeRotation(angle, 0, 0, 1)
For some reason, this line of code causes the app to crash. The crash is not happening on the first hit of this line, but after a
few seconds of consecutive rotation. If I comment this line out, the crash is not occurring.
To make things worse, when the app crashes xcode doesn't show any error or stacktrace but says "connection to device is lost".
This happening only on a device. On the simulator all goes fine.
In the crash logs of the device, at the time of the crash I see no crashes of my apps but there is a crash of processes DTServiceHub
Incident Identifier: 02336F7A-CAB3-4B13-9509-65EA61813529
CrashReporter Key: e16756d8ab2514bab0584705f4151434dbed594f
Hardware Model: iPad3,4
Process: DTServiceHub [768]
Path: /Developer/Library/PrivateFrameworks/DVTInstrumentsFoundation.framework/DTServiceHub
Identifier: DTServiceHub
Version: ???
Code Type: ARM (Native)
Role: Unspecified
Parent Process: launchd [1]
Coalition: <none> [352]
Date/Time: 2018-10-02 18:26:03.0352 +0300
Launch Time: 2018-10-02 18:25:45.0000 +0300
OS Version: iPhone OS 10.3.3 (14G60)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0bd5f30c
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [0]
hread 6 name: Dispatch queue: NStatManager queue
Thread 6 Crashed:
0 libobjc.A.dylib 0x1d404dc6 objc_msgSend + 6
1 CoreFoundation 0x1e086210 -[__NSDictionaryM objectForKey:] + 128
2 IDEDebugGaugeDataProviders 0x00439278 0x430000 + 37496
3 IDEDebugGaugeDataProviders 0x004382a8 0x430000 + 33448
4 NetworkStatistics 0x240ab374 -[NWStatisticsDelegateBlockWrapper sourceDidReceiveCounts:] + 160
5 NetworkStatistics 0x240a548c __59-[NWStatisticsManager dispatchDidReceiveCounts:fromUpdate:]_block_invoke + 110
6 libdispatch.dylib 0x1d83d796 _dispatch_call_block_and_release + 10
7 libdispatch.dylib 0x1d84a59c _dispatch_queue_serial_drain + 854
8 libdispatch.dylib 0x1d840b70 _dispatch_queue_invoke + 886
9 libdispatch.dylib 0x1d84c1b4 _dispatch_root_queue_drain + 326
10 libdispatch.dylib 0x1d84c00e _dispatch_worker_thread3 + 106
11 libsystem_pthread.dylib 0x1d9f287c _pthread_wqthread + 1040
12 libsystem_pthread.dylib 0x1d9f245c start_wqthread + 8
Any ideas?

OBJC Another crash log issue

I've been scanning thru similar questions but I cannot find one that applies to my case or clear enough. My app was rejected by the Apple Review with it crashes al launch, it works on all of my devices the crashlog is as below , the uuid matches on DSYM and the binary section on the crash log, ran atos, dwarf , symbolicate and all of the suggested stuff on the other questions but I get nothing it just echoes back the addresses or prints it back so i cannot find out where/what causes the crash. Any suggestion??? I also found a bunch of perl/csh scripts that do the same or fail so I'm stuck.
Hardware Model: xxx
Process: MyApp [840]
Path: /private/var/containers/Bundle/Application/772689C2-24B8-49E8-A236-
C0D669C5A5AE/MyApp.app/MyApp
Version: 4 (1.40)
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Date/Time: 2018-07-25 08:49:09.6233 -0700
Launch Time: 2018-07-25 08:49:04.7929 -0700
OS Version: iPhone OS 11.4.1 (15G77)
Baseband Version: 6.80.00
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000dc17cbec8
VM Region Info: 0xdc17cbec8 is not in any region. Bytes after
previous region: 51027689161
REGION TYPE START - END [ VSIZE]
PRT/MAX SHRMOD REGION DETAIL
MALLOC_NANO (reserved) 00000001d8000000-00000001e0000000 [128.0M]
rw-/rwx SM=NUL ...(unallocated)
--->
UNUSED SPACE AT END
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [0]
Triggered by Thread: 0
Filtered syslog:
None found
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x0000000183fcd7f4 0x183fa8000 +
153588
1 CoreFoundation 0x0000000184cc6500 0x184cb1000 + 87296
2 libobjc.A.dylib 0x0000000183fce13c 0x183fa8000 + 155964
3 CoreFoundation 0x0000000184cbcaac 0x184cb1000 + 47788
4 UIKit 0x000000018ede35c8 0x18e9bf000 + 4343240
5 UIKit 0x000000018edfb9dc 0x18e9bf000 + 4442588
6 CoreFoundation 0x0000000184d9e910 0x184cb1000 + 973072
7 CoreFoundation 0x0000000184d9c238 0x184cb1000 + 963128
8 CoreFoundation 0x0000000184d9c884 0x184cb1000 + 964740
9 CoreFoundation 0x0000000184cbcda8 0x184cb1000 + 48552
10 GraphicsServices 0x0000000186ca2020 0x186c97000 + 45088
11 UIKit 0x000000018ecdc758 0x18e9bf000 + 3266392
12 MyApp 0x00000001011bd888 main (main.m:14)
13 libdyld.dylib 0x000000018474dfc0 0x18474d000 + 4032
Thread 1:

App is crashed on launch by app store reviewed

I've tested my apps with all sort of iOs version and result is working fine on those devices. But when I published to App Store, they rejected that app is crashed on launch. I cannot convince why app is crashed on their phone even I've tested with same iOs version.
Please let me know, how to solve that issue and I've attached error logs.
{"app_name":"CakeApp","timestamp":"2017-08-10 06:54:09.29 -0700","app_version":"3","slice_uuid":"ba63de93-382a-3879-933d-e584d00cb7aa","adam_id":1233988265,"build_version":"1.2","bundleID":"com.ppshein.CakeApp","share_with_app_devs":false,"is_first_party":false,"bug_type":"109","os_version":"iPhone OS 10.3.3 (14G60)","incident_id":"81B4B45E-ACB0-4305-81BE-B88E4E257238","name":"CakeApp"}
Incident Identifier: 81B4B45E-ACB0-4305-81BE-B88E4E257238
CrashReporter Key: 318083a7319cbe05fd01b4c953a58aebe938f998
Hardware Model: xxx
Process: CakeApp [5822]
Path: /private/var/containers/Bundle/Application/126924F1-2DBF-4F12-8355-1C5787680F75/CakeApp.app/CakeApp
Identifier: com.ppshein.CakeApp
Version: 1.2 (3)
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: com.ppshein.CakeApp [1034]
Date/Time: 2017-08-10 06:54:09.0262 -0700
Launch Time: 2017-08-10 06:54:06.9573 -0700
OS Version: iPhone OS 10.3.3 (14G60)
Report Version: 104
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000001002749c8
Termination Signal: Trace/BPT trap: 5
Termination Reason: Namespace SIGNAL, Code 0x5
Terminating Process: exc handler [0]
Triggered by Thread: 0
Filtered syslog:
None found
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 CakeApp 0x00000001002749c8 0x100098000 + 1952200
1 CakeApp 0x000000010026dca4 0x100098000 + 1924260
2 UIKit 0x00000001930eae48 0x19306a000 + 527944
3 UIKit 0x00000001932f737c 0x19306a000 + 2675580
4 UIKit 0x00000001932fce24 0x19306a000 + 2698788
5 UIKit 0x00000001933118b0 0x19306a000 + 2783408
6 UIKit 0x00000001932fa0b8 0x19306a000 + 2687160
7 FrontBoardServices 0x000000018eaf8884 0x18eabe000 + 239748
8 FrontBoardServices 0x000000018eaf86f0 0x18eabe000 + 239344
9 FrontBoardServices 0x000000018eaf8aa0 0x18eabe000 + 240288
10 CoreFoundation 0x000000018cefd42c 0x18ce22000 + 898092
11 CoreFoundation 0x000000018cefcd9c 0x18ce22000 + 896412
12 CoreFoundation 0x000000018cefa9a8 0x18ce22000 + 887208
13 CoreFoundation 0x000000018ce2ada4 0x18ce22000 + 36260
14 UIKit 0x00000001930e3fc8 0x19306a000 + 499656
15 UIKit 0x00000001930dec9c 0x19306a000 + 478364
16 CakeApp 0x00000001000a5e3c 0x100098000 + 56892
17 libdyld.dylib 0x000000018be3959c 0x18be35000 + 17820
Did you test your app in a clean environment? Uninstall the app and delete all of its data and then install again.
You can try to resolve the crash by symbolicating the stack trace, as described in this technical note from Apple, which can help you identify the part of your code that crashed.

App fails right after start with IBM MobileFirst Platform with SecKeyGetBlockSize

We have a lot of users, but just a couple have this issue. The App crashes right after starting. Both Bitcode and ATS are disabled. What could be causing this issue? Thank you
Hardware Model: iPhone9,3
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Date/Time: 2017-05-16 18:05:01.2852 -0400
Launch Time: 2017-05-16 18:04:57.4399 -0400
OS Version: iPhone OS 10.3.1 (14E304)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000010
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [0]
Triggered by Thread: 0
Thread 0 name:
Thread 0 Crashed:
SecKeyGetBlockSize + 0 (SecKey.c:696)
WLCertManager signData:privateKey:] + 276 (WLCertManager.m:525)
[WLDeviceAuthManager signDeviceAuth:entity:isPEnabled:] + 1168 (WLDeviceAuthManager.m:173)
[BaseProvisioningChallengeHandler onDeviceAuthDataReady:] + 172 (BaseProvisioningChallengeHandler.m:162)
[BaseDeviceAuthChallengeHandler getDeviceAuthDataAsync:] + 1308 (BaseDeviceAuthChallengeHandler.m:58)
[BaseProvisioningChallengeHandler handleChallenge:] + 1040 (BaseProvisioningChallengeHandler.m:138)
[WLRequest startHandleChallenges:httpRequest:]_block_invoke + 484 (WLRequest.m:606)
[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 136 (NSDictionary.m:680)
[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 180 (NSDictionary.m:692)
[WLRequest startHandleChallenges:httpRequest:] + 256 (WLRequest.m:598)
[WLRequest requestFailed:error:] + 604 (WLRequest.m:505)
[WLAFHTTPRequestOperationManagerWrapper requestFailed:error:] + 2020 (WLAFHTTPRequestOperationManagerWrapper.m:396)
[WLAFHTTPRequestOperationManagerWrapper start]_block_invoke229 + 112 (WLAFHTTPRequestOperationManagerWrapper.m:340)
[WLAFHTTPRequestOperation setCompletionBlockWithSuccess:failure:]_block_invoke42 + 112 (WLAFHTTPRequestOperation.m:141)
dispatch_call_block_and_release + 24 (init.c:963)
_dispatch_main_queue_callback_4CF + 444 (inline_internal.h:2417)
__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12 (CFRunLoop.c:1793)
__CFRunLoopRun + 1572 (CFRunLoop.c:3004)
CFRunLoopRunSpecific + 424 (CFRunLoop.c:3113)
GSEventRunModal + 100 (GSEvent.c:2245)
UIApplicationMain + 208 (UIApplication.m:4089)
main + 200 (main.swift:12)
libdyld.dylib 0x000000018eeb559c start + 4
Full log here https://drive.google.com/open?id=0B1GqBSG2XUgZYmhJVGFRakFtWUU
It looks like it is happening when we are doing
private lazy var client: WLClient = WLClient.sharedInstance()
self.client.wlConnectWithDelegate(SomeDelegate)
MFP version is = 7.1-2016/07/11
EXC_BAD_ACCESS is caused by a null pointer reference. I have seen this before when wlConnectWithDelegate was being called more than once.
I would try to use Swift's dispatch_once_t singleton like this:
var token: dispatch_once_t = 0
dispatch_once(&token) {
//Make sure you register all challenge handlers then connect
WLClient.sharedInstance().wlConnectWithDelegate(SomeDelegate)
}
The exception looks like a keychain access error in MobileFirst SDK. MobileFirst does not support background mode in 7.1. Please make sure your app is not trying run MobileFirst connect APIs from background.Also make sure "KeyChain Sharing" is enabled in Targets->Capabilities.
The issue is fixed and published for MobileFirst 7.1

iOS Xcode 5 EXEC_BREAKPOINT (SIGTRAP) App Startup ONLY ON ONE DEVICE

I am building a mobile app using PhoneGap and I have send it to Beta using TestFlight. Everyone has been able to download and test the app except for one user out of roughly 10. He can install the app perfectly fine, but when he goes to launch it, it crashes immediately. The first time he tried he got into the app, but when gave permissions to a plugin it crashed.
He provided me with a crash log, which I've shortened to:
Incident Identifier: BE251DD5-6D68-4084-84F6-EC629B24F2CA
CrashReporter Key: 7cccfe6ca4af8513c8cdb2fc1cacf253a416553b
Hardware Model: iPhone6,1
Process: Loaner [1549]
Path: /var/mobile/Applications/5B7BB625-9A3D-4ACE-A8A0-74424577067C/Loaner.app/Loaner
Identifier: com.cardeninteractive.loaner
Version: 1.1d (1.1d)
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
Date/Time: 2014-05-27 11:54:57.681 -0400
OS Version: iOS 7.1.1 (11D201)
Report Version: 104
Exception Type: EXC_BREAKPOINT (SIGTRAP) Exception Codes: 0x0000000000000001, 0x0000000185806198 Triggered by Thread: 0 Thread 0 Crashed:
0 CoreFoundation 0x0000000185806198 0x185800000 + 24984
1 Loaner 0x00000001000407b4 0x100020000 + 133044
2 Loaner 0x000000010003ec64 0x100020000 + 126052
3 Loaner 0x0000000100039174 0x100020000 + 102772
4 Loaner 0x000000010003a25c 0x100020000 + 107100
5 libdispatch.dylib 0x00000001923ebfd0 0x1923e8000 + 16336
6 libdispatch.dylib 0x00000001923f3834 0x1923e8000 + 47156
7 libdispatch.dylib 0x00000001923ebfd0 0x1923e8000 + 16336
8 libdispatch.dylib 0x00000001923ef1d8 0x1923e8000 + 29144
9 CoreFoundation 0x00000001858cac28 0x185800000 + 830504
10 CoreFoundation 0x00000001858c8f68 0x185800000 + 823144
11 CoreFoundation 0x0000000185809c1c 0x185800000 + 39964
12 GraphicsServices 0x000000018b4f1c08 0x18b4e4000 + 56328
13 UIKit 0x000000018893afd8 0x1888c0000 + 503768
14 Loaner 0x0000000100035f68 0x100020000 + 89960
15 libdyld.dylib 0x0000000192407a9c 0x192404000 + 15004
I have read a number of posts on SO and can't seem to gain any insight into this.
Both myself and this guy are using an iPhone 5S and the problem doesn't affect me at all, even if I download the build from TestFlight and not through the IDE.

Resources