Flutter IOS构建新手常见问题

版本介绍

XCode版本: 14.3

Flutter版本: 3.10.0

Pod包管理器

Pod 是一个 IOS 的包管理工具,就像安卓有 gradle 管理包一样,了解 Flutter 中 IOS 打包工具有助于我们在打包过程中减少错误

Flutter IOS 的配置文件路径:项目根目录/ios/Podfile

一、将 Runner.xcodeproj 当成 Runner.xcworkspace

问题: 将Runner.xcodeproj当成Runner.xcworkspace直接在XCode中跑这样会报错

解决方法:把Runner.xcworkspace文件放到XCode中跑

以下文件都在ios目录中

二、打包自动分配版本导致打包错误

问题: Automatically assigning platform iOS with version 8.0 on target Runner because no platform was specified. Please specify a platform for this target in your Podfile.

解决方法:

打开 Podfile 文件,将第一行的制定 IOS 版本打开

# Uncomment this line to define a global platform for your project
platform :ios, '11.0' # 解开注释即可# Uncomment this line to define a global platform for your project

三、ios 构建过程遇到xxx包不存在

原因: pod拉包的时候没有把某个包给下载下来

问题: Could not build the application for the simulator. Error launching application on iPhone 14 Pro Max.

解决方法:

  1. 删除掉 Podfile 文件,以及 Podfile.lock 文件
  2. 在项目终端运行 flutter clean
  3. 在项目终端运行 flutter pub get
  4. 在 IOS 目录运行 pod install
  5. 在项目终端运行 flutter run -v 即可

四、打包报错:xxx for architecture arm64

问题: Building for iOS Simulator, but linking in object file built for iOS, file '/xxx/xxxx' for architecture arm64

解决方法:

在 Flutter 项目中的 IOS 文件下打开

结尾

持续总结中....

猜你喜欢

转载自juejin.im/post/7255855818595369018