背景
升级到 Xcode 26.4 之后,项目编译失败了,排查后发现是 AFNetworking 库导致的,原因是:
Xcode 26.4 :SDK 将 netinet6/in6.h 标为模块私有头,AFNetworking 4.x 直接 import 会报错;
修改
Podfile中,针对 Target处理即可。让 AI 处理即可。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| post_install do |installer| %w[ AFNetworking/AFNetworking/AFHTTPSessionManager.m AFNetworking/AFNetworking/AFNetworkReachabilityManager.m ].each do |rel| path = File.join(installer.sandbox.root, rel) next unless File.exist?(path) content = File.read(path) patched = content.sub(/^#import <netinet6\/in6\.h>\n/, '') next if patched == content begin FileUtils.chmod('u+w', path) File.write(path, patched) puts "[Podfile] Patched AFNetworking: removed netinet6/in6.h in #{File.basename(path)} (Xcode 26+ SDK)" rescue StandardError => e warn "[Podfile] AFNetworking patch failed for #{path} (#{e.class}: #{e.message}). Fix: chmod u+w \"#{path}\" then run pod install again." end end end
|