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

使用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到两个相关问题:

(国外网站,国内可能无法访问) http://cameronspickert.com/2014/01/20/remove-the-arm64-architecture-from-cocoapods-targets

https://gist.github.com/tigerbears/9480433

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

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的结尾加上:下面代码



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
 
   


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

最后我的podfile
使用cocoapods添加的库和不支持arm64的API真机调试问题_第1张图片

最后我的工程设置
使用cocoapods添加的库和不支持arm64的API真机调试问题_第2张图片




cocoapod工程设置


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


你可能感兴趣的:(iOS,开发)