適配iOS9遇到的一些問題_Scheme白名單_ Bitcode及解決辦法

升級Xcode7 運行項目發現報錯以下:api

1.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列爲白名單,纔可正常檢查其餘應用是否安裝。ui

受此影響,當你的應用在iOS 9中須要使用微信SDK的相關能力(分享、收藏、支付、登陸等)時,須要在「Info.plist」裏增長以下代碼:atom

完成後需使用Xcode 7編譯。spa

若是你在模擬器上運行能夠能還會有如下報錯:code

-canOpenURL: failed for URL: 「weixin://app/wxdaae92a9cfe5d54c/」 - error: 「(null)」orm

這是由於模擬器上並無安裝微信,若是運行到真機上就不會有報錯了。ip

請注意:未升級到微信客戶端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>12345678910111213141516171819

qq登陸綁定,qq支付,qq分享 
微信支付,微信登陸綁定 
新浪登陸綁定 
支付寶支付,支付寶登陸綁定


2.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」。 

3.項目運行報錯以下

<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.123

出錯緣由:設置app的狀態欄樣式的使用使用了舊的方式,在info.plist裏面設置了View controller-based status bar appearance爲NO,默認爲YES,通常式iOS6的時候使用這種方式,iOS7,8也兼容,可是到了iOS9就報了警告。

[[UIApplication sharedApplication]setStatusBarStyle:UIStatusBarStyleLightContent];1

之前咱們經過上面代碼改變狀態了顏色,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]");123

解決辦法: 
修改方式將View controller-based status bar appearance設置爲YES,而後使用新的方式來實現狀態欄的樣式。

- (UIStatusBarStyle)preferredStatusBarStyle;- (UIViewController *)childViewControllerForStatusBarStyle;- (void)setNeedsStatusBarAppearanceUpdate123

4 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替換

framworks位置改變

其餘問題待更新…

相關文章
相關標籤/搜索