代码改变世界

iOS,Xcod7/8,iOS使用修改点

2016-09-19 14:30  帅不过三秒  阅读(567)  评论(0编辑  收藏  举报

1.Xcod7使用修改点

2.Xcode8使用修改点

Xcod7使用修改点

1.xcode7 新建的项目,Foundation下默认所有http请求都被改为https请求.

HTTP+SSL/TLS+TCP = HTTPS

也就是说,服务需要提供https(TLS 1.2)的接口;

如果服务不改变,则客户端info.plist的根<dict>需加下面的键值;

简单信任所有http服务器

<key>NSAppTransportSecurity</key>

<dict>

    <!--Connect to anything (this is probably BAD)-->

    <key>NSAllowsArbitraryLoads</key>

    <true/>

</dict>

或者严谨的

<key>NSAppTransportSecurity</key>

<dict>

  <key>NSExceptionDomains</key>

  <dict>

    <key>yourserver.com</key>

    <dict>

      <!--Include to allow subdomains-->

      <key>NSIncludesSubdomains</key>

      <true/>

      <!--Include to allow insecure HTTP requests-->

      <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>

      <true/>

      <!--Include to specify minimum TLS version-->

      <key>NSTemporaryExceptionMinimumTLSVersion</key>

      <string>TLSv1.1</string>

    </dict>

  </dict>

</dict>

 

2.xcode7 默认开启,bitcode(iwatch需要),则会导致部分第三方框架报错(比如友盟的错误)

youmeng/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

这是要么更新库,要么可以在 build setting 中,搜索bitcode,并吧 enable bitcode 设置为 NO

 

3.iOS9安装企业证书打包的app

企业证书打包的app,安装到手机里面后第一次打开app。不会像以前提示,信任还是不信任该证书;

这是个时候需要iOS9 设置-》通用-》描述文件-》企业级应用 中信任对应的企业开发者。

 

4.iOS9 URL Schemes 

除了要在项目info URL Types中设置URL Schemes,还需要在info.plist里面增加可信任的调用app,否则回报如下错误

-canOpenURL: failed for URL: "weixin://app/wx9c8771d3c07dfd30/" - error: "This app is not allowed to query for scheme weixin"

-canOpenURL: failed for URL: "wtloginmqq2://qzapp" - error: "This app is not allowed to query for scheme wtloginmqq2"

info.plist加入

<key>LSApplicationQueriesSchemes</key>

<array>

<string>urlscheme</string>

<string>urlscheme2</string>

<string>urlscheme3</string>

<string>urlscheme4</string>

</array>

5.iPad适配Slide Over 和 Split View分屏应用最好把纯代码改为stroyboard

6.部分库文件后缀变更

dylib后缀的变成tbd

例如:变成

七、Xcode7打兼容32位和64位手机机型包

       将build active architecture only改成no,就是32位和64位都包含,会根据不同手机自动选择使用32还是64.

 

     

Xcode8使用修改点

1.真机调试修改

将下图所示地方勾选上

 

2.应用权限配置

在Info.plist中增加如下代码

<!-- 相册 -->

<key>NSPhotoLibraryUsageDescription</key>

<string>App需要您的同意,才能访问相册</string>

<!-- 相机 -->

<key>NSCameraUsageDescription</key>

<string>App需要您的同意,才能访问相机</string>

<!-- 麦克风 -->

<key>NSMicrophoneUsageDescription</key>

<string>App需要您的同意,才能访问麦克风</string>

<!-- 位置 -->

<key>NSLocationUsageDescription</key>

<string>App需要您的同意,才能访问位置</string>

<!-- 在使用期间访问位置 -->

<key>NSLocationWhenInUseUsageDescription</key>

<string>App需要您的同意,才能在使用期间访问位置</string>

<!-- 始终访问位置 -->

<key>NSLocationAlwaysUsageDescription</key>

<string>App需要您的同意,才能始终访问位置</string>

<!-- 日历 -->

<key>NSCalendarsUsageDescription</key>

<string>App需要您的同意,才能访问日历</string>

<!-- 提醒事项 -->

<key>NSRemindersUsageDescription</key>

<string>App需要您的同意,才能访问提醒事项</string>

<!-- 运动与健身 -->

<key>NSMotionUsageDescription</key> <string>App需要您的同意,才能访问运动与健身</string>

<!-- 健康更新 -->

<key>NSHealthUpdateUsageDescription</key>

<string>App需要您的同意,才能访问健康更新 </string>

<!-- 健康分享 -->

<key>NSHealthShareUsageDescription</key>

<string>App需要您的同意,才能访问健康分享</string>

<!-- 蓝牙 -->

<key>NSBluetoothPeripheralUsageDescription</key>

<string>App需要您的同意,才能访问蓝牙</string>

<!-- 媒体资料库 -->

<key>NSAppleMusicUsageDescription</key>

<string>App需要您的同意,才能访问媒体资料库</string>

<!-- 通讯录 -->

<key>NSContactsUsageDescription</key>

<string>App需要您的同意,才能访问通讯录</string>

 

如果不起作用,可以请求后台权限,类似于这样:

<key>UIBackgroundModes</key>

<array>

<!-- 在这里写上你在后台模式下要使用权限对应的key -->

<string>location</string>

...

</array>

 

iOS10下数据共享,下面配置后,可以到iTunes应用文件共享里面查看Documents文件夹下的文件