您的位置:首页 > Web前端 > JavaScript

xcode7升级后遇到问题

2015-09-18 15:56 573 查看
xcode7升级后遇到问题,遇到了几个问题:

1、苹果建议使用https协议,导致原本的http协议无法访问,

2、bitcode默认开启导致一些不支持bitcode的第三方插件报错。

3、JSONKit第三类库不能适配IOS9导致应用闪退问题。

1、在iOS9 中,苹果将原http协议改成了https协议,使用 TLS1.2 SSL加密请求数据。也就是说原本如果我们使用http协议与我们服务器连接的话,会导致连接不上。提示连接失败。

https://developer.apple.com/library/prerelease/ios/releasenotes/General/WhatsNewIniOS/Articles/iOS9.html#//apple_ref/doc/uid/TP40016198-DontLinkElementID_13

App Transport Security

App Transport Security (ATS) enforces best practices in the secure connections between an app and its back end. ATS prevents accidental disclosure, provides secure default behavior, and is easy to adopt; it is also on by default in iOS 9 and OS X v10.11. You
should adopt ATS as soon as possible, regardless of whether you’re creating a new app or updating an existing one.

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.

解决办法:

在info.plist中添加
<key>NSAppTransportSecurity</key><dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/></dict>

打开工程,在找到Supporting Files文件夹,找到info.plist文件。一般是项目名称+info.plist。选择之后右键,选择show
in finder.在文件夹打开

找到文件之后,右键,选择在文本编辑。在最后</dict></plist>之前添加上面的代码,保存就可以。我们就是设置访问为我们特定的域。可能不是安全的。

2、使用友盟或shareSDK等第三方插件,使用真机调试,报bitcode错误。

bitcode是什么呢?在官方文档可以找到答案:


App Thinning

App thinning helps you develop apps for diverse platforms and deliver an optimized installation automatically. App thinning includes the following elements:

Slicing. Artwork incorporated into the Asset Catalog and tagged for a platform allows the App Store to deliver only what is needed for installation.

On-Demand Resources. Host additional content for your app in the iTunes App Store repository, allowing it to fetch resources as needed using asynchronous download and installation. To learn more about this technology, see On-Demand
Resources Guide.

Bitcode. Archive your app for submission to the App Store in an intermediate representation, which is compiled into 64- or 32-bit executables for the target devices when delivered.

To learn more about app thinning, see App
Thinning (iOS, watchOS).

大概的意思是bitcode是被编译程序的一种中间形式的代码。包含bitcode配置的程序将会在App store上被编译和链接。bitcode允许苹果在后期重新优化我们程序的二进制文件,而不需要我们重新提交一个新的版本到App store上。当我们提交程序到App store上时,Xcode会将程序编译为一个中间表现形式(bitcode)。然后App store会再将这个botcode编译为可执行的64位或32位程序。

在Xcode 7中,我们新建或者打开一个iOS程序时,bitcode选项默认是设置为YES的。如果我们引用的第三方的库不支持bitcode,我们可以在”Build Settings”->”Enable
Bitcode”选项中看到这个设置。设置ENABLE_BITCODE为NO。

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

对应iOS,bitcode是可选的。

对于watchOS,bitcode是必须的。

Mac OS不支持bitcode。

3、JSONKit闪退问题

JSON数据传输是应用常用的。但是JSONKit第三方还不能适配ios9,会导致闪退问题。可能不久就可以了。我们需要采用系统的JSON库。所以我们需要切换回系统JSON库。可以采用一些已经做好适配的JSON库。比如:YRJSONAdapter:https://gitHub.com/YueRuo/YRJSONAdapter

只要使用YRJSONAdapter替换所有的JSONkit

未完待续-------
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息