Undefined symbols for architecture armv7:
"_swiftoverride_class_getSuperclass(swift::TargetMetadata<swift::InProcess> const*)", referenced from:
swift::swift50override_conformsToProtocol(swift::TargetMetadata<swift::InProcess> const*,
swift::TargetProtocolDescriptor<swift::InProcess> const*, swift::TargetWitnessTable<swift::InProcess>
const* (*)(swift::TargetMetadata<swift::InProcess> const*,
swift::TargetProtocolDescriptor<swift::InProcess> const*)) in
libswiftCompatibility50.a(ProtocolConformance.cpp.o)
環(huán)境: Unity2018.4.36f1 And Xcode12+ 編譯
原因: Swift、OC 混編時(shí)需要配置Xcode Project, 使用xxxxx Bridging-Header.h
解決(Xcode配置):
1. Adding a new Swift file and a Brigde header:
-
File -> New -> File
-
Select Swift File
-
Confirm Create Bridging Header
2.Go to Build Settings and set Always Embed Swift Standard Libraries to YES
------------------------------------------------分割線------------------------------------------------
解決(Unity打包過(guò)程的話):
- 將任一空的.swift文件放至Assets/Plugins/iOS目錄下
- 打包后處理增加:
[PostProcessBuild(900)]
public static void OnPostprocessBuild(BuildTarget target, string path)
{
PBXProject project = new PBXProject();
string pbxProjectPath = PBXProject.GetPBXProjectPath(path);
pbxProject.SetBuildProperty(targetGuid,"ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "YES");
}