ShareSheet failing but only for US users

I have an app that shares a text file using the iOS ShareSheet. This app has functioned as intended until the release of iOS17 but I now have reports of zero length files ... but only from users based in the US!

I have test reports from UK and Europe that show no issues.

I have tested the original implementation, that uses UIDocumentInteractionController, and alternatives such as UIActivityViewController e.g.:

UIActivityViewController* avc = [[UIActivityViewController alloc] initWithActivityItems:@[self.temporaryURL] applicationActivities:nil];
        [self presentViewController:avc animated:YES completion:^{
        }];

Like many reports on the forums, there are a lot of errors (from the Sharing library) in the console such as:

Failed to request default share mode for fileURL:file:///private/var/mobile/Containers/Data/Application....

or

Only support loading options for CKShare and SWY types.

But in my testing the file shares without problems.

The file to be shared is located in the NSTemporaryDirectory()

Has anyone else seen this strange behaviour?

If so, does anyone know how to fix it?

Answered by endecotp in 777828022

What happens if an EU/UK user changes their device's region to US?

Accepted Answer

What happens if an EU/UK user changes their device's region to US?

Thanks @endecotp - Changing the region has enabled me to reproduce the bug. The only iOS17 device I had access to for testing was my own personal device so was hesitant to mess with that however, it turns out that changing regions was pretty painless.

I have now found the source of the bug:

My file was being generated using NSASCIIStringEncoding and included a timestamp value.

It appears that, in iOS17, the US region/locale now uses a` UTF8 NARROW NO-BREAK SPACE (0xe2 0x80 0xaf) between the seconds and the timezone info e.g. 00:00:00 GMT whereas UK/EU still uses a simple ASCII space (e.g. 0x20).

Consequently, the creation of the NSData for my file was failing (silently but that was me not checking it!).

I'll switch to encoding the file contents as UTF8 - which should be acceptable for any receiving Apps.

iOS17, the US region/locale now uses a` UTF8 NARROW NO-BREAK SPACE

You are not the only one to encounter obscure bugs with this as the root cause:

https://developer.apple.com/forums/thread/732993

ShareSheet failing but only for US users
 
 
Q