在适配 iOS 18 + xcode 16时遇到的问题,记录一下。
1. 使用xcode 16 + iOS 18 运行App时遇到,APP 的icon 出现空白现象。
原先APP icon 设置方案。
暂时解决方案:
2、 Xcode 16 不支持 framework 开启 bitcode,移除framework 中的bitcode
解决方法:
(1) 在Xcode中禁用Bitcode:
1、打开你的Xcode项目。
2、选择“Build Settings”标签。
3、搜索“Enable Bitcode”并将其设置为“No”。
4、清理并重建你的项目(使用快捷键Shift + Command + K进行清理,然后使用Command + B进行重建)。
(2) 手动剥离Bitcode:
如果禁用Bitcode不起作用,你可以尝试手动从framework中剥离Bitcode。
打开终端。
运行命令:xcrun bitcode_strip -r <path_to_your_Framework> -o <output_path>
其中<path_to_your_Framework>是你的framework的实际路径。
(3) 使用命令行工具
你也可以使用命令行工具xcrun bitcode_strip来手动去除framework的Bitcode。
命令格式如下:
xcrun bitcode_strip -r ${framework_path} -o ${framework_path}
其中${framework_path}是framework的二进制文件路径。
(4) 更新或替换第三方库
如果问题是由第三方库引起的,联系库的供应商获取更新版本,或者寻找不包含Bitcode的替代库。
(5) 使用CocoaPods的post_install钩子
如果你使用CocoaPods管理依赖,可以在Podfile中添加一个post_install钩子来自动剥离所有frameworks中的Bitcode。
post_install do |installer|
bitcode_strip_path = `xcrun --find bitcode_strip`.chop!
def strip_bitcode_from_framework(bitcode_strip_path, framework_relative_path)
framework_path = File.join(Dir.pwd, framework_relative_path)
command = "#{bitcode_strip_path} #{framework_path} -r -o #{framework_path}"
puts "Stripping bitcode: #{command}"
system(command)
end
# 列出需要剥离Bitcode的frameworks路径
framework_paths = [
"Pods/LibraryA/LibraryA/dynamic/LibraryA.xcframework/ios-arm64_armv7/LibraryA.framework/LibraryA",
"Pods/LibraryB/LibraryB.xcframework/ios-arm64_armv7/LibraryB.framework/LibraryB"
]
framework_paths.each do |framework_relative_path|
strip_bitcode_from_framework(bitcode_strip_path, framework_relative_path)
end
end
这段代码会在pod安装后自动运行,剥离指定frameworks中的Bitcode。
3 、 Xcode 16 Termination Description: DYLD, Library not loaded: /usr/lib/swift/libswiftCoreGraphics.dylib **
解决方法:
#关闭引用第三方库的bitcode
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
# config.build_settings['ENABLE_BITCODE'] = 'NO'
# config.build_settings['CODE_SIGN_IDENTITY'] = '' #置空 解决报错
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
xcconfig_path = config.base_configuration_reference.real_path
update_xcconfig(xcconfig_path, 'OTHER_LDFLAGS', ' -Wl,-weak-lswiftCoreGraphics')
end
end
end
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
————————————————
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/tongwei117/article/details/142218571