笔记: 报错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

相关文章
相关标签/搜索