M1编译
试试 mbp 2021 14的低版本,编译当前工作的项目,遇到不少问题,自己的项目还好,毕竟用到的第三方库不是很多。
问题
GoogleSignIn
之前项目用的是5.0.2应该是,6.0的版本改动比较大,这里先记录。
Google Sign-In quick migration guide
objc_msgSend 报警
Too many arguments to function call, expected 0, have 3
设置 Enable Strict Checking of objc_msgSend Calls 已经没用了,intel-based 机器可能还有用,apple silicon 机器没有用了。
id scheduleVc = ((id (*)(Class _Nullable, SEL _Nonnull,
SEL _Nonnull))(void *)objc_msgSend)(objc_getClass("ScheduleViewController"),
sel_registerName("alloc"), sel_registerName("init"));
1.变量scheduleVc是id类型,所以需要
强转(objc_msgSend函数)返回id类型的值
所以是 id (*)
2.函数中的三个参数:
a.是Class类型的
b.是SEL类型的
c.也是SEL类型的
所以是 (Class, SEL, SEL)
3. ( (id (*)(Class, SEL,SEL))(void *) objc_msgSend )
包管理器
carthage 编译问题比较多
cocoapods 库基本没啥问题,如果 pod install
报错,可尝试
sudo arch -x86_64 gem install ffi
Then
arch -x86_64 pod install
building for iOS Simulator, but linking in object file built for iOS
这个问题就是当前模拟器跑的,但是编译的第三方库确是打包的选项(any ios device arm64,armv7)导致的
当然还有一点,自己编译版本的时候,注意buildsetting里的mach(关键词)选项选择,static library
参考
Update Auth examples with GoogleSignIn 6.0.0 #1222
升级Xcode12后,objc_msgSend爆红
Too many arguments to function call, expected 0, have 2