LoginSignup
0
0

iOS17端末でFlutterアプリがビルドできない問題解決備忘録

Last updated at Posted at 2023-09-21

前提

flutter 3.7.0を利用したプロジェクトです。

背景

Xcode15が正式リリースされたので、試しにアップデートしたところ、以下のエラーが出てFlutterアプリのiOSビルドが出来なくなりました。
プロジェクトの中でflutter_inappwebviewを利用しているとエラーが発生するみたいなので、備忘録のためワークアラウンドを記載します。

エラー内容

Error (Xcode): DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead

DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR insteadの解決方法

CocoaPodsのissue上で解決方法が紹介されていましたのでPodfileを書き換えてみます。

post_install do |installer|
      installer.pods_project.targets.each do |target|
          target.build_configurations.each do |config|
          xcconfig_path = config.base_configuration_reference.real_path
          xcconfig = File.read(xcconfig_path)
          xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
          File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
          end
      end
  end

Error (Xcode): DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR insteadのエラーは解決しましたが、新たに以下のエラーが発生しました。

エラー内容

undefined method `real_path' for nil:NilClass

undefined method `real_path' for nil:NilClassの解決方法

CocoaPodsのissue上でnilチェックを追加することが紹介されていました。以下のようにPodfileを書き換えてみます。

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      if config.base_configuration_reference
        xcconfig_path = config.base_configuration_reference.real_path
        xcconfig = File.read(xcconfig_path)
        xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
        File.open(xcconfig_path, "w") { |file| file << xcconfig_mod } 
      end
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
    end
  end
end

pod installは成功するものの、ビルド時に新たに以下のエラーが発生しました。

エラー内容

Could not build module 'WebKit'

使っているflutter_inappwebviewに問題があるそうで、以下のワークアラウンドをpubspec.yamlに追加してみます。

  flutter_inappwebview:
    git:
      url: https://github.com/Estrelio/flutter_inappwebview.git
      ref: fix-xcode-17

以上で無事にiOSアプリのビルドとアーカイブが出来るようになりました。
今回の解決方法はあくまでもワークアラウンドなので、正式な対応方法が出たらまたご紹介します。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0