Firebase 和 Firebase Analytics 在 Xcode 15 中出现错误
我喜欢为苹果平台开发,但有时开发环境有助于我们发展或提高耐心。
在 Xcode 15 中,Apple 对指向默认工具链位置的变量进行了修改,将其从 $DT_TOOLCHAIN_DIR 更换为 $TOOLCHAIN_DIR。
DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead
如果您的项目或目标依赖于之前的变量,则应将其更新为使用 $TOOLCHAIN_DIR。
要避免每次需要清理项目时执行此更换,请在您的 Podfile 末尾添加以下代码片段:
# Solution for: macOS v14 (Sonoma) | XCode 15.4 | Swift 5.0 | PodFile
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
# Update the Swift version
config.build_settings['SWIFT_VERSION'] = '5.0'
# Update all Pods iOS Deployment Target ios Version
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.0'
# Update LIBRARY_SEARCH_PATHS
['Firebase.release.xcconfig', 'FirebaseAnalytics.release.xcconfig'].each do |file_name|
Dir.glob("Pods/**/#{file_name}", File::FNM_CASEFOLD).each do |xcconfig_path|
text = File.read(xcconfig_path)
new_contents = text.gsub('DT_TOOLCHAIN_DIR', 'TOOLCHAIN_DIR')
File.open(xcconfig_path, "w") {|file| file.puts new_contents }
end
end
end
end
end
和跑步
pod install
此错误能在 macOS 14(Sonoma)、XCode 15.4、Swift 5.0 或更高版本的设置环境中与 Firebase 和 Firebase Analytics Pods 相关。
这种方法可以挽救几个小时的生命。