AFNetworking swizzle breaking Xcode localization setting
Platform
macOS
Installed
Swift Package Manager
Version
7.23.0
Steps to Reproduce
- Create a new project, add Sentry with Swift Package Manager and add the setup code in your Main file of the project.
- Add a Localizable.strings file, and add a string.
"Key" = "Value"; - In your main view, for a SwiftUI app, add
Text("Key") - Edit the current scheme, go to Options and change the language to Double-length pseudolanguage.
- Run app
Expected Result
Text label should appear as "Value Value"
Actual Result
Label is "Value". If you remove the Sentry initialization it works properly. This is related to this thread here: https://github.com/AFNetworking/AFNetworking/issues/3303. No real fix has been found.
Hello @MaxHasADHD. Thanks for this.
Indeed I was able to reproduce the problem.
Since the "Double-length pseudolanguage" is meant for tests purpose, while testing you can disable enableNetworkTracking and enableNetworkBreadcrumbs in you Sentry options.
The permanent solution for this is easy, we just need to postpone the swizzling of URLSessionTask for the end of the main loop with a dispatch_async.
The side effect is that we may loose some requests being done at the initialization of the app, like inside appDidFinishLaunch
I'm closing this due to inactivity and the workaround explained in https://github.com/getsentry/sentry-cocoa/issues/2052#issuecomment-1211695245. Please reopen the issue if it still persists @MaxHasADHD.