1// Copyright 2013 The Flutter Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#import "flutter/shell/platform/darwin/macos/framework/Headers/FlutterDartProject.h" 6#import "flutter/shell/platform/darwin/macos/framework/Source/FlutterDartProject_Internal.h" 7 8#include <vector> 9 10static NSString* const kICUBundlePath = @"icudtl.dat"; 11 12@implementation FlutterDartProject { 13 NSBundle* _bundle; 14} 15 16- (instancetype)init { 17 return [self initWithPrecompiledDartBundle:nil]; 18} 19 20- (instancetype)initWithPrecompiledDartBundle:(NSBundle*)bundle { 21 self = [super init]; 22 NSAssert(self, @"Super init cannot be nil"); 23 24 _bundle = bundle ?: [NSBundle mainBundle]; 25 return self; 26} 27 28- (NSString*)assetsPath { 29 NSString* flutterAssetsName = [_bundle objectForInfoDictionaryKey:@"FLTAssetsPath"]; 30 if (flutterAssetsName == nil) { 31 flutterAssetsName = @"flutter_assets"; 32 } 33 NSString* path = [_bundle pathForResource:flutterAssetsName ofType:@""]; 34 if (!path) { 35 NSLog(@"Failed to find path for \"%@\"", flutterAssetsName); 36 } 37 return path; 38} 39 40- (NSString*)ICUDataPath { 41 NSString* path = [[NSBundle bundleForClass:[self class]] pathForResource:kICUBundlePath 42 ofType:nil]; 43 if (!path) { 44 NSLog(@"Failed to find path for \"%@\"", kICUBundlePath); 45 } 46 return path; 47} 48 49- (std::vector<const char*>)argv { 50 // FlutterProjectArgs expects a full argv, so when processing it for flags the first item is 51 // treated as the executable and ignored. Add a dummy value so that all provided arguments 52 // are used. 53 std::vector<const char*> arguments = {"placeholder"}; 54 for (NSUInteger i = 0; i < _engineSwitches.count; ++i) { 55 arguments.push_back([_engineSwitches[i] UTF8String]); 56 } 57 return arguments; 58} 59 60@end 61