Pantry: Crash after Swift 3 update
Hello guys, I’m having a serious problem with Pantry. I didn’t change anything from what I had before the update (it’s a project that could wait). After this update, Pantry crashes at every pack call. I pack arrays (of every type, even custom structs that conforms to the Storable protocol) and other kind of stuff. Before the update everything was working good, not now.
One of the call is simple as :
Pantry.pack(self, key: pantryKeyCurrentUser)
Here crashes pointing me to this line (number 118 of file JSONWarehouse):
let data = try JSONSerialization.data(withJSONObject: storableDictionary, options: .prettyPrinted)
The error is EXC_BAD_INSTRUCTION (code = EXC_I386_INVOP, subcode = 0x0)
About this issue
- Original URL
- State: open
- Created 8 years ago
- Comments: 40 (9 by maintainers)
Thanks, I’ll check this out today
In my case, I had one nested class. Let’s say
class Ahas a mandatory reference toclass B:The type of the mandatory reference is serialized by
MirrorasMyApp_B!. I suspected that the exclamation mark could be a problem, so I removed it.After that, the problem was gone and my object of type
class Ais serialized without problem.Hope this help can help you.
I’ll bring up the same issue as before. Is there a reason for the IUOs that I’m missing? They look unnecessary.
You’re going to crash on accessing whatever property is an IUO if you try to access it normally as well. The only difference here is that Pantry is trying to access each of your properties in an attempt to store them so the issue is automatically discovered.
@andreamazz I’m still a fan of checking our valid JSON before we write it. Can you submit a PR from your branch?
Ok, I was able to reproduce the issue. Let me see if I can fix it.