筆記: 報錯library not found for -lstdc++.6.0.9如何解決

低版本Xcode升級到Xcode10以後,將廢棄libstdc++6.0.9的庫,致使不少用到這個庫的項目會報出library not found for -lstdc++.6.0.9錯誤。ios

手動依賴了第三方庫致使報錯,如何解決(臨時方案)

升級第三方庫,或將低版本Xcode9的libstdc++6.0.9.tbd拷貝到Xcode10的目錄下 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform(模擬器下運行:iPhoneSimulator.platform)/Developer/SDKs/iPhoneOS.sdk/usr/lib/c++

注意: 此方法只能暫時性解決問題,Xcode升級後須要從新拷貝libstdc++6.0.9.tbdbash

CocoaPods依賴第三方庫報錯解決方案(推薦使用)

在Podfile中增長post_install的hook,移除Pods目錄從新pod install便可,hook部分代碼以下app

platform :ios, '9.0'
	use_frameworks!
	
	target "DEMO" do
	
	    pod 'MJRefresh'
	end
	
	post_install do |installer_representation|
	    installer_representation.pods_project.targets.each do |target|
	        // DEMO 爲本身項目的target名
	        if target.name == 'Pods-DEMO'
	            target.build_configurations.each do |config|
	                xcconfig_path = config.base_configuration_reference.real_path
	                xcconfig = File.read(xcconfig_path)
	                new_xcconfig = xcconfig.sub('stdc++.6.0.9', 'c++')
	                File.open(xcconfig_path, "w") { |file| file << new_xcconfig }
	            end
	        end
	    end
	end 
複製代碼

參考資料

Fix libstdc++.6在Xcode10編譯報錯問題post

Podfile中hook配置ui

相關文章
相關標籤/搜索