發表日期:2018-09 文章編輯:小燈 瀏覽次數:2394
本文接著上一篇 Flutter筆記之安裝和運行(一) ,本文主要記錄在搭建 Flutter iOS 環境時所遇到的問題。
使用 flutter doctor 命令,基本會提示需要 Xcode 9.x 以上,因此首先就要保證 MacOS 需要 10.12.x 以上,推薦 MacOS 升級到最新穩定版本(目前本人升級到 MacOS 10.13.6,對應 Xcode 9.4.1,啰嗦一下升級有風險~~ 建議看看 升級MacOS High Sierra目前遇到的所有問題匯總(已解決,升級遇到問題必讀) ?),然后去 More Downloads for Apple Developers 頁,下載相應的 Command Lines Tools for Xcode 后面安裝libimobiledevice、ideviceinstaller 等環境都要用到。
基本安裝iOS環境都是用 HomeBrew,如果已經安裝了,為了保證能順利安裝軟件,還要使用 brew update 命令更新 HomeBrew(注:這里可能需要閱讀設置 brew 鏡像,沒問題的就略過吧)
完成 MacOS 和 HomeBrew 提到的準備工作,基本就可以按照提示,一步步執行了:
iOS toolchain - develop for iOS devices (Xcode 9.4.1)
? ideviceinstaller is not installed; this is used to discover connected iOS devices.
To install, run:
brew install --HEAD libimobiledevice
brew install ideviceinstaller
? ios-deploy not installed. To install:
brew install ios-deploy
? CocoaPods not installed.
CocoaPods is used to retrieve the iOS platform side's plugin code that responds to your plugin usage on the Dart side.
Without resolving iOS dependencies with CocoaPods, plugins will not work on iOS.
For more info, see https://flutter.io/platform-plugins
To install:
brew install cocoapods
pod setup
在過程中, iOS程序的依賴管理工具CocoaPods,在最后一步 pod setup 可能會出現 "error: RPC failed; curl 56 SSLRead" 錯誤,如下圖:
最后,放一張 Flutter 的雙平臺 Demo 圖,結束這篇安裝筆記~~