iOS Simulator should simulate file system-based file naming restrictions

Originator:igeek1
Number:rdar://31360501 Date Originated:30-Mar-2017 08:27 PM
Status:Resolved Resolved:June 11 2017, 6:39 PM
Product:Developer Tools Product Version:Xcode 8.3 (8E162)
Classification:Enhancement Reproducible:Not Applicable
 
Summary:
The iOS simulator does not do 1:1 emulation of the file system. Namely, it does not mimic the case-sensitive nature of iOS up to version 10.2.x, and it does not mimic the lack of file name normalization exhibited by APFS.

Steps to Reproduce:
1. Write an app that makes ill-informed assumptions about how the iOS file system behaves. Perhaps it assumes that the file system is case-insensitive. Perhaps it assumes that the file system will normalize Unicode character sequences when reading and writing files.
2. Test the app on an iOS device.

Expected Results:
Your assumptions were challenged by the iOS simulator, because it was emulating the file system on iOS. You caught file system-related bugs in the simulator before you even tried testing on device.

Actual Results:
The iOS simulator uses the same file system as your Mac, which is typically HFS+ (case insensitive). Since HFS+ is case insensitive, you might have written a file called FILE.TXT and read it back in as file.txt, and it would have worked. But it would have failed on any iOS device, because iOS has a case-sensitive file system. And since HFS+ normalizes Unicode character sequences, you might have written a file called café.txt with a U+00E9 “é” character, and read it back with a U+0065 U+0301 “e” followed by “combining ´ acute”, and it would have worked, but it would have failed on a 64-bit device running iOS 10.3+, because APFS does no normalization of file names.

Regression:
The iOS simulator has never been a perfect simulator of file name restrictions, because HFS+ is typically case insensitive, and iOS has always been case sensitive. But it got worse with iOS 10.3 (and, by extension, Xcode 8.3), because iOS switched to APFS, which diverges even farther from HFS+ (case insensitive).

Notes:
It seems like this could be solved by storing all of the files in the iOS simulator in a disk image with the right file system characteristics based on the iOS device and version being simulated. I believe the disk image could then be invisibly mounted, similar to how some software updates are installed via invisibly mounted disk images.

Comments

My reply

I'm not familiar with the foibles of the POSIX read/write APIs to put together a test, and I don't have any code that demonstrates the problem. I'll take your word for it that it's resolved.

Apple Developer Relations

Please verify this issue with the Xcode 9 beta and update your bug report at https://bugreport.apple.com/ with your results. Xcode 9 (9M136h) https://developer.apple.com/download/ Posted Date: June 5th, 2017


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!