iOS---XCode7 + IOS9 问题及解决方案

来源:互联网 发布:传奇数据溢出 编辑:程序博客网 时间:2024/05/18 00:58

bitcode

xcode7默认会开启bitcode 会导致第三方框架报错,下面是友盟的错误:libMobClickLibrary.a(MobClick.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 armv7

有两种方式可以解决 :1,更新库 2,build setting 中,搜索bitcode,并把 enable bitcode 设置为 NO

二,https (ATS)

如果使用ios9 sdk编译,,Foundation下默认所有http请求都被改为https请求  如下修改info.plist:

For example you can add a specific domain like:

<key>NSAppTransportSecurity</key><dict>  <key>NSExceptionDomains</key>  <dict>    <key>yourserver.com</key>    <dict>      <!--Include to allow subdomains-->      <key>NSIncludesSubdomains</key>      <true/>      <!--Include to allow HTTP requests-->      <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>      <true/>      <!--Include to specify minimum TLS version-->      <key>NSTemporaryExceptionMinimumTLSVersion</key>      <string>TLSv1.1</string>    </dict>  </dict></dict>

The lazy option is:

<key>NSAppTransportSecurity</key><dict>  <!--Include to allow all connections (DANGER)-->  <key>NSAllowsArbitraryLoads</key>      <true/></dict>

经过测试 所有通过NSURLConnection发送的请求都会被强制使用https

ASIHTTPRequest库不会受到影响 因为它底层是对CFNetwork的封装。

需要注意的是 以上解决方法目前尚不清楚苹果会不会拒绝上架,有条件的最好尽快改为https.


三,企业证书

使用企业证书打包的app 第一次安装时不会主动提示 信任/不信任 

 需要开发者到 设置->通用->描述文件->企业级应用 信任该证书


四:URL scheme

如果在应用中使用URL scheme调用其他应用必须在info.plist中将调用的scheme设置为信任名单 否则无法使用。

LSApplicationQueriesSchemes(Array) -> urlscheme1 urlscheme2....



  常见 URL Scheme

  微信:wechat  weixin

  QQ:mqq  mqqapi

  支付宝:alipay alipayshare

  新浪微博 :sinaweibo  sinaweibosso weibosdk weibosdk2.5


五 directory not found for option问题

问题原因:Xcode7将framworks位置改变了。

解决方法:

点击项目,选择 Targets->build setting

找到 Frameworks Search Path 或者 Library Search Paths

删除$(SDKROOT)/Developer/Library/Frameworks,

或者使用$(PLATFORM_DIR)/Developer/Library/Frameworks替换


六 项目运行报错如下

<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就报了警告。

解决办法: 删除 原先的设置代码

//设置状态栏的白色 [[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];



0 0