63 bool hasExplicitBundle = bundle != nil;
68 auto settings = flutter::SettingsFromCommandLine(command_line,
true);
70 FML_CHECK(settings.merged_platform_ui_thread !=
71 flutter::Settings::MergedPlatformUIThread::kMergeAfterLaunch)
72 <<
"merged-platform-ui-thread=mergeAfterLaunch is not supported on iOS.";
74 settings.task_observer_add = [](intptr_t key,
const fml::closure& callback) {
75 fml::TaskQueueId queue_id = fml::MessageLoop::GetCurrentTaskQueueId();
76 fml::MessageLoopTaskQueues::GetInstance()->AddTaskObserver(queue_id, key, callback);
80 settings.task_observer_remove = [](fml::TaskQueueId queue_id, intptr_t key) {
81 fml::MessageLoopTaskQueues::GetInstance()->RemoveTaskObserver(queue_id, key);
84 settings.log_message_callback = [](
const std::string& tag,
const std::string& message) {
85 std::stringstream stream;
87 stream << tag <<
": ";
90 std::string log = stream.str();
91 [FlutterLogger logDirect:[NSString stringWithUTF8String:log.c_str()]];
94 settings.enable_platform_isolates =
true;
100 if (settings.icu_data_path.empty()) {
101 NSString* icuDataPath = [engineBundle pathForResource:
@"icudtl" ofType:
@"dat"];
102 if (icuDataPath.length > 0) {
103 settings.icu_data_path = icuDataPath.UTF8String;
107 if (flutter::DartVM::IsRunningPrecompiledCode()) {
108 if (hasExplicitBundle) {
109 NSString* executablePath = bundle.executablePath;
110 if ([[NSFileManager defaultManager] fileExistsAtPath:executablePath]) {
111 settings.application_library_paths.push_back(executablePath.UTF8String);
116 if (settings.application_library_paths.empty()) {
117 NSString* libraryName = [mainBundle objectForInfoDictionaryKey:
@"FLTLibraryPath"];
118 NSString* libraryPath = [mainBundle pathForResource:libraryName ofType:
@""];
119 if (libraryPath.length > 0) {
120 NSString* executablePath = [NSBundle bundleWithPath:libraryPath].executablePath;
121 if (executablePath.length > 0) {
122 settings.application_library_paths.push_back(executablePath.UTF8String);
129 if (settings.application_library_paths.empty()) {
130 NSString* applicationFrameworkPath = [mainBundle pathForResource:
@"Frameworks/App.framework"
132 if (applicationFrameworkPath.length > 0) {
133 NSString* executablePath =
134 [NSBundle bundleWithPath:applicationFrameworkPath].executablePath;
135 if (executablePath.length > 0) {
136 settings.application_library_paths.push_back(executablePath.UTF8String);
143 if (settings.assets_path.empty()) {
146 if (assetsPath.length == 0) {
147 NSLog(
@"Failed to find assets path for \"%@\
"", bundle);
149 settings.assets_path = assetsPath.UTF8String;
154 if (!flutter::DartVM::IsRunningPrecompiledCode()) {
155 NSURL* applicationKernelSnapshotURL =
157 relativeToURL:[NSURL fileURLWithPath:assetsPath]];
159 if ([applicationKernelSnapshotURL checkResourceIsReachableAndReturnError:&error]) {
160 settings.application_kernel_asset = applicationKernelSnapshotURL.path.UTF8String;
162 NSLog(
@"Failed to find snapshot at %@: %@", applicationKernelSnapshotURL.path, error);
171 settings.may_insecurely_connect_to_all_domains =
true;
172 settings.domain_network_policy =
"";
175 #if TARGET_OS_SIMULATOR
178 settings.enable_wide_gamut =
false;
183 BOOL enableWideGamut =
185 settings.enable_wide_gamut = enableWideGamut;
188 settings.warn_on_impeller_opt_out =
true;
190 NSNumber* nsEnableSDFs = [mainBundle objectForInfoDictionaryKey:
@"FLTEnableSDFs"];
191 settings.impeller_use_sdfs = (nsEnableSDFs ? nsEnableSDFs.boolValue : NO);
193 NSNumber* enableTraceSystrace = [mainBundle objectForInfoDictionaryKey:
@"FLTTraceSystrace"];
195 if (enableTraceSystrace != nil) {
196 settings.trace_systrace = enableTraceSystrace.boolValue;
199 NSNumber* profileMicrotasks = [mainBundle objectForInfoDictionaryKey:
@"FLTProfileMicrotasks"];
201 if (profileMicrotasks != nil) {
202 settings.profile_microtasks = profileMicrotasks.boolValue;
205 NSNumber* enableDartAsserts = [mainBundle objectForInfoDictionaryKey:
@"FLTEnableDartAsserts"];
206 if (enableDartAsserts != nil) {
207 settings.dart_flags.push_back(
"--enable-asserts");
210 NSNumber* enableDartProfiling = [mainBundle objectForInfoDictionaryKey:
@"FLTEnableDartProfiling"];
212 if (enableDartProfiling != nil) {
213 settings.enable_dart_profiling = enableDartProfiling.boolValue;
216 NSNumber* profileStartup = [mainBundle objectForInfoDictionaryKey:
@"FLTProfileStartup"];
218 if (profileStartup != nil) {
219 settings.profile_startup = profileStartup.boolValue;
223 NSNumber* leakDartVM = [mainBundle objectForInfoDictionaryKey:
@"FLTLeakDartVM"];
225 if (leakDartVM != nil) {
226 settings.leak_vm = leakDartVM.boolValue;
229 NSNumber* enableMergedPlatformUIThread =
230 [mainBundle objectForInfoDictionaryKey:
@"FLTEnableMergedPlatformUIThread"];
231 if (enableMergedPlatformUIThread != nil) {
232 FML_CHECK(enableMergedPlatformUIThread.boolValue)
233 <<
"FLTEnableMergedPlatformUIThread=false is no longer allowed.";
236 NSNumber* enableFlutterGPU = [mainBundle objectForInfoDictionaryKey:
@"FLTEnableFlutterGPU"];
237 if (enableFlutterGPU != nil) {
238 settings.enable_flutter_gpu = enableFlutterGPU.boolValue;
241 #if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
244 auto make_mapping_callback = [](
const uint8_t* mapping,
size_t size) {
245 return [mapping, size]() {
return std::make_unique<fml::NonOwnedMapping>(mapping, size); };
248 settings.dart_library_sources_kernel =
258 if (settings.old_gen_heap_size <= 0) {
259 settings.old_gen_heap_size = std::round([NSProcessInfo processInfo].physicalMemory * .48 /
260 flutter::kMegaByteSizeInBytes);
265 CGFloat scale = [UIScreen mainScreen].scale;
266 CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width * scale;
267 CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height * scale;
268 settings.resource_cache_max_bytes_threshold = screenWidth * screenHeight * 12 * 4;
278 NSNumber* enable_embedder_api =
279 [mainBundle objectForInfoDictionaryKey:
@"FLTEnableIOSEmbedderAPI"];
281 if (enable_embedder_api) {
282 settings.enable_embedder_api = enable_embedder_api.boolValue;
NSNumber *_Nullable FLTEnableWideGamutFromBundle(NSBundle *_Nullable bundle, NSBundle *_Nullable mainBundle)
static const char * kApplicationKernelSnapshotFileName
const intptr_t kPlatformStrongDillSize
FLUTTER_ASSERT_ARC const uint8_t kPlatformStrongDill[]
static BOOL DoesHardwareSupportWideGamut()
NSBundle * FLTGetApplicationBundle()
NSBundle * FLTFrameworkBundleWithIdentifier(NSString *flutterFrameworkBundleID)
NSString * FLTAssetsPathFromBundle(NSBundle *bundle)
fml::CommandLine CommandLineFromNSProcessInfo(NSProcessInfo *processInfoOrNil=nil)