sentry-cocoa icon indicating copy to clipboard operation
sentry-cocoa copied to clipboard

AFNetworking swizzle breaking Xcode localization setting

Open MaxHasADHD opened this issue 3 years ago • 2 comments

Platform

macOS

Installed

Swift Package Manager

Version

7.23.0

Steps to Reproduce

  1. Create a new project, add Sentry with Swift Package Manager and add the setup code in your Main file of the project.
  2. Add a Localizable.strings file, and add a string. "Key" = "Value";
  3. In your main view, for a SwiftUI app, add Text("Key")
  4. Edit the current scheme, go to Options and change the language to Double-length pseudolanguage.
  5. 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.

MaxHasADHD avatar Aug 09 '22 16:08 MaxHasADHD

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.

brustolin avatar Aug 11 '22 08:08 brustolin

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

brustolin avatar Aug 11 '22 08:08 brustolin

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.

philipphofmann avatar Feb 28 '24 13:02 philipphofmann