Launch arguments (NSDoubleLocalizedStrings, NSShowNonLocalizedStrings) not working

I am trying to use launch options like NSDoubleLocalizedStrings

and NSShowNonLocalizedStrings

to check localization in my Objective-C project. For some reason, I couldn't get any of them to work. I tried to set both arguments on startup and options in schema settings: Also I checked the keys and both of them . But the arguments still don't work.enter image description here  enter image description hereNSUserDefaults

YES

To make sure this is not an Xcode bug, I created a completely new project with one view in Objective-C and Swift with one label on the view. Both projects had empty Localizable.strings

files, and the code in these projects:

@interface ViewController ()
@property (nonatomic, strong) IBOutlet UILabel *label;
@end

@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    self.label.text = NSLocalizedString(@"Some text", nil);
}
@end

      

and

class ViewController: UIViewController {
    @IBOutlet var label: UILabel!

    override func viewDidLoad() {
        super.viewDidLoad()
        label.text = NSLocalizedString("Some text", comment: "")
    }
}

      

The result looks like this:

enter image description here

So here are the questions:

1) What could be the reasons why the startup arguments are not working in my Objective-C project?

2) Why NSDoubleLocalizedStrings

doesn't the argument work in Swift?

+3


source to share


1 answer


After spending a couple of days researching and gradually removing all files and frameworks from my Objective-C project, I realized that the reason was in the library AFNetworking

. This question is described here . If you want to use AFNetworking

in your project and debug localization issues, you can add lines like this toapplication: didFinishLaunchingWithOptions:

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setBool:YES forKey:@"NSDoubleLocalizedStrings"];
[defaults setBool:YES forKey:@"NSShowNonLocalizedStrings"];
[defaults synchronize];

      



The second time you run the application, you will see how these launch arguments work.

The answer to the second question about why the argument NSDoubleLocalizedStrings

doesn't work in Swift is that it is probably a bug in XCode. This may be due to macros that are not supported in Swift but NSLocalizedString

are actually macros. So I created a bug on radar .

+1


source







All Articles