1.網(wǎng)絡(luò)請(qǐng)求報(bào)錯(cuò)。
升級(jí)Xcode 7.0發(fā)現(xiàn)網(wǎng)絡(luò)訪問失敗。
輸出錯(cuò)誤信息:
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內(nèi)訪問的網(wǎng)絡(luò)必須使用HTTPS協(xié)議。
但是現(xiàn)在公司的項(xiàng)目使用的是HTTP協(xié)議,使用私有加密方式保證數(shù)據(jù)安全。現(xiàn)在也不能馬上改成HTTPS協(xié)議傳輸偿衰。
最終找到以下解決辦法:
在Info.plist中添加NSAppTransportSecurity類型Dictionary挂疆。
在NSAppTransportSecurity下添加NSAllowsArbitraryLoads類型Boolean,值設(shè)為YES
2.Scheme白名單問題(無法判斷手機(jī)是否安裝微信等)
-canOpenURL: failed for URL: "weixin://app/wxdaae92a9cfe5d54c/" - error: "This app is not allowed to query for scheme weixin"
搜索后得知,近期蘋果公司iOS 9系統(tǒng)策略更新,限制了http協(xié)議的訪問下翎,此外應(yīng)用需要在“Info.plist”中將要使用的URL Schemes列為白名單缤言,才可正常檢查其他應(yīng)用是否安裝。
受此影響视事,當(dāng)你的應(yīng)用在iOS 9中需要使用微信SDK的相關(guān)能力(分享胆萧、收藏、支付俐东、登錄等)時(shí)跌穗,需要在“Info.plist”里增加如下代碼:
注意:截圖來自微信開放平臺(tái),里面已經(jīng)包含第一個(gè)問題的解決
完成后需使用Xcode 7編譯虏辫。
如果你在模擬器上運(yùn)行可以能還會(huì)有以下報(bào)錯(cuò):
-canOpenURL: failed for URL: "weixin://app/wxdaae92a9cfe5d54c/" - error: "(null)"
這是因?yàn)槟M器上并沒有安裝微信蚌吸,如果運(yùn)行到真機(jī)上就不會(huì)有報(bào)錯(cuò)了。
請(qǐng)注意:未升級(jí)到微信客戶端6.2.5及以上版本的用戶砌庄,在iOS 9下使用到微信相關(guān)功能時(shí)羹唠,仍可能無法成功。
下面整理一些常用的白名單
3.Bitcode問題(通俗解釋:在線版安卓ART模式)
報(bào)錯(cuò)如下
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)
原因:Xcode7 及以上版本會(huì)默認(rèn)開啟 bitcode 娄昆。
bitcode具體是什么就不解釋了佩微。
解決方法:
1.更新library使包含Bitcode,否則會(huì)出現(xiàn)以上的警告萌焰。
2.關(guān)閉Bitcode哺眯,簡(jiǎn)單粗暴。
Build Settings”->”Enable Bitcode”改成"NO"扒俯。
4.項(xiàng)目運(yùn)行報(bào)錯(cuò)如下
:CGContextSaveGState: invalid context0x0. If you want to see the backtrace, please setCG_CONTEXT_SHOW_BACKTRACE environmental variable.
:CGContextTranslateCTM: invalid context0x0. If you want to see the backtrace, please setCG_CONTEXT_SHOW_BACKTRACE environmental variable.
:CGContextRestoreGState: invalid context0x0. If you want to see the backtrace, please setCG_CONTEXT_SHOW_BACKTRACE environmental variable.
出錯(cuò)原因:設(shè)置app的狀態(tài)欄樣式的使用使用了舊的方式奶卓,在info.plist里面設(shè)置了View controller-based status
bar appearance為NO,默認(rèn)為YES撼玄,一般式iOS6的時(shí)候使用這種方式夺姑,iOS7,8也兼容互纯,但是到了iOS9就報(bào)了警告瑟幕。
[[UIApplication sharedApplication]setStatusBarStyle:UIStatusBarStyleLightContent];
以前我們通過上面代碼改變狀態(tài)了顏色磕蒲,iOS9以后點(diǎn)進(jìn)去看api發(fā)現(xiàn)如下說明
// 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設(shè)置為YES留潦,然后使用新的方式來實(shí)現(xiàn)狀態(tài)欄的樣式。
- (UIStatusBarStyle)preferredStatusBarStyle;
- (UIViewController *)childViewControllerForStatusBarStyle;
- (void)setNeedsStatusBarAppearanceUpdate;
5. directory not found for option問題
警告如下:
ld: warning: directory not found for option ‘-F/Applications/Xcode7.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.0.sdk/Developer/Library/Frameworks‘
問題原因:Xcode7將framworks位置改變了辣往。
解決方法:
點(diǎn)擊項(xiàng)目兔院,選擇 Targets->xxxTests , 選擇build setting ,找到 Frameworks Search Path 或者 Library Search Paths 刪除$(SDKROOT)/Developer/Library/Frameworks站削,或者使用$(PLATFORM_DIR)/Developer/Library/Frameworks替換.