zoukankan      html  css  js  c++  java
  • 项目适配iOS9遇到的一些问题及解决办法(更新两个小问题)

    1.网络请求报错。
    升级Xcode 7.0发现网络访问失败。
    输出错误信息

    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
     
    2.Scheme白名单问题(无法判断手机是否安装微信等)
    -canOpenURL: failed for URL: "weixin://app/wxdaae92a9cfe5d54c/" - error: "This app is not allowed to query for scheme weixin"

    搜索后得知近期苹果公司iOS 9系统策略更新,限制了http协议的访问,此外应用需要在“Info.plist”中将要使用的URL Schemes列为白名单,才可正常检查其他应用是否安装。

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

    解决办法:
    修改方式将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替换

  • 相关阅读:
    JavaScript对象 原型
    JavaScript数据类型 数据转换
    JavaScript字符串去除空格
    JavaScript实现StringBuffer
    JavaScript获取url参数
    JavaScript获取当前根目录
    React 和 Redux理解
    Umbraco 中获取一个media item的文件路径 file path
    Umbraco中获取UmbracoContext
    Umbraco中如何找到home node
  • 原文地址:https://www.cnblogs.com/edensyd/p/8878150.html
Copyright © 2011-2022 走看看