新建一个项目iOSMixFlutter
@property (strong, nonatomic) UIWindow *window;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
[self.window setBackgroundColor:[UIColor whiteColor]];
self.window.rootViewController = [[ViewController alloc] init];
[self.window makeKeyAndVisible];
return YES;
}
运行界面为
用cocopod初始化,步骤为
https://www.jianshu.com/p/c3e20ec5cf9d
执行
清除flutter缓存
rm /Applications/flutter/bin/cache/lockfile
让配置生效
source ~/.bash_profile
进入相关文件
cd /Users/yyz/Desktop/flutterMix/iOSMixFlutter
生成flutter的module
flutter create --template module my_flutter
执行结束如下图
修改Podfile文件
flutter_application_path = './my_flutter'
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')
install_all_flutter_pods(flutter_application_path)
执行pod install
运行项目点击跳转成功
写第一个demo的时候 ,运行失败了,flutter的路径除了问题,加了脚本,OK了!
flutter sdk的路径
"/Applications/flutter/packages/flutter_tools/bin/xcode_backend.sh" build
"/Applications/flutter/packages/flutter_tools/bin/xcode_backend.sh" embed
网上查的相对路径,不好使,所以填了绝对路径
"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" build
"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" embed