59 bool hasExplicitBundle = bundle != nil;
64 auto settings = flutter::SettingsFromCommandLine(command_line);
66 settings.task_observer_add = [](intptr_t key,
const fml::closure& callback) {
67 fml::MessageLoop::GetCurrent().AddTaskObserver(key, callback);
70 settings.task_observer_remove = [](intptr_t key) {
71 fml::MessageLoop::GetCurrent().RemoveTaskObserver(key);
74 settings.log_message_callback = [](
const std::string& tag,
const std::string& message) {
77 std::stringstream stream;
79 stream << tag <<
": ";
82 std::string log = stream.str();
83 syslog(LOG_ALERT,
"%.*s", (
int)log.size(), log.c_str());
86 settings.enable_platform_isolates =
true;
92 if (settings.icu_data_path.empty()) {
93 NSString* icuDataPath = [engineBundle pathForResource:
@"icudtl" ofType:
@"dat"];
94 if (icuDataPath.length > 0) {
95 settings.icu_data_path = icuDataPath.UTF8String;
99 if (flutter::DartVM::IsRunningPrecompiledCode()) {
100 if (hasExplicitBundle) {
101 NSString* executablePath = bundle.executablePath;
102 if ([[NSFileManager defaultManager] fileExistsAtPath:executablePath]) {
103 settings.application_library_path.push_back(executablePath.UTF8String);
108 if (settings.application_library_path.empty()) {
109 NSString* libraryName = [mainBundle objectForInfoDictionaryKey:
@"FLTLibraryPath"];
110 NSString* libraryPath = [mainBundle pathForResource:libraryName ofType:
@""];
111 if (libraryPath.length > 0) {
112 NSString* executablePath = [NSBundle bundleWithPath:libraryPath].executablePath;
113 if (executablePath.length > 0) {
114 settings.application_library_path.push_back(executablePath.UTF8String);
121 if (settings.application_library_path.empty()) {
122 NSString* applicationFrameworkPath = [mainBundle pathForResource:
@"Frameworks/App.framework"
124 if (applicationFrameworkPath.length > 0) {
125 NSString* executablePath =
126 [NSBundle bundleWithPath:applicationFrameworkPath].executablePath;
127 if (executablePath.length > 0) {
128 settings.application_library_path.push_back(executablePath.UTF8String);
135 if (settings.assets_path.empty()) {
138 if (assetsPath.length == 0) {
139 NSLog(
@"Failed to find assets path for \"%@\
"", bundle);
141 settings.assets_path = assetsPath.UTF8String;
146 if (!flutter::DartVM::IsRunningPrecompiledCode()) {
147 NSURL* applicationKernelSnapshotURL =
149 relativeToURL:[NSURL fileURLWithPath:assetsPath]];
151 if ([applicationKernelSnapshotURL checkResourceIsReachableAndReturnError:&error]) {
152 settings.application_kernel_asset = applicationKernelSnapshotURL.path.UTF8String;
154 NSLog(
@"Failed to find snapshot at %@: %@", applicationKernelSnapshotURL.path, error);
163 settings.may_insecurely_connect_to_all_domains =
true;
164 settings.domain_network_policy =
"";
167 #if TARGET_OS_SIMULATOR
170 settings.enable_wide_gamut =
false;
174 NSNumber* nsEnableWideGamut = [mainBundle objectForInfoDictionaryKey:
@"FLTEnableWideGamut"];
175 BOOL enableWideGamut =
177 settings.enable_wide_gamut = enableWideGamut;
180 settings.warn_on_impeller_opt_out =
true;
182 NSNumber* enableTraceSystrace = [mainBundle objectForInfoDictionaryKey:
@"FLTTraceSystrace"];
184 if (enableTraceSystrace != nil) {
185 settings.trace_systrace = enableTraceSystrace.boolValue;
188 NSNumber* enableDartAsserts = [mainBundle objectForInfoDictionaryKey:
@"FLTEnableDartAsserts"];
189 if (enableDartAsserts != nil) {
190 settings.dart_flags.push_back(
"--enable-asserts");
193 NSNumber* enableDartProfiling = [mainBundle objectForInfoDictionaryKey:
@"FLTEnableDartProfiling"];
195 if (enableDartProfiling != nil) {
196 settings.enable_dart_profiling = enableDartProfiling.boolValue;
200 NSNumber* leakDartVM = [mainBundle objectForInfoDictionaryKey:
@"FLTLeakDartVM"];
202 if (leakDartVM != nil) {
203 settings.leak_vm = leakDartVM.boolValue;
206 NSNumber* enableMergedPlatformUIThread =
207 [mainBundle objectForInfoDictionaryKey:
@"FLTEnableMergedPlatformUIThread"];
208 if (enableMergedPlatformUIThread != nil) {
209 settings.merged_platform_ui_thread = enableMergedPlatformUIThread.boolValue;
212 #if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
215 auto make_mapping_callback = [](
const uint8_t* mapping,
size_t size) {
216 return [mapping, size]() {
return std::make_unique<fml::NonOwnedMapping>(mapping, size); };
219 settings.dart_library_sources_kernel =
221 #endif // FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
229 if (settings.old_gen_heap_size <= 0) {
230 settings.old_gen_heap_size = std::round([NSProcessInfo processInfo].physicalMemory * .48 /
231 flutter::kMegaByteSizeInBytes);
236 CGFloat scale = [UIScreen mainScreen].scale;
237 CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width * scale;
238 CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height * scale;
239 settings.resource_cache_max_bytes_threshold = screenWidth * screenHeight * 12 * 4;
242 NSNumber* enable_embedder_api =
243 [mainBundle objectForInfoDictionaryKey:
@"FLTEnableIOSEmbedderAPI"];
245 if (enable_embedder_api) {
246 settings.enable_embedder_api = enable_embedder_api.boolValue;