為您解碼網(wǎng)站建設(shè)的點(diǎn)點(diǎn)滴滴
發(fā)表日期:2018-11 文章編輯:小燈 瀏覽次數(shù):1733
1 創(chuàng)建iOS項(xiàng)目(做測(cè)試使用)
2 cocoapods走起
project 'XX.xcodeproj' #source 'https://github.com/CocoaPods/Specs.git' #platform :ios, '9.0' #inhibit_all_warnings! # Uncomment the next line to define a global platform for your project # platform :ios, '9.0'target 'XX' do # Uncomment the next line if you're using Swift or would like to use dynamic frameworks # use_frameworks!# Pods for XXtarget 'XXTests' do inherit! :search_paths # Pods for testing endtarget 'XXUITests' do inherit! :search_paths # Pods for testing endend flutter_application_path = './flutter_module' eval(File.read(File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')), binding)
關(guān)鍵部鋒分就是末尾添加的
flutter_application_path = './flutter_module' eval(File.read(File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')), binding)
3 進(jìn)入項(xiàng)目根目錄添加flutter_module
flutter create -t module flutter_module
4 Xcode 設(shè)置
Build Phases 添加 Run Scripts
"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" build
4 pod install
5 code設(shè)置
5.1 Appdelegate
#import <Flutter/Flutter.h> @interface AppDelegate : FlutterAppDelegate//@property (strong, nonatomic) UIWindow *window; @end
#import <FlutterPluginRegistrant/GeneratedPluginRegistrant.h> // Only if you have Flutter Plugins- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. [GeneratedPluginRegistrant registerWithRegistry:self]; return [super application:application didFinishLaunchingWithOptions:launchOptions]; }
5.2 Controller切換
- (IBAction)pushFlutterVC:(id)sender { FlutterViewController *flutterViewController = [[FlutterViewController alloc] init]; flutterViewController.view.backgroundColor = [UIColor cyanColor]; [flutterViewController setInitialRoute:@"route1"];[self presentViewController:flutterViewControlleranimated:YES completion:^{UIViewController * vc = [[NextViewController alloc] init]; // vc.view.backgroundColor = [UIColor whiteColor];AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;UIViewController * rootVC = appDelegate.window.rootViewController;UIViewController * topVC = nil;if ([rootVC isKindOfClass:[UINavigationController class]]) { topVC =((UINavigationController *)rootVC).topViewController.presentedViewController;} else {topVC =rootVC.presentedViewController;}[topVC presentViewController:vc animated:YES completion:nil];}]; }
5.2中我們要考慮到首頁(yè)是Nav UIViewCOntrooler 或者是FlutterViewController
到此我們的就可以直接X(jué)code run運(yùn)行項(xiàng)目啦
6 假如想實(shí)現(xiàn)hot reload
進(jìn)入項(xiàng)目中的flutter_module,運(yùn)行 flutter attach
日期:2018-10 瀏覽次數(shù):7544
日期:2018-12 瀏覽次數(shù):4627
日期:2018-07 瀏覽次數(shù):5140
日期:2018-12 瀏覽次數(shù):4420
日期:2018-09 瀏覽次數(shù):5781
日期:2018-12 瀏覽次數(shù):10199
日期:2018-11 瀏覽次數(shù):5111
日期:2018-07 瀏覽次數(shù):4862
日期:2018-05 瀏覽次數(shù):5119
日期:2018-12 瀏覽次數(shù):4591
日期:2018-10 瀏覽次數(shù):5395
日期:2018-12 瀏覽次數(shù):6465
日期:2018-11 瀏覽次數(shù):4720
日期:2018-08 瀏覽次數(shù):4872
日期:2018-11 瀏覽次數(shù):12965
日期:2018-09 瀏覽次數(shù):5883
日期:2018-12 瀏覽次數(shù):5100
日期:2018-10 瀏覽次數(shù):4445
日期:2018-11 瀏覽次數(shù):4798
日期:2018-12 瀏覽次數(shù):6326
日期:2018-06 瀏覽次數(shù):4268
日期:2018-08 瀏覽次數(shù):5714
日期:2018-10 瀏覽次數(shù):4704
日期:2018-12 瀏覽次數(shù):4821
日期:2018-07 瀏覽次數(shù):4633
日期:2018-12 瀏覽次數(shù):4805
日期:2018-06 瀏覽次數(shù):4639
日期:2018-11 瀏覽次數(shù):4624
日期:2018-12 瀏覽次數(shù):4556
日期:2018-12 瀏覽次數(shù):5534
Copyright ? 2013-2018 Tadeng NetWork Technology Co., LTD. All Rights Reserved.