use

use,第1张

OC工程可以使用也可以不使用use_frameworks!,而含有swift的工程必须使用use_frameworks!。
若原来用oc创建的私有库含有extern导入的全局变量或常量会造成该错误。

Undefined symbols for architecture arm64:
  "_sCommonUnitBoldFontHeight", referenced from:
      -[BITUCNNaviView exitBtn] in BITUCNNaviView.o
      -[BITUCNNaviView confirmBtn] in BITUCNNaviView.o
      -[BITUCNNaviView adjustAutoLayout] in BITUCNNaviView.o
  "_sCommonUnitEdgeDistance", referenced from:
      -[BITUCNNaviView adjustAutoLayout] in BITUCNNaviView.o
  "_sCommonUnitFontHeight", referenced from:
      -[BITCMSelectTableViewCell loadData:hideLine:] in BITCMSelectTableViewCell.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

出问题的代码:

//常用字体高度
extern const NSInteger sCommonUnitFontHeight;
//常用字体高度
const NSInteger sCommonUnitFontHeight = 13;

最笨的解决方案,直接把私有库拖入工程,然后修改头文件的包含方式。

正确的库是:

探索通过建立一个公用的私有库,它依赖其它私有库,结果问题仍旧存在。
正探索其它通用导入方式的可行性。利用test导入工程,然后手动增加私有库。

target 'DYLiangXinApp' do
  # Comment the next line if you don't want to use dynamic frameworks


  # Pods for DYLiangXinApp
  use_frameworks!
  
  # 数据
    pod 'AFNetworking'
    pod 'MJExtension'


end

target 'DYLiangXinAppTests' do
  # Comment the next line if you don't want to use dynamic frameworks


  # Pods for DYLiangXinApp
  
  pod 'DYVideoPlayer'

end

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/993568.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存