[iOS] allow enabling asserts from Plist. (flutter/engine#52069)
Part of https://github.com/flutter/flutter/issues/145729 . I don't believe (or wasn't able to find ) if there is a way to specify dart-vm flags from an iOS application. Once its installed, the tool provided process args won't work. By allowing this to be specified in the Plist, developers can ensure the value persists for subsequent launches.
This commit is contained in:
@@ -210,6 +210,11 @@ flutter::Settings FLTDefaultSettingsForBundle(NSBundle* bundle, NSProcessInfo* p
|
||||
settings.trace_systrace = enableTraceSystrace.boolValue;
|
||||
}
|
||||
|
||||
NSNumber* enableDartAsserts = [mainBundle objectForInfoDictionaryKey:@"FLTEnableDartAsserts"];
|
||||
if (enableDartAsserts != nil) {
|
||||
settings.dart_flags.push_back("--enable-asserts");
|
||||
}
|
||||
|
||||
NSNumber* enableDartProfiling = [mainBundle objectForInfoDictionaryKey:@"FLTEnableDartProfiling"];
|
||||
// Change the default only if the option is present.
|
||||
if (enableDartProfiling != nil) {
|
||||
|
||||
@@ -263,6 +263,20 @@ FLUTTER_ASSERT_ARC
|
||||
[mockMainBundle stopMocking];
|
||||
}
|
||||
|
||||
- (void)testEnableDartAssertsCommandLineArgument {
|
||||
id mockMainBundle = OCMPartialMock([NSBundle mainBundle]);
|
||||
OCMStub([mockMainBundle objectForInfoDictionaryKey:@"FLTEnableDartAsserts"]).andReturn(@"YES");
|
||||
id mockProcessInfo = OCMPartialMock([NSProcessInfo processInfo]);
|
||||
NSArray* arguments = @[ @"process_name" ];
|
||||
OCMStub([mockProcessInfo arguments]).andReturn(arguments);
|
||||
|
||||
auto settings = FLTDefaultSettingsForBundle(nil, mockProcessInfo);
|
||||
|
||||
XCTAssertEqual(settings.dart_flags.size(), 1u);
|
||||
XCTAssertEqual(settings.dart_flags[0], "--enable-asserts");
|
||||
[mockMainBundle stopMocking];
|
||||
}
|
||||
|
||||
- (void)testDisableImpellerSettingIsCorrectlyOverriddenByCommandLine {
|
||||
id mockMainBundle = OCMPartialMock([NSBundle mainBundle]);
|
||||
OCMStub([mockMainBundle objectForInfoDictionaryKey:@"FLTEnableImpeller"]).andReturn(@"YES");
|
||||
|
||||
Reference in New Issue
Block a user