iOS问题汇总

571 阅读1分钟

首次使用 xcode 打开 flutter 项目时,需要在项目目录下运行 flutter build ios 命令,它会依次运行 pop installxcode build,成功之后,再用 xcode 选择 ios 文件夹打开工程。

否则可能会出现很多错误,如

could not find included file 'Generated.xcconfig' in search paths

.dart_tool\package_config.json does not exist.

等等等等,所以,一定要先运行 flutter build ios,排除掉这些基础性的问题。

低版本机器上运行报错:

dyld: Library not loaded: @rpath/libswiftCore.dylib

可以在xcode里设置:

targets -> Build settings -> Always embed swift standard libraries -> Yes

不行的话,还可以在 build settings,搜索 runpath search paths,添加两项:

@executable_path/Frameworks

/usr/lib/swift

然后 xcode 里 clean 项目之后重新运行,这样基本就可以了。

xcode连接真机时,有时会有如下提示:

Xcode Unable to prepare iPhone for development

很可能是因为真机上的iOS系统较新,而xcode尚不支持,正常的流程是把xcode更新到最新,但更新xcode又可能需要将macOS更新到最新,如果不想这么做,可以在

filsv/iOSDeviceSupport: Xcode iPhoneOS DeviceSupport files (6.0 - 15.4) (github.com)

下载相应iOS版本的压缩包,解压后放到下面的目录中,重启xcode和真机即可:

xcode/Content/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport