[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:
Jonah Williams
2024-04-15 17:06:05 -07:00
committed by GitHub
parent d3232cba08
commit 9c212d5d0d
2 changed files with 19 additions and 0 deletions

View File

@@ -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) {

View File

@@ -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");