【iOS】ld: symbol(s) not found for architecture arm64 Xcode13使用Xcode14编译的库之问题

问题

-[AMapSmoothManager removeNoisePoint:] in libamap-ios.a(AMapSmoothManager.o)
ld: symbol(s) not found for architecture arm64

开始尝试各种配置,均无效,各种检查,代码也没问题,小伙伴编译打包没问题,基本判断是xcode某个编译配置项的缘故。


\"_objc_msgSend$integerValue\", referenced from:
-[GaodeLocManager setLocationOption:] in libamap-ios.a(GaodeLocManager.o)
\"_objc_msgSend$intensity\", referenced from:
-[AMapSmoothManager pathOptimize:] in libamap-ios.a(AMapSmoothManager.o)
-[AMapSmoothManager kalmanFilterPath:] in libamap-ios.a(AMapSmoothManager.o)
-[AMapSmoothManager kalmanFilterPoint:curLoc:] in libamap-ios.a(AMapSmoothManager.o)
\"_objc_msgSend$startLocation\", referenced from:
-[AmapCustomModule startLocationService:param:] in libamap-ios.a(AmapCustomModule.o)
-[GaodeLocModule startLocation] in libamap-ios.a(GaodeLocModule.o)
-[GaodeLocModule startLocationService:param:] in libamap-ios.a(GaodeLocModule.o)
\"_objc_msgSend$setApiKey:\", referenced from:
-[AmapCustomModule setApiKey:] in libamap-ios.a(AmapCustomModule.o)
-[GaodeLocModule setApiKey:] in libamap-ios.a(GaodeLocModule.o)
\"_objc_msgSend$pause:\", referenced from:
-[AmapCustomModule pauseByName:] in libamap-ios.a(AmapCustomModule.o)
-[AMapOfflineMapModule pauseByName:] in libamap-ios.a(AMapOfflineMapModule.o)
\"_objc_msgSend$noiseThreshhold\", referenced from:
-[AMapSmoothManager removeNoisePoint:] in libamap-ios.a(AMapSmoothManager.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

上述只是一部分,总体结果是xcode 14编译的库在xcode13上使用就会出现如上问题,而且是所有的函数都是如此。

原因

XCode14 的clang增加了一个新的特性关于msgSend的,而不向下兼容,所以在Xcode13上面报错。

处理

在framework工程的buildSetting里面,Apple Clang-Custom Compiler Flags 增加-fno-objc-msgsend-selector-stubs
添加位置如下:
在这里插入图片描述

添加后上述flags之后,Xcode13可以成功对项目进行编译,framework包有所增大。

但如果多人协作,有小伙伴的xcode是13,那么他们又需要去除这个flag,不然编译不过。

猜你喜欢

转载自blog.csdn.net/lanlangaogao/article/details/130173183