XCode14.3 (14E222b) iOS16.4 运行项
更新第三方库后运行项目奔溃,终端提示如下:
dyld[33631]: Library not loaded: @rpath/libswiftCoreGraphics.dylib
Referenced from: <44697CFA-F1C7-303D-9737-AE9FD4B30163> /private/var/containers/Bundle/Application/EC53A7C5-AD46-46E3-B17D-43E6958E6278/CloudDiskApp.app/CloudDiskApp
Reason: tried: '/usr/lib/system/introspection/libswiftCoreGraphics.dylib' (no such file, not in dyld cache), '/private/var/containers/Bundle/Application/EC53A7C5-AD46-46E3-B17D-43E6958E6278/CloudDiskApp.app/Frameworks/libswiftCoreGraphics.dylib' (no such file), '/private/var/containers/Bundle/Application/EC53A7C5-AD46-46E3-B17D-43E6958E6278/CloudDiskApp.app/Frameworks/libswiftCoreGraphics.dylib' (no such file), '/usr/local/lib/libswiftCoreGraphics.dylib' (no such file), '/usr/lib/libswiftCoreGraphics.dylib' (no such file, not in dyld cache)
方案一
libswiftCoreGraphics.tbd添加到 Link Binary With Libraries 可以解决这个问题 — 没解决
方案二
Podfile 里面加上hook
def update_xcconfig(xcconfig_path, key, value)
# read from xcconfig to build_settings dictionary
build_settings = Hash[*File.read(xcconfig_path).lines.map{|x| x.delete!("\n").split(/\s*=\s*/, 2)}.flatten]
# modify key
if build_settings.has_key?(key)
if build_settings[key].index(value) == nil
build_settings[key] << value
end
else
build_settings[key] = value
end
# write build_settings dictionary to xcconfig
File.open(xcconfig_path, "w+") {|file|
build_settings.each do |k, v|
file.puts "#{k} = #{v}"
end
}
end
# post_install hook
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
update_xcconfig(xcconfig_path, 'OTHER_LDFLAGS', ' -Wl,-weak-lswiftCoreGraphics')
end
end
end
重新 pod install,app能正常运行。再用otool查看库,加载路径也是正确的,问题解决
最近升级到xcode 14.3 版本的同学,会遇到这个一个问题
File not found: /Users/Downloads/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphoneos.a
解决方法(亲测有效)
在podfile文件中,增加以下内容
installer.generated_projects.each do |project|
project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
end
end
end
end