1.网络请求报错。
升级Xcode 7.0
发现网络访问失败。
输出错误信息css
The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.api
缘由:iOS9引入了新特性App Transport Security (ATS)
。
详情:App Transport Security (ATS)
新特性要求App内访问的网络必须使用HTTPS
协议。
可是如今公司的项目使用的是HTTP
协议,使用私有加密方式保证数据安全。如今也不能立刻改为HTTPS协议传输。
最终找到如下解决办法:
在Info.plist中添加NSAppTransportSecurity
类型Dictionary
。
在NSAppTransportSecurity
下添加NSAllowsArbitraryLoads
类型Boolean
,值设为YES
安全
2.Scheme白名单问题(没法判断手机是否安装微信等)微信
-canOpenURL: failed for URL: "weixin://app/wxdaae92a9cfe5d54c/" - error: "This app is not allowed to query for scheme weixin"网络
搜索后得知app
近期苹果公司iOS 9系统策略更新,限制了http协议的访问,此外应用须要在“Info.plist”中将要使用的URL Schemes列为白名单,才可正常检查其余应用是否安装。微信支付
受此影响,当你的应用在iOS 9中须要使用微信SDK的相关能力(分享、收藏、支付、登陆等)时,须要在“Info.plist”里增长以下代码:ui
注意:截图来自微信开放平台,里面已经包含第一个问题的解决atom
完成后需使用Xcode 7编译。加密
若是你在模拟器上运行能够能还会有如下报错:
-canOpenURL: failed for URL: "weixin://app/wxdaae92a9cfe5d54c/" - error: "(null)"
这是由于模拟器上并无安装微信,若是运行到真机上就不会有报错了。
请注意:未升级到微信客户端6.2.5及以上版本的用户,在iOS 9下使用到微信相关功能时,仍可能没法成功。
下面整理一些经常使用的白名单
<key>LSApplicationQueriesSchemes</key> <array> <string>mqqOpensdkSSoLogin</string> <string>mqzone</string> <string>sinaweibo</string> <string>alipayauth</string> <string>alipay</string> <string>safepay</string> <string>mqq</string> <string>mqqapi</string> <string>mqqopensdkapiV3</string> <string>mqqopensdkapiV2</string> <string>mqqapiwallet</string> <string>mqqwpa</string> <string>mqqbrowser</string> <string>wtloginmqq2</string> <string>weixin</string> <string>wechat</string> </array>
qq登陆绑定,qq支付,qq分享
微信支付,微信登陆绑定
新浪登陆绑定
支付宝支付,支付宝登陆绑定
3.Bitcode问题(通俗解释:在线版安卓ART模式)
报错以下
ld: warning: directory not found for option '-F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/Developer/Library/Frameworks'
ld: -bundle and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together
clang: error: linker command failed with exit code 1 (use -v to see invocation)![]()
Bitcode报错
缘由:Xcode7 及以上版本会默认开启 bitcode 。
bitcode具体是什么就不解释了。
解决方法:
1.更新library使包含Bitcode,不然会出现以上的警告。
2.关闭Bitcode,简单粗暴。
Build Settings”->”Enable Bitcode”改为"NO"。
4.项目运行报错以下
<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];
之前咱们经过上面代码改变状态了颜色,iOS9之后点进去看api发现以下说明
// Setting the statusBarStyle does nothing if your application is using the default UIViewController-based status bar system. @property(readwrite, nonatomic) UIStatusBarStyle statusBarStyle NS_DEPRECATED_IOS(2_0, 9_0, "Use -[UIViewController preferredStatusBarStyle]"); - (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle animated:(BOOL)animated NS_DEPRECATED_IOS(2_0, 9_0, "Use -[UIViewController preferredStatusBarStyle]");
解决办法:
修改方式将View controller-based status bar appearance设置为YES,而后使用新的方式来实现状态栏的样式。
- (UIStatusBarStyle)preferredStatusBarStyle; - (UIViewController *)childViewControllerForStatusBarStyle; - (void)setNeedsStatusBarAppearanceUpdate
2015.09.21更新
5 directory not found for option问题
警告以下:
ld: warning: directory not found for option '-F/Applications/Xcode 7.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.0.sdk/Developer/Library/Frameworks'
问题缘由:Xcode7将framworks位置改变了。
解决方法:
点击项目,选择 Targets->xxxTests
选择build setting ,找到 Frameworks Search Path 或者 Library Search Paths
删除$(SDKROOT)/Developer/Library/Frameworks,
或者使用$(PLATFORM_DIR)/Developer/Library/Frameworks替换