iOS Flutter 开发环境部署
source link: https://easeapi.com/blog/167-flutter-ios-setup.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
iOS Flutter 开发环境部署
原创 2023-02-07
按计划应该是继续SwiftUI相关的,临时需求用到了Flutter,接下来的几篇可能都是和Flutter相关(只是可能)。本文记录iOS Flutter 开发环境部署步骤。
macOS Flutter 开发环境
参考文档:在 macOS 上安装和配置 Flutter 开发环境
从 Flutter SDK 版本列表 下载最新安装包或直接git clone
:
git clone https://github.com/flutter/flutter.git -b stable
将下载解压的或git clone
的文件路径添加进环境变量。比如,在 Linux 和 macOS Mojave 及之前的系统,是默认使用 Bash 终端的,需要修改 $HOME/.bashrc
文件;而 macOS Catalina 系统默认使用 Z Shell
,需要修改 $HOME/.zshrc 文件。
export PATH="$PATH:[PATH_OF_FLUTTER_DIRECTORY]/bin"
//查看 是否已经添加到 PATH 环境变量中
echo $PATH
运行 source $HOME/.bash_profile
来刷新使当前终端生效。
验证 flutter 命令是否可用:
which flutter
查看当前环境是否需要安装其他的依赖:
flutter doctor -v
设置 iOS 开发环境
确保安装了Xcode:
sudo xcode-select -s /Applications/Xcode.app
sudo xcodebuild -runFirstLaunch
新建Flutter App
flutter create easeapi_app
两种方式打开项目:
- 使用
Android Studio
打开
Android Studio
依次打开Preferences
> Plugins
,搜索安装 Flutter
和Dart
插件。使用Android Studio > Open an existing Android Studio project
打开easeapi_app
目录,可以直接选择 iOS 模拟器运行。
- 使用
Xcode
打开
直接通过Xcode
打开ios/Runner.xcworkspace
项目。
为iOS项目设置包名和开发者Team
flutter提供了自动化构建的命令:
flutter build ios --debug
使用前需要配置好项目的包名和开发者Team。通过Xcode打开项目 > TARGETS > Signing & Capabilities
。
为新建的Flutter App添加Podfile
cd ios
vim Podfile
platform:ios, '11.0'
source 'https://cdn.cocoapods.org/'
target 'Runner' do
pod 'EaseapiCom', :path => './'
end
执行:pod install
。不出意外的话,此时会报错:
CocoaPods did not set the base configuration of your project because your project already has a custom config set.
这是因为flutter
和Cocoapods
都为对应的PROJECT生成了xcconfig
文件,flutter
已经生成过xcconfig
,执行pod install
会提示文件已经存在,此时Cocoapods
的xcconfig
配置并未生效。
可以手动在flutter
生成的xcconfig
文件中引入pod install
生成的xcconfig
文件。具体操作步骤为:
vim ios/Flutter/Debug.xcconfig
#include "Generated.xcconfig"
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
vim ios/Flutter/Release.xcconfig
#include "Generated.xcconfig"
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
以上配置完成后,使用Xcode直接运行Runner.xcworkspace
即可。
iOS CoreMotion 传感器开发
iOS NSAttributedString NSHTMLTextDocumentType陷阱
Using a Custom Toolchain in Xcode
xcodebuild:code signature invalid
iOS安全:使用dumpdecrypted/Clutch 砸壳
您的电子邮箱地址不会被公开,必填项已用*标注。
留言内容 *
显示名称 *
电子邮箱地址 *
个人网站地址
在此浏览器中保存我的显示名称、邮箱地址和网站地址,以便下次留言时使用。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK