最新iOS or Android 混合flutter開發流程

github.com/flutter/flu… 上面是官方的原文,有空我再逐字翻譯,下面我初略的講一下iOS的混合編譯流程。ios

(凡是遇到問題,或者從其餘過期譯文過來的讀者,必需要從第一步從新開始)git

1.先切換到flutter master分支,再升級sdkgithub

1.
flutter channel master

2.
flutter upgrade

//網絡情況本身解決,這兩步很重要
複製代碼

2.找到本身編寫的flutter項目的路徑bash

flutter_application_path = "../flutter_more/"
//我這裏寫的是相對路徑,能夠填寫絕對路徑,可是絕對路徑很差讓團隊其餘人操做
複製代碼

3.向podfile文件添加一下代碼網絡

flutter_application_path = "../flutter_more/"
//這裏的代碼上和過期的文檔不同,必定要改爲這樣!
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')

//向你須要引用的target添加如下代碼
install_all_flutter_pods(flutter_application_path)

//cocopods大家應該比我熟練,我今天才接觸
複製代碼
  1. 使用pod install
pod install

//若是報錯,請注意第三步的部分是否有出入
複製代碼

5.你如今已經能夠直接啓動了ios項目了,下面是綁定flutter橋的代碼(我從原文直接複製的代碼,你應該看得懂這部操做,另外,若是AppDelegate繼承了其餘類,原文中有其餘方式解決)app

In AppDelegate.h:

#import <UIKit/UIKit.h>
#import <Flutter/Flutter.h>

@interface AppDelegate : FlutterAppDelegate
@property (nonatomic,strong) FlutterEngine *flutterEngine;
@end

This allows AppDelegate.m to be really simple, unless your host app needs to override other methods here:

#import <FlutterPluginRegistrant/GeneratedPluginRegistrant.h> // Only if you have Flutter Plugins

#include "AppDelegate.h"

@implementation AppDelegate

// This override can be omitted if you do not have any Flutter Plugins.
- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  self.flutterEngine = [[FlutterEngine alloc] initWithName:@"io.flutter" project:nil];
  [self.flutterEngine runWithEntrypoint:nil];
  [GeneratedPluginRegistrant registerWithRegistry:self.flutterEngine];
  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}

@end
複製代碼

6.目前到這裏就結束了混編的基礎了。less

相關文章
相關標籤/搜索