67 bool hasExplicitBundle = bundle != nil;
72 auto settings = flutter::SettingsFromCommandLine(command_line);
74 settings.task_observer_add = [](intptr_t key,
const fml::closure& callback) {
75 fml::MessageLoop::GetCurrent().AddTaskObserver(key, callback);
78 settings.task_observer_remove = [](intptr_t key) {
79 fml::MessageLoop::GetCurrent().RemoveTaskObserver(key);
82 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 syslog(LOG_ALERT,
"%.*s", (
int)log.size(), log.c_str());
98 if (settings.icu_data_path.empty()) {
99 NSString* icuDataPath = [engineBundle pathForResource:
@"icudtl" ofType:
@"dat"];
100 if (icuDataPath.length > 0) {
101 settings.icu_data_path = icuDataPath.UTF8String;
105 if (flutter::DartVM::IsRunningPrecompiledCode()) {
106 if (hasExplicitBundle) {
107 NSString* executablePath = bundle.executablePath;
108 if ([[NSFileManager defaultManager] fileExistsAtPath:executablePath]) {
109 settings.application_library_path.push_back(executablePath.UTF8String);
114 if (settings.application_library_path.empty()) {
115 NSString* libraryName = [mainBundle objectForInfoDictionaryKey:
@"FLTLibraryPath"];
116 NSString* libraryPath = [mainBundle pathForResource:libraryName ofType:
@""];
117 if (libraryPath.length > 0) {
118 NSString* executablePath = [NSBundle bundleWithPath:libraryPath].executablePath;
119 if (executablePath.length > 0) {
120 settings.application_library_path.push_back(executablePath.UTF8String);
127 if (settings.application_library_path.empty()) {
128 NSString* applicationFrameworkPath = [mainBundle pathForResource:
@"Frameworks/App.framework"
130 if (applicationFrameworkPath.length > 0) {
131 NSString* executablePath =
132 [NSBundle bundleWithPath:applicationFrameworkPath].executablePath;
133 if (executablePath.length > 0) {
134 settings.application_library_path.push_back(executablePath.UTF8String);
141 if (settings.assets_path.empty()) {
144 if (assetsPath.length == 0) {
145 NSLog(
@"Failed to find assets path for \"%@\
"", bundle);
147 settings.assets_path = assetsPath.UTF8String;
152 if (!flutter::DartVM::IsRunningPrecompiledCode()) {
153 NSURL* applicationKernelSnapshotURL =
155 relativeToURL:[NSURL fileURLWithPath:assetsPath]];
157 if ([applicationKernelSnapshotURL checkResourceIsReachableAndReturnError:&error]) {
158 settings.application_kernel_asset = applicationKernelSnapshotURL.path.UTF8String;
160 NSLog(
@"Failed to find snapshot at %@: %@", applicationKernelSnapshotURL.path, error);
169 settings.may_insecurely_connect_to_all_domains =
true;
170 settings.domain_network_policy =
"";
173 #if TARGET_OS_SIMULATOR
176 settings.enable_wide_gamut =
false;
180 NSNumber* nsEnableWideGamut = [mainBundle objectForInfoDictionaryKey:
@"FLTEnableWideGamut"];
181 BOOL enableWideGamut =
183 settings.enable_wide_gamut = enableWideGamut;
190 if (!command_line.HasOption(
"enable-impeller")) {
192 NSNumber* enableImpeller = [bundle objectForInfoDictionaryKey:
@"FLTEnableImpeller"];
193 if (enableImpeller == nil) {
195 enableImpeller = [mainBundle objectForInfoDictionaryKey:
@"FLTEnableImpeller"];
198 if (enableImpeller != nil) {
199 settings.enable_impeller = enableImpeller.boolValue;
203 settings.warn_on_impeller_opt_out =
true;
205 NSNumber* enableTraceSystrace = [mainBundle objectForInfoDictionaryKey:
@"FLTTraceSystrace"];
207 if (enableTraceSystrace != nil) {
208 settings.trace_systrace = enableTraceSystrace.boolValue;
211 NSNumber* enableDartProfiling = [mainBundle objectForInfoDictionaryKey:
@"FLTEnableDartProfiling"];
213 if (enableDartProfiling != nil) {
214 settings.enable_dart_profiling = enableDartProfiling.boolValue;
218 NSNumber* leakDartVM = [mainBundle objectForInfoDictionaryKey:
@"FLTLeakDartVM"];
220 if (leakDartVM != nil) {
221 settings.leak_vm = leakDartVM.boolValue;
224 #if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
227 auto make_mapping_callback = [](
const uint8_t* mapping,
size_t size) {
228 return [mapping, size]() {
return std::make_unique<fml::NonOwnedMapping>(mapping, size); };
231 settings.dart_library_sources_kernel =
233 #endif // FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
241 if (settings.old_gen_heap_size <= 0) {
242 settings.old_gen_heap_size = std::round([NSProcessInfo processInfo].physicalMemory * .48 /
243 flutter::kMegaByteSizeInBytes);
248 CGFloat scale = [UIScreen mainScreen].scale;
249 CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width * scale;
250 CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height * scale;
251 settings.resource_cache_max_bytes_threshold = screenWidth * screenHeight * 12 * 4;
254 NSNumber* enable_embedder_api =
255 [mainBundle objectForInfoDictionaryKey:
@"FLTEnableIOSEmbedderAPI"];
257 if (enable_embedder_api) {
258 settings.enable_embedder_api = enable_embedder_api.boolValue;