项目适配iOS9遇到的一些问题及解决办法

iOS 9 适配系列教程

网络请求报错。

升级Xcode 7.0发现网络访问失败。
输出错误信息
#warning: 获取app配置信息失败: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.
原因:iOS9引入了新特性App Transport Security (ATS)。
详情:App Transport Security (ATS)
新特性要求App内访问的网络必须使用HTTPS协议。
但是现在公司的项目使用的是HTTP协议,使用私有加密方式保证数据安全。现在也不能马上改成HTTPS协议传输。
最终找到以下解决办法:
在Info.plist中添加NSAppTransportSecurity类型Dictionary。在NSAppTransportSecurity下添加NSAllowsArbitraryLoads类型Boolean,值设为YES


2F5721B6-2C74-4B59-84B3-7D77C541038F.png

Bitcode问题

原因:Xcode7 及以上版本会默认开启 bitcode 。
bitcode具体是什么就不解释了。
解决方法:
1.更新library使包含Bitcode,否则会出现以上的警告。
2.关闭Bitcode,简单粗暴。

Build Settings”->”Enable Bitcode”改成"NO"。


20150917113544983.jpg

项目运行报错如下

<Error>: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
<Error>: CGContextTranslateCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
<Error>: CGContextRestoreGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.

出错原因:设置app的状态栏样式的使用使用了旧的方式,在info.plist里面设置了View controller-based status bar appearance为NO,默认为YES,一般式iOS6的时候使用这种方式,iOS7,8也兼容,但是到了iOS9就报了警告。

如果想自己的app在各个机器都能够最高效率的运行,则需要将Build Active Architecture Only改为NO,Valid architectures选择对应的指令集:armv7 armv7s arm64。这个会为各个指令集编译对应的代码,因此最后的 ipa体积基本翻了3倍,Release版本必须NO。

解决办法:

删除 原先的设置代码
//设置状态栏的白色 [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

修改方式将View controller-based status bar appearance设置为YES,然后使用新的方式来实现状态栏的样式。


2F5721B6-2C74-4B59-84B3-7D77C541038F.png

在你的 自定义导航控制器里面 写上如下方法:
//设置状态栏的(亮色)白色
-(UIStatusBarStyle)preferredStatusBarStyle{ return UIStatusBarStyleLightContent;}
记住要clean 或者删除应用程序 重新运行

升级Xcode 7 之后 ios 9 模拟器 一启动程序 就直接报错

报错如下
***** Assertion failure in -[UIApplication _runWithMainScene:transitionContext:completion:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3505.16/UIApplication.m:3294**

原因:

新的SDK不允许在设置rootViewController之前做过于复杂的操作,导致在didFinishLaunchingWithOptions 结束后还没有设置rootViewController
Xcode7需要所有UIWindow必须立即先设置一个rootViewController

解决办法:
先设置个rootVIewController 之后重新赋值
UIWindow *window = [[UIWindowalloc] initWithFrame:[UIScreenmainScreen].bounds];window.rootViewController = [UIViewController new];



出现问题:

was built for newer iOS version (9.1) than being linked (8.0)


  1. Select your Project
  2. Select your Target
  3. Select "Build Settings" tab
  4. Scroll down to "Linking"
  5. Edit "Other Linker Flags" and add "-w" 解决

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值