报错:
ld: warning: directory not found for option '-L /Users/mobilefish/Library/Developer/Xcode/DerivedData/Unity-iPhone-fwocxxrsxgizoydxrjlbwrfeilsb/Build/Products/Release-iphoneos/GoogleToolboxForMac /Users/mobilefish/Library/Developer/Xcode/DerivedData/Unity-iPhone-fwocxxrsxgizoydxrjlbwrfeilsb/Build/Products/Release-iphoneos/Protobuf /Users/mobilefish/Library/Developer/Xcode/DerivedData/Unity-iPhone-fwocxxrsxgizoydxrjlbwrfeilsb/Build/Products/Release-iphoneos/nanopb'
ld: warning: arm64 function not 4-byte aligned: ltmp0 from /Volumes/Untitled/OrientalSkyProjects/MC_XCodeProject/MC_XCodeProject/Libraries/libiPhone-lib.a(unwind_test_arm64.o)
ld: warning: arm64 function not 4-byte aligned: _unwind_tester from /Volumes/Untitled/OrientalSkyProjects/MC_XCodeProject/MC_XCodeProject/Libraries/libiPhone-lib.a(unwind_test_arm64.o)
Undefined symbols for architecture arm64:
"_OBJC_CLASS_$_FIRDynamicLinks", referenced from:
objc-class-ref in libApp.a(invites_receiver_internal_ios_75ab5b9435a7c52eb095887705fc1133.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
疑问:
这句话的意思是:在 libApp.a 中的 invites_receiver_internal_ios 中调用了 “OBJC_CLASS$_FIRDynamicLinks”,但是找不到这个 FIRDynamicLinks 的定义。也就是说,可能是缺少一些 framework 之类的。
找到类似的一个错误解决:
http://kojirohashida.hatenablog.com/entry/2017/01/18/124806
博主给出的错误解说也是 Firebase 的 podfile 上给出的 framework 不够。找出需要的库,添加到 podfile 里,再 pod install 一下,添加至工程中即可。
在 Firebase 文档搜索发现 FIRDynamicLinks 在 FirebaseDynamicLinks.ramework 里,所以在 Podfile 中添加:
pod 'Firebase/DynamicLinks'
在 pod update 之后,注意要添加到 Xcode 工程中去。(#TODO:PlayServerResolver 这个插件,在 Unity 编译出 Xcode 工程的时候,是什么时候跑了 Cocoapods 的?以及对 Xcode 的 project 做了哪些工作?)
其他:
这个问题困扰了我挺长时间,最开始直接无脑 Google 尝试各种奇怪的方法并不能解决,然后老大跑过来问我这句错误报错到底是什么意思,这个 .a 文件到底里面是什么结构,是 .dll 还是 .lib 还是 .so 还是什么鬼,到底是 libApp.a 自己缺东西还是它 link 到其他什么缺东西。在搞清楚到底是什么问题之后,思路就很清晰了。总的来说,我可能需要补一补编译原理了。。。
.a
files are static library files. They "contain" one or more.o
files, i.e. compiled code. To use them, you (often) need the header (.h
) files that correspond to the compiled code, but you do not need the source code (.c
,.m
) itself. The.a
files are produced with thear
utility, and the linker (ld
) that is (usually) invoked by your compiler knows their format and how to extract the relevant pieces of code from the archive and into your executable.
(https://stackoverflow.com/questions/8224035/what-is-a-a-as-libcrypto-a-file)