Flutter 混合原生工程 pod庫 和 script報錯

Pod庫引入 Flutter工程地址

官方文檔 : https://flutter.dev/docs/development/ios-project-migration
flutter官方 pod使用說明

pod podFile 文件添加的時候也要注意了!!!!!!

一定要注意 flutter的版本問題

flutter – version

如果是 1.8.4 版本以後的 使用 下面這種添加方式

# platform :ios, '9.0'
flutter_application_path = '../flutter_module'
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')

target 'flutter_testDemo' do
  # Comment the next line if you don't want to use dynamic frameworks
  install_all_flutter_pods(flutter_application_path)
  # Pods for flutter_testDemo
  target 'flutter_testDemoTests' do
    inherit! :search_paths
    # Pods for testing
  end
  target 'flutter_testDemoUITests' do
    # Pods for testing
  end
end

否則使用下面的這種


# platform :ios, '9.0'
target 'flutter_testDemo' do
  # Comment the next line if you don't want to use dynamic frameworks
  flutter_application_path = '../flutter_module'
  load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')
  # Pods for flutter_testDemo
  target 'flutter_testDemoTests' do
    inherit! :search_paths
    # Pods for testing
  end
  target 'flutter_testDemoUITests' do
    # Pods for testing
  end
end

flutter_application_path 路徑就是 你的 flutter_module 工程路徑
官方推薦 放在同級目錄下 所以用…/來找父級目錄可以找到工程

在這裏插入圖片描述

Xcode 添加 Run Script 選擇腳本地址

"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" build
"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" embed

如果報錯:
Command PhaseScriptExecution failed with a nonzero exit code
(我曾一度認爲 是我的地址配置出了問題還嘗試寫 死路徑 )

請檢查 Run script only when installing 是否勾選
在這裏插入圖片描述
僅在打包的時候運行腳本

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章