Open2

【Flutter】実機でビルドした時に遭遇したエラー

Yu YuYu Yu

事象

FlutterプロジェクトをiOSの実機でビルドした時に以下のエラーに遭遇した

Could not build the precompiled application for the device.
Error (Xcode): File not found:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphoneos.a


Error (Xcode): Linker command failed with exit code 1 (use -v to see invocation)

解決方法

Podfileのpost_install句に以下を追加したら解消した

post_install do |installer|
+  installer.generated_projects.each do |project|
+    project.targets.each do |target|
+      target.build_configurations.each do |config|
+        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
+      end
+   end
+  end
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end
Yu YuYu Yu

事象

多分dart:htmlはflutter webでしか使えないから、スマホアプリケーションでビルドするなら使うなって言われてる気がする

Could not build the precompiled application for the device.
Error (Xcode): lib/home_screen.dart:16:8: Error: Dart library 'dart:html' is not available on this platform.

Could not build the precompiled application for the device.
Error (Xcode): ../../.pub-cache/hosted/pub.dev/js-0.6.5/lib/js.dart:10:1: Error: Dart library
'dart:js' is not available on this platform.

解消方法

もしモバイルだけの対応でよければ以下の対応でよし

  1. 'dart:html'、'dart:js'は使ってないのでソース上から削除した。
  2. .pub-cache配下も一度全て削除
  3. flutter clean
  4. flutter run
    で解消した。

もし、モバイルもWebも対応する場合は以下を実施したら解消した。
https://qiita.com/strivesdfpx379/items/a2e9493405f4d754a982