Crash on iOS 16 when built with Xcode 15 in release mode only - Symbol not found: _$s10Foundation13__DataStorageC12replaceBytes2in4with6lengthySnySiG_SVSgSitF

When running on iOS 16 in release mode, my app (built with Xcode 15) crashes with the following message:

Symbol not found: _$s10Foundation13__DataStorageC12replaceBytes2in4with6lengthySnySiG_SVSgSitF

The same app works fine when:

  • Run on iOS 16 in debug mode
  • Run on iOS 17
  • Built with Xcode 14

There are no deprecation warnings showing in Xcode, and everything compiles fine. I found this method that seems to match the missing symbol (https://developer.apple.com/documentation/foundation/nsmutabledata/1412428-replacebytes); however, it's not being used anywhere in the app.

Is there a specific symbol removed in Xcode 15 causing this issue?

Thank you!

Are you using 3rd party frameworks, pods, or swift packages? If so, scan the sources of the latter two pods & packages.

Are you using append(contentsOf:) or replaceSubrange() anywhere in your source code for any Data or String types?

Thank you for the reply! I isolated the issue to a 3rd party Swift package, so I copied the Swift source files into an empty Xcode project to reproduce the crash. This project has no 3rd party dependencies, as the Swift package did not have any dependencies either.

The source code uses replaceSubrange() on an Array, but not append(contentsOf:) specifically. It does use several Data operations, such as append(_ int).

I copied the Swift source files into an empty Xcode project to reproduce the crash.

Are you able to further reduce this to the point where you can paste an example in here? I’d love to take a look at it.

Share and Enjoy

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

I haven't been able to reduce it to a single file, but I've uploaded the Swift files I copied into the empty project here: https://github.com/enchantingmoon/EuclidDebug.

Another developer provided the following info with a Feedback ID: https://github.com/nicklockwood/Euclid/issues/107#issuecomment-1730491594

This seems to be an SDK issue (I've filed FB13195864): The missing symbol is a variant of the internal __DataStorage.replaceBytes method that takes a Range<Int>, which, despite being added in iOS 17, is incorrectly marked as being ?>available back to iOS 8. The method is usable from inline, and a reference to it gets inlined into the app (via a couple layers of inlined framework code). And so the app crashes when >running pre-iOS 17 since method does not actually exist.

Another developer … filed FB13195864

OK, that’s definitely a bug in Foundation and is getting some traction.

I isolated the issue to a 3rd party Swift package, so I copied the Swift source files into an empty Xcode project to reproduce the crash.

Is the “3rd party Swift package” mentioned in this quote the Euclid package you referenced later? If so, it’s probably best to follow the package author’s lead here.

Share and Enjoy

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

Crash on iOS 16 when built with Xcode 15 in release mode only - Symbol not found: _$s10Foundation13__DataStorageC12replaceBytes2in4with6lengthySnySiG_SVSgSitF
 
 
Q