LoginSignup
8
4

Xcode 15 でCocoaPodsを利用したプロジェクトをビルドしたら"DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead"が発生した。

Last updated at Posted at 2023-09-25

現象

Xcode15にアップデートしたのち、ビルドをすると以下のエラーが発生しました。

DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead

読み取ると
デフォルトのツールチェーンの場所を指す変数$DT_TOOLCHAIN_DIR$TOOLCHAIN_DIRに変更したようです。プロジェクト/ターゲットが$DT_TOOLCHAIN_DIRを使用している場合は、$TOOLCHAIN_DIRに置き換える必要があります。

解決法

下記のスクリプトをpodfileに追記します。

podfile
post_install do |installer|
	xcode_base_version = `xcodebuild -version | grep 'Xcode' | awk '{print $2}' | cut -d . -f 1`
    # 既存のスクリプトなどで以下が記載されている場合、↑の変数だけ追加すればOK
	installer.pods_project.targets.each do |target|
		target.build_configurations.each do |config|
			# Xcode 15以上で動作します(if内を追記)
			if config.base_configuration_reference && Integer(xcode_base_version) >= 15
				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
end

その後、podコマンドで各ライブラリを更新してください。

pod install

引用元

こちらに解決方法が丸々載っていました。

8
4
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
8
4