最近在做IOS测试时,碰到了几个环境引起的问题,主要是开发工具新版本及IOS系统新版本特性导致。现挑取两个比较典型的问题来分享给大家。
问题描述:开发提测时,创建的工程是在xcode6版本上创建的,而测试环境使用新的版本Xcode7,将开发提测工程导入后进行编译报如下错误:
ld: '/Users/netease/Downloads/nos-ios-demo-for-stabilitytest/NOSSDKDemo/libnos ios SDK.a(NOSBase64.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
具体如图显示:
问题分析: 通过编译过程所报的错误,很明显的可以看出是第三方库不包含bitcode问题,具体来看下官方对于bitcode解释
Bitcode is an intermediate representationof a compiled program. Apps you upload to iTunes Connect that contain bitcodewill be compiled and linked on the App Store. Including bitcode will allowApple to re-optimize your app binary in the future without the need to submit anew version of your app to the store.
Bitcode. When you archive for submission tothe App Store, Xcode will compile your app into an intermediate representation.The App Store will then compile the bitcode down into the 64 or 32 bitexecutables as necessary.
通过上面的解释我们可以看出,bitcode属于被编译程序的一种中间形态,类似于c中的.o文件。当新的app软件需要发布时,只需要提交对应的二进制文件,剩下的事情交给AppStore来完成,无需通过Appstore提交发布新的版本。
针对上面的问题,官方也给出了解决方法:
You must rebuild it with bitcode enabled(Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, ordisable bitcode for this target. for architecture arm64
由于Xcode7默认开启bitcode,且此选项对于非watch App来说是可选的,故最好的解决方法便是将bitcode开关关掉,具体如下图:
当前IOS发布了9.0以上版本,但IOS9有一个新的特性,苹果将原http协议改成了https协议,使用 TLS1.2 SSL加密请求数据,当拿原有的工程在9.0以上版本编译运行时会有以下错误: 使用普通HTTP请求报如下错误:
Application Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
来看下官方给出解释:
If you’re developing a new app, you should use HTTPS exclusively. If you have an existing app, you should use HTTPS as much as you can right now, and create a plan for migrating the rest of your app as soon as possible. In addition, your communication through higher-level APIs needs to be encrypted using TLS version 1.2 with forward secrecy. If you try to make a connection that doesn't follow this requirement, an error is thrown. If your app needs to make a request to an insecure domain, you have to specify this domain in your app's Info.plist file.
针对这个问题的快速解决方法便是修改plist文件,具体修改如下: 在Info.plist文件中添加如下配置:
<plist>
<dict>
....
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict>
</plist>
界面修改配置,如图:
本文来自网易实践者社区,经作者刘成授权发布。