Re: Launching apps on 10.13.2


Graham Cox
 

OK, the bug is reproducible in a very simple test case. Apple have f***ed up for sure here.

This writes the simplest possible archive that includes this structure - here’s what it looks like in a plist editor:




Running this on 10.13.2 throws an exception. Earlier system versions are fine.

The code in the test app is this:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// create an archive using -encodeArrayOfObjCType:count:at: with 32-bit floats

NSString* path = [@"~/Desktop/testArchive.plist" stringByExpandingTildeInPath];

float testValues[] = {1.0, 2.0, 3.5, 4.6, 3.1415926, 0.0};

NSMutableData* testArchive = [NSMutableData data];

NSKeyedArchiver* archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:testArchive];

[archiver encodeArrayOfObjCType:@encode(float) count:6 at:testValues];
[archiver finishEncoding];

[testArchive writeToFile:path atomically:YES];

// now read it back in and see if it can be dearchived - in 10.13.2, this will throw an exception.


NSData* readArchive = [NSData dataWithContentsOfFile:path];

NSKeyedUnarchiver* unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:readArchive];

float readValues[6];

[unarchiver decodeArrayOfObjCType:@encode(float) count:6 at:readValues];
[unarchiver finishDecoding];

for( int i = 0; i < 6; ++i )
NSAssert( readValues[i] == testValues[i], @"dearchived data does not match values archived");

}

Submitting a bug report now. The annoying thing is that I can’t see any workaround. This is a killer for our users right now. Grrrr…..

On 8 Dec 2017, at 1:42 pm, Graham Cox <graham@mapdiva.com> wrote:

I’m going to create a simple test case that shows the problem in isolation (if it does), and submit it as a bug. I’m thinking that this particular feature of archiving is not used much, Apple have broken it, and it wasn’t picked up in testing. Again, I’m reluctant to draw this conclusion, but that’s how it looks right now.

Join cocoa@apple-dev.groups.io to automatically receive all group messages.