use_frameworks引起的Undefined symbols for architecture arm64

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

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值