国产精品主播叶子闺蜜_三级高清精品国产_99久久精品国产麻豆_国产精品无码免费专区午夜

歡迎您光臨深圳塔燈網絡科技有限公司!
電話圖標 余先生:13699882642

網站百科

為您解碼網站建設的點點滴滴

Flutter與iOS混編(pod)

發表日期:2018-11 文章編輯:小燈 瀏覽次數:4034

一、配置過程

  • 1. 新建一個xcode工程:FlutterNativeFrame
    跟flutter在同級別路徑

    image.png

  • 2. binding flutter

// flutter_application_path:flutter工程的絕對路徑 flutter_application_path = '**/**/my_flutter' eval(File.read(File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')), binding) 
image.png
  • 3.執行pod install
    執行完之后,打開xcode工程,出現如圖所示的兩個文件夾,success

    image.png

  • 4. 添加腳本文件
    "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" build "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" embed

    image.png

image.png

ok,run,如果運行報錯,把Enable Bitcode 設為NO,Flutter混合開發還不支持bit code,所以在iOS工程檢查項目并關閉bit code

image.png

現在應該可以運行起來了,如果還是不行,重復以上步驟

混編開始:
修改AppDelegate.h、AppDelegate.m

// .h #import <UIKit/UIKit.h> #import <Flutter/Flutter.h>@interface AppDelegate : FlutterAppDelegate @end// .m #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 { [GeneratedPluginRegistrant registerWithRegistry:self]; return [super application:application didFinishLaunchingWithOptions:launchOptions]; }@end 

ViewController跳轉

#import <Flutter/Flutter.h> #import "ViewController.h"@implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button addTarget:selfaction:@selector(handleButtonAction)forControlEvents:UIControlEventTouchUpInside]; [button setTitle:@"Press me" forState:UIControlStateNormal]; [button setBackgroundColor:[UIColor blueColor]]; button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0); [self.view addSubview:button]; }- (void)handleButtonAction { FlutterViewController* flutterViewController = [[FlutterViewController alloc] init]; [self presentViewController:flutterViewController animated:false completion:nil]; } @end 

二、熱更新 Hot Reload

cd到flutter工程路徑,執行flutter attach
attach成功之后,運行xcode,更新直接press 'r'

image.png

在VStudio中修改dart文件,press 'r'直接可以看到修改之后的顯示

官網鏈接:Hot reload https://flutter.io/docs/development/tools/hot-reload


本頁內容由塔燈網絡科技有限公司通過網絡收集編輯所得,所有資料僅供用戶學習參考,本站不擁有所有權,如您認為本網頁中由涉嫌抄襲的內容,請及時與我們聯系,并提供相關證據,工作人員會在5工作日內聯系您,一經查實,本站立刻刪除侵權內容。本文鏈接:http://www.juherenli.com/17756.html
相關APP開發