WidgetKit Crash

On the crash reports, I am getting a lot of crashes with this crash report for two iOS 14 Widgets:

Code Block
Foundation _NSFileHandleRaiseOperationException
....
SwiftUI FileArchiveWriter.AppendByes(_size:)
....
My Widget closure #1 in MyTimelineProver.getTimeline(in:completion:)



When checked within the project, this happens in:
Code Block
func getTimeline(in context: Self.Context, completion: @escaping (Timeline<Self.Entry>) -> Void)


I have one timeline that asked to update every 5 mins.

Getting the same crash. Happens randomly on a TestFlight build.

Getting the same crash. Happens randomly on a TestFlight build.

Can you post an Apple crash report for this? Use the text attachment feature (the paperclip button) to avoid clogging up the timeline.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
I also get a lot of this issues.
It seems like my timeline get called multiple times and it just crashes
Happened to me today as well. It seems to be an error that Xcode missed before compiling, resulting in a bad function in the executable (I may or may not have used the correct terminology, I'm fairly new to app development, sorry) - I've rewritten one of my functions and suddenly it started to work again.

Until it fixed, try to delete / comment out chunks of your code (one at a time, of course) until you find where the problem is, then try to fix or rewrite it. Managed to fix that twice this way.
Make sure that you're only calling the completion handler once!
It can be a bit hard to trace with nested closures + networking, so try some print statements and see if that helps.
0   CoreFoundation                	       0x18184904c __exceptionPreprocess + 220
1   libobjc.A.dylib               	       0x199ebdf54 objc_exception_throw + 60
2   Foundation                    	       0x183105238 -[NSConcreteFileHandle offsetInFile] + 0
3   Foundation                    	       0x183104e10 -[NSConcreteFileHandle init] + 0
4   Foundation                    	       0x18301395c -[NSString(NSURLUtilities) stringByRemovingPercentEncoding] + 0
5   SwiftUI                       	       0x1892bafe8 FileArchiveWriter.appendBytes(_:size:) + 52
6   SwiftUI                       	       0x1892d130c FileArchiveWriter.append<A>(_:) + 184
7   SwiftUI                       	       0x189310cb4 specialized ArchiveWriter.addAttachment(from:) + 388
8   SwiftUI                       	       0x18930104c Encoder.encodeAttachedValue<A>(key:encoder:) + 400
9   SwiftUI                       	       0x1892f7ae4 CodableCGImage.encode(to:) + 144
10  SwiftUI                       	       0x1893098c0 protocol witness for Encodable.encode(to:) in conformance CodableCGImage + 20
11  libswiftCore.dylib            	       0x1865340fc dispatch thunk of Encodable.encode(to:) + 32
12  libswiftFoundation.dylib      	       0x185e906f8 __PlistEncoder.box_<A>(_:) + 376
13  libswiftFoundation.dylib      	       0x185e9d908 _PlistKeyedEncodingContainer.encode<A>(_:forKey:) + 384
14  libswiftFoundation.dylib      	       0x185e9b414 protocol witness for KeyedEncodingContainerProtocol.encode<A>(_:forKey:) in conformance _PlistKeyedEncodingContainer<A> + 32
15  libswiftCore.dylib            	       0x186245eec _KeyedEncodingContainerBox.encode<A, B>(_:forKey:) + 396
16  libswiftCore.dylib            	       0x186239328 KeyedEncodingContainer.encode<A>(_:forKey:) + 68
17  SwiftUI                       	       0x18930c0e8 GraphicsImage.encode(to:) + 800

I am also facing this crash on xcode 13.1 ios 15.1, the simulator did work perfectly while testflight build does not load the widget

Unfortunately a backtrace snippet isn’t enough for me to offer any insight into this. Please post the full Apple crash report.

ps Since I responded earlier on this thread I’ve written up instructions on how to do this.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

WidgetKit Crash
 
 
Q