Xcode 8 适配

一、Xcode 8 编译产生logs

问题描述:当你新建了个项目用xcode8直接编译发现打印了很多日志
如下图:

垃圾logs.png

解决办法: OS_ACTIVITY_MODE : disable

如下图:

具体配置位置.png

二、Xcode 8 自带文档注释失效

解决方法
打开终端,命令运行:

sudo /usr/libexec/xpccachectl
然后必须重启电脑后生效

注意:Xcode8内置了开启注释的功能,位置在这里,如下图

位置.png

三、隐私数据访问问题
问题出现

  • 在iOS 10中,当我打开相机时突然crash了,崩溃日志如下:

This app has crashed because it attempted to access privacy-sensitive data without a usage description.The app's Info.plist must contain an NSPhotoLibraryUsageDescription key with a string value explaining to the user how the app uses this data.

崩溃原因

  • 上面崩溃意思试图访问安全隐私数据,但是又没有相应的描述,你必须要包含在info.plist里包含一个键值NSPhotoLibraryUsageDescription对应的描述。
  • 其实上面是iOS10,苹果加强了对隐私数据的保护,要对隐私数据权限做一个适配iOS10调用相机,访问通讯录,访问相册等都要在info.plist中加入权限访问描述,不然之前你们的项目涉及到这些权限的地方就会直接crash掉。

解决办法

  • 只需要在info.plist添加NSContactsUsageDescription的key, value自己随意填写就可以,这里列举出对应的key(Source Code模式下):

    <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值
相册 NSPhotoLibraryUsageDescription
相机 NSCameraUsageDescription
麦克风 NSMicrophoneUsageDescription
位置 NSLocationUsageDescription
在使用期间访问位置 NSLocationWhenInUseUsageDescription
始终访问位置 NSLocationAlwaysUsageDescription
日历 NSCalendarsUsageDescription
提醒事项 NSRemindersUsageDescription
运动与健身 NSMotionUsageDescription
健康更新 NSHealthUpdateUsageDescription
健康分享 NSHealthShareUsageDescription
蓝牙 NSBluetoothPeripheralUsageDescription
媒体资料库 NSAppleMusicUsageDescription

4、Xcode8中添加SnapKit框架报错,编译失败

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容