我的Flutter版本 Flutter 1.9.1 不同版本差异还是有些的
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 是否勾选
仅在打包的时候运行脚本
/engine/ios does not exist
Command PhaseScriptExecution failed with a nonzero exit code
按照Xcode 中给出的提示你会发现确实没有 ios文件夹
这个cache文件夹 也可以选择清理一下 全删掉 然后运行 flutter doctor
然后就会看到
但是就不下载ios的不知道为啥
别慌运行一下你新建的 flutter_module 选择iOS模拟器
👏🏻
flutterTest.app/Frameworks/Flutter.framework: Permission denied
Command PhaseScriptExecution failed with a nonzero exit code
flutterTest.app /Frameworks/ Flutter.framework:拒绝访问
文件路径:flutter/packages/flutter_tools/bin/xcode_backend.sh
将144行的RunCommand find “${derived_dir}/engine/Flutter.framework” -type f -exec chmod a-w “{}” ;
改成RunCommand find “${derived_dir}/engine/Flutter.framework” -type f -iname ‘.h’ -exec chmod a-w “{}” ;
你会看到一个if else 两个里边的都要改
if [[ -e "${project_path}/.ios" ]]; then
RunCommand rm -rf -- "${derived_dir}/engine"
mkdir "${derived_dir}/engine"
RunCommand cp -r -- "${flutter_podspec}" "${derived_dir}/engine"
RunCommand cp -r -- "${flutter_framework}" "${derived_dir}/engine"
RunCommand find "${derived_dir}/engine/Flutter.framework" -type f -iname '.h' -exec chmod a-w "{}" \;
else
RunCommand rm -rf -- "${derived_dir}/Flutter.framework"
RunCommand cp -r -- "${flutter_framework}" "${derived_dir}"
RunCommand find "${derived_dir}/engine/Flutter.framework" -type f -iname '.h' -exec chmod a-w "{}" \;
fi
粘这个也成