问题集
编译错误
1. SQLite系统类和项目库类命名冲突(fileprivate typealias 解决)
2. Xcode14.3 以后,不能编译ARC,下载和copy到 Xcode 目录下
# 指定目标目录
TARGET_DIR="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc"
# 检查目标目录是否存在,如果不存在则创建
if [ ! -d "$TARGET_DIR" ]; then
mkdir -p "$TARGET_DIR"
echo "创建目录 $TARGET_DIR"
fi
# 复制当前目录下的所有 .a 文件到目标目录
find . -maxdepth 1 -type f -name "*.a" -exec cp {} "$TARGET_DIR" ;
echo "所有 .a 文件已成功复制到 $TARGET_DIR"
3. iAd.framework 不能使用 (暂时先放弃吧……)
4. 移除ATAuth文件架引用,编译flag (废弃的空目录,影响编译,也是厉害……)
5. 设置ENABLE_DEBUG_DYLIB为false,关闭动态库调试
HandyJson问题
● 原理:
HandyJSON 利用了 Swift 的 Mirror 类型进行反射。反射可以在运行时获取对象的类型信息和属性,这使得 HandyJSON 能够自动将 JSON 字典中的值映射到 Swift 对象的属性上。
优势:
HandyJSON 通过减少中间对象的创建和直接内存操作来优化性能。它避免了大量的临时对象分配,从而提高了解析速度
● 问题
Xcode16 升级,支持Codable,不再支持Mirror使用的 打包
打包问题
Call parameter type does not match function signature!
ptr null
i64 %16 = call swiftcc i64 @swift_getTypeByMangledNameInContext(ptr %15, i64 %10, ptr null, ptr null) #22, !dbg !2584
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
Rename failed: /Users/xxx/Library/Developer/Xcode/DerivedData/han-ezydnutpxxdvdngthbspmtadcgpp/Build/Intermediates.noindex/ArchiveIntermediates/han/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/HandyJSON.build/Objects-normal/arm64/ContextDescriptorType-9285e76d.o.tmp -> /Users/xxx/Library/Developer/Xcode/DerivedData/han-ezydnutpxxdvdngthbspmtadcgpp/Build/Intermediates.noindex/ArchiveIntermediates/han/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/HandyJSON.build/Objects-normal/arm64/ContextDescriptorType.o: No such file or directory
Rename failed: /Users/xxx/Library/Developer/Xcode/DerivedData/han-ezydnutpxxdvdngthbspmtadcgpp/Build/Intermediates.noindex/ArchiveIntermediates/han/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/HandyJSON.build/Objects-normal/arm64/FieldDescriptor-b6c499c4.o.tmp -> /Users/xxx/Library/Developer/Xcode/DerivedData/han-ezydnutpxxdvdngthbspmtadcgpp/Build/Intermediates.noindex/ArchiveIntermediates/han/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/HandyJSON.build/Objects-normal/arm64/FieldDescriptor.o: No such file or directory
参考:Xcode15.3打包报错 · Issue #488 · alibaba/HandyJSON · GitHub
更新了HandyJson的补丁版库 Pods 又可以了
Comparing alibaba:master...Miles-Matheson:master · alibaba/HandyJSON · GitHub
有新的方案(尚未验证)podfile添加代码
# https://github.com/alibaba/HandyJSON/issues/499
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
# 设置 HandyJSON 的编译模式为 Incremental增量编译
if target.name == 'HandyJSON'
config.build_settings['SWIFT_COMPILATION_MODE'] = 'incremental'
end
end
end
● 方案
更佳方案(优先级递减)
关于json data序列化成对象的方案对比
不同角度看问题 - 从 Codable 到 Swift 元编程 | OneV's Den
○ Sourcery代码生成
○ Codable
○ Mirror (Xcode16 不在支持 Mirror运行时 打包,仅支持调试模式了)
最终方案
联动的测试用例,可能是灾难级的增加
1. 旧的逻辑扔使用Xcode15 稳定版打包
2. 新的功能,使用Xcode 16 + HandyJson的补丁版库 打包提测
3. 逐步调整,升级到遗弃HandyJSON到 Codable
测试新Xcode 打包到TestFlight 测试账号,低版本iOS 会崩溃吗?
1. 邀请内部测试账号,必须添加用户
2. testFlight下载安装app
iOS10 缺少dylb动态库,启动崩溃
● 问题正解
方案一:移除IQKeyboardManagerSwift pod,
方案二:设置other linker flags为-Wl,-weak-lswiftCoreGraphics
stackoverflow.com/questions/7…
选用方案二
● 但是,IQKeyboardManagerSwift 更新没有解决问题
尝试运行IQKeyboardManagerSwift 的demo iOS 10
● 编写podfile post_install 钩子执行脚本
1. 替换pod库中的-Wl,-weak-lswiftCoreGraphics
# 替换链接器标志
other_ldflags = '$(inherited) -Wl,-weak-lswiftCoreGraphics -framework "CoreGraphics" -framework "Foundation" -framework "QuartzCore" -framework "UIKit"'
2. 由于依赖关系已经修改,所有要主动修改xcconfig
# 由于依赖关系已经修改,所有要主动修改xcconfig
# 获取 Pods 目录路径
pods_root = installer.sandbox.root
# 查找所有的 .xcconfig 文件
Dir.glob(File.join(pods_root, '**', '*.xcconfig')).each do |xcconfig_path|
# 读取文件内容
xcconfig_content = File.read(xcconfig_path)
# 替换链接器标志
updated_content = xcconfig_content.gsub('-l"swiftCoreGraphics"', '-Wl,-weak-lswiftCoreGraphics')
# 写回修改后的内容
File.open(xcconfig_path, 'w') { |file| file.write(updated_content) }
end
感受
有了一次不想再有第二次了,有时间多研究研究,Apple Intelligence不香吗?