IOS:IOS9适配中出现的一些问题

来源:互联网 发布:非正式会谈oo的淘宝店 编辑:程序博客网 时间:2024/05/29 13:08

一、Xcode升级到7.0后,之前采用http明文请求的app,将不能正常进行网络交互

报错如下:

App Transport Security has blocked a cleartext HTTP (http://)resource load since it is insecure. 

解决方案:

1.配置成https(不过对于已经是明文的,肯定很麻烦了)

2.修改info.plist配置:

在info.plist 加入key

NSAppTransportSecurity

NSAllowsArbitraryLoads


如图所示:



二、蓝牙开发如何获取UUID的问题

在升级之前我们可以通过以下代码获得外围设备的UUID

- (NSString *)GetUUID :(CBPeripheral *)myPeriph  {      CFUUIDRef theUUID = [myPeriph UUID];      if (theUUID == 0x0) {                    return nil;      }else{          CFStringRef string = CFUUIDCreateString(NULL, theUUID);          return (__bridge_transfer NSString *)string ;      }        }  

更新之后很多人不适应了,其实更新之后更简单了,只需要很少的代码

peripheral.identifier.UUIDString 就OK了


三、编译出现xxx does not contain bitcode.You must rebuild it with bitcode enabled(Xcode setting ENABLE_BITCODE),obtain an update library from the vendor,or disable biecode for thia target,for architrcture arm64 的错误

Bitcode是什么?

找东西嘛,最先想到的当然是先看官方文档了。在App Distribution Guide – App Thinning (iOS, watchOS)一节中,找到了下面这样一个定义:

Bitcode is an intermediate representation of a compiled program. Apps you upload to iTunes Connect that contain bitcode will be compiled and linked on the App Store. Including bitcode will allow Apple to re-optimize your app binary in the future without the need to submit a new version of your app to the store.

说的是bitcode是被编译程序的一种中间形式的代码。包含bitcode配置的程序将会在App store上被编译和链接。bitcode允许苹果在后期重新优化我们程序的二进制文件,而不需要我们重新提交一个新的版本到App store上。

嗯,看着挺高级的啊。

继续看,在What’s New in Xcode-New Features in Xcode 7中,还有一段如下的描述

Bitcode. When you archive for submission to the 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 bit executables as necessary.

当我们提交程序到App store上时,Xcode会将程序编译为一个中间表现形式(bitcode)。然后App store会再将这个botcode编译为可执行的64位或32位程序。

再看看这两段描述都是放在App Thinning(App瘦身)一节中,可以看出其与包的优化有关了。喵大(@onevcat)在其博客开发者所需要知道的 iOS 9 SDK 新特性中也描述了iOS 9中苹果在App瘦身中所做的一些改进,大家可以转场到那去研读一下。

Bitcode配置

在上面的错误提示中,提到了如何处理我们遇到的问题:

ou 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

要么让第三方库支持,要么关闭target的bitcode选项。

在Xcode 7中,我们新建一个iOS程序时,bitcode选项默认是设置为YES的。我们可以在”Build Settings”->”Enable Bitcode”选项中看到这个设置。将其设为NO即可

不过,我们现在需要考虑的是三个平台:iOS,Mac OS,watchOS。

  • 对应iOS,bitcode是可选的。

  • 对于watchOS,bitcode是必须的。

  • Mac OS不支持bitcode。



因为依赖于第三方的库,而这个库不支持bitcode,暂时只能设置ENABLE_BITCODE为NO。

所以,如果我们的工程需要支持bitcode,则必要要求所有的引入的第三方库都支持bitcode。


四,系统一些库没有了


如图,这些在iOS9里都没有了:



其实只是欢乐后缀,将.dylib换成.tbd,然后就行了,

如图:




五、iOS9中被移除的API或者枚举




六、canOpenURL:和openURL:这两个API在iOS9中受到影响

当用xcode7打包时需要在plist文件中配置参数。(LSApplicationQueriesSchemes


0 0
原创粉丝点击