使用cocoapods添加的库和不支持arm64的API真机调试问题

本文详细介绍了如何解决在使用CocoaPods构建的iOS应用中,由于第三方库默认支持64位编译导致的警告问题。通过调整Podfile配置,确保应用仅在所需架构下编译,从而避免与不支持64位的API(如微信、QQ的API)冲突。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

使用shareSDK来做第三方分享,模拟器运行良好,但是5s真机一直报错,好像里面的腾讯API是不支持64位

开发环境:

xcode:5.1.1

真机调试:iPhone5s 

使用cocoapods管理第三方库

报错:

加入shareSDK后,添加shareSDK相关代码,添加腾讯的API后,报错xxxxxxxxxnot find arm64。Architectures你删除arm64后cocoapods添加的某些库报错找不到什么符号等等。各种这是Architectures各种报错。最后实在不行只有翻墙去求助国外大神们,原来cocoapods和微信,QQ的API冲突了。


一番折腾还是不行,偶然间看到这个:
********************************************************************************************

解决cocoapods在64位iOS7系统下面的警告问题

现在编写iOS程序,引用到第三方包,运用cocoapods进行包管理已经成为了一个趋势了,但是最近运用cocoapods构建的应用却在64bit的iOS7系统中有警告的产生,具体的警告信息如下面所示:

Pods was rejected as an implicit dependency for ‘libPods.a’ because its architectures ‘i386’ didn’t contain all required architectures ‘x86_64’

具体的解决方案如下:在TAGETS =》 Build Settings 中重新设置值.

  1. Architectures: Standard architectures (armv7, armv7s)
  2. Base SDK: Latest iOS (iOS 7.0)
  3. Build Active Architecture Only: YES
  4. Supported Platforms: iOS
  5. Valid Architectures: arm64 armv7 armv7s

自己的工程和Pods工程都需要进行上述的设置.

注意: 在每次Podfile更新之后,还需要重新检查新的Pods工程中的设置是不是如上面设置的一致,如果不一致,则需要修改一致。

********************************************************************************************
这样做了依然不行,继续查找解决方案,又Google到两个相关问题:


其中有这样一段话讲明白了报错的原因:

Despite the lack of universal 64-bit support among 3rd-party pods, CocoaPods still includes the arm64 architecture (via ARCHS_STANDARD_INCLUDING_64_BIT) in its generated targets’ build settings. This can cause problems if your app’s dependencies don’t support arm64, or you only want to build for armv7 and armv7s for other reasons.

Fortunately, there’s a quick and easy automated fix. Just add the following to the bottom of your Podfile to revert the ARCHS build setting to ARCHS_STANDARD:

# Remove 64-bit build architecture from Pods targets
post_install do |installer|
  installer.project.targets.each do |target|
    target.build_configurations.each do |configuration|
      target.build_settings(configuration.name)['ARCHS'] = '$(ARCHS_STANDARD_32_BIT)'
    end
  end
end

To test, target the “iPhone Retina (4-inch 64-bit)” simulator and build. 

意思是说,cocoapods添加的库总是包含arm64编译,所以使用了cocoapods后默认采用arm64编译。这可能使得如果你的工程中添加的东西不支持arm64,就会和cocoapods冲突。


所以在podfile的结尾加上:下面代码

 
 

 
 

<div class="line" id="file-gistfile1-txt-LC19"><pre style="font-size: 14px; line-height: 22px; padding: 10px 20px;"><code><span style="color: rgb(172, 81, 250);">post_install <span style="font-weight: bold;">do</span> |installer|
  installer.project.targets.each <span style="font-weight: bold;">do</span> |target|
    target.build_configurations.each <span style="font-weight: bold;">do</span> |configuration|
      target.build_settings(configuration.name)['ARCHS'] = '$(ARCHS_STANDARD_32_BIT)'
    <span style="font-weight: bold;">end</span>
  <span style="font-weight: bold;">end</span>
<span style="font-weight: bold;">end</span></span></code>

 
 


改了pod file后,运行 'pod update'更新一下pod,重新生成新的. workspace。打开进入工程。问题解决了。

最后我的podfile


最后我的工程设置





cocoapod工程设置



总结:cocoapod添加的库被默认成包含arm64,进行64位编译。但是微信,QQ的API不支持64位编译,必须要用32位编译。没办法改变腾讯的API,幸好可以改podfile使其采用32位编译。如果遇到其他不支持arm64的API,又用了coocapods,都可以这样做


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值