一.工程改动
1. 工程配置
直接使用Xcode8Beta打开工程后,你会发现你的provisonfile配置出了问题,这是由于在Xcode8中对工程配置有了一些小的改动。
在Xcode8工程配置的general选项卡中,使用更详细signing选项替换了原有的team选项。
选中:project -> target -> general
Xcode8之前team选项

Xcode8之前provisionfile选项

Xcode8之后变更为signing选项

signing选项展开

2. swift版本
假如你Xcode7的工程中使用了swift,那么你使用Xcode8一打开工程就会出现下面的选项,选择convert:

选convert后,会让你选择swift的版本。
如果你选择了3.0版本的swift选项,那等待convert结束后,一般依然有一部分需要你做手动适配。
假如你暂时不想花费时间做swift版本的适配,你可以选择swift2.3版本,convert并不会转换任何内容,你的项目也可以像以往在Xcode7中那样正常运行。
此时我们选择swift2.3:

选择swift版本后,选择你的工程target:

稍等片刻:

选择update,结束收工:

二、应用适配
1. 权限配置
随着人们对隐私保护的注重,似乎苹果的每一代产品都有相应的体现——更为严格的设备和数据访问权限控制。
在iOS10中,如果你的App想要访问用户的相机、相册、麦克风、通讯录等等权限,都需要进行相关的配置,不然会直接crash。
你需要在info.plist中添加你App需要的一些设备权限。
首先找到info,可以直接在这里添加键值对:

也可以找到info.plist文件,然后使用SourceCode方式打开:


一些常用的权限配置选项:
```
// 相机
<key>NSCameraUsageDescription</key>
<string>App需要您的同意,才能访问相册</string>
// 相册
<key>NSPhotoLibraryUsageDescription</key>
<string>App需要您的同意,才能访问相机</string>
// 麦克风:
<key>NSMicrophoneUsageDescription</key>
<string>App需要您的同意,才能访问麦克风</string>
// 通信录
<key>NSContactsUsageDescription</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>
```
2. 字体改变
iOS10的字体发生了变化,这导致一些文字在原有的宽高约束下可能会出现显示不完整或者留白的情况,需要逐一检查。
3. 推送通知
iOS10以后,想要正常收到推送通知,需要进行额外的配置:

参考
IOS 10 适配系列2 IOS10 适配汇总:ATS、隐私数据、UserNotifications、UICollectionView汇总
网友评论