升级到Xcode16后项目编译报错问题
前言
将Xcode升级到Xcode16后发现一系列报错,特记录
问题一:HandJson
报错
Function type mismatch, declared as '@convention(thin) (UnsafePointer<UInt8>, Int, Optional<UnsafeRawPointer>, Optional<UnsafeRawPointer>) -> Optional<@thick any Any.Type>' but used as '@convention(thin) (UnsafePointer<UInt8>, UInt, Optional<UnsafeRawPointer>, Optional<UnsafeRawPointer>) -> Optional<@thick any Any.Type>'
解决方案:将HandyJSON/Source/Metadata.swift
里的UInt
改为Int
,修改如下
1
2
3
4
5
// 原始内容是UInt
// "function": { _getTypeByMangledNameInContext(cMangledTypeName, UInt(getMangledTypeNameSize(cMangledTypeName)), genericContext: self.contextDescriptorPointer, genericArguments: self.genericArgumentVector) }
// 改成Int
"function": { _getTypeByMangledNameInContext(cMangledTypeName, Int(getMangledTypeNameSize(cMangledTypeName)), genericContext: self.contextDescriptorPointer, genericArguments: self.genericArgumentVector) }
参考: https://github.com/alibaba/HandyJSON/issues/501 —-
问题二:boringssl-grpc
报错
BoringSSL-GRPC/src/ssl/ssl_transcript.cc unsupported option '-G' for target 'x86_64-apple-ios15.0-simulator'
解决方案:将Podfile
里的增加针对性的处理,修改如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == 'BoringSSL-GRPC'
target.source_build_phase.files.each do |file|
if file.settings && file.settings['COMPILER_FLAGS']
flags = file.settings['COMPILER_FLAGS'].split
flags.reject! { |flag| flag == '-GCC_WARN_INHIBIT_ALL_WARNINGS' }
file.settings['COMPILER_FLAGS'] = flags.join(' ')
end
end
end
end
end
参考: https://github.com/grpc/grpc/pull/36904 —-
问题三:WCDBSwift
里的Expression
与系统类名称冲突报错
Expression' is ambiguous for type lookup in this context
解决方案:将之前直接使用Expression
里的地方增加下库的前缀,修改如下
1
2
3
4
5
6
import Foundation
import WCDBSwift
// var whereStr: Expression?
var whereStr: WCDBSwift.Expression?
问题四:CocoaLumberjack
报错
Use of undeclared identifier 'LOG_ASYNC_ENABLED
解决方案一:修改源码
将之前直接使用CocoaLumberjack/Sources/CocoaLumberjack/include/CocoaLumberjack/DDLogMacros.h
里的地方修改内容
1
2
3
4
5
6
7
8
9
10
11
//#ifndef DD_LEGACY_MACROS
#define DD_LEGACY_MACROS 0
//#endif
//#ifndef LOG_LEVEL_DEF
#define LOG_LEVEL_DEF ddLogLevel
//#endif
//#ifndef LOG_ASYNC_ENABLED
#define LOG_ASYNC_ENABLED YES
//#endif
解决方案二:在xcode里配置预定义的宏
Xcode 16 pod init报错
参考: