xcode8的一些变动

一、证书管理

用Xcode8打开工程后,比较明显的就是下图了,这个是苹果的新特性,可以帮助我们自动管理证书。建议大家勾选这个Automatically manage signing(Ps.但是在beat2版本我用的时候,完全不可以,GM版本竟然神奇的又好了。)

id="iframe_0.7217733417637646" src="https://www.cnblogs.com/show-blocking-image.aspx?url=http%3A%2F%2Fstatic.zybuluo.com%2FcoderXu%2F1567ki636zl9z3t7rhs7zsmw%2FQQ20160913-8.png&maxWidth=910&origin=http://www.cnblogs.com&iframeId=iframe_0.7217733417637646" frameborder="0" scrolling="no" height="529" style="margin: 0px; padding: 0px; border-style: none; width: 910px;">
QQ20160913-8.png-96.9kB

下面我来说说可能会出现的问题:

1.Xcode未设置开发者账号情况下的截图

id="iframe_0.013762704329565167" src="https://www.cnblogs.com/show-blocking-image.aspx?url=http%3A%2F%2Fstatic.zybuluo.com%2FcoderXu%2Fs9024p7gzbcmv7q532fmjigj%2FQQ20160913-0.png&maxWidth=910&origin=http://www.cnblogs.com&iframeId=iframe_0.013762704329565167" frameborder="0" scrolling="no" height="297" style="margin: 0px; padding: 0px; border-style: none; width: 910px;">
QQ20160913-0.png-38.5kB


解决办法是:大家在Xcode的偏好设置中,添加苹果账号,即可。

2.设备机器未添加进开发者的Device情况下的截图

id="iframe_0.8423797173891217" src="https://www.cnblogs.com/show-blocking-image.aspx?url=http%3A%2F%2Fstatic.zybuluo.com%2FcoderXu%2Fwbv8uoou5mm9bhy1pehi2byj%2FQQ20160913-2.png&maxWidth=910&origin=http://www.cnblogs.com&iframeId=iframe_0.8423797173891217" frameborder="0" scrolling="no" height="272" style="margin: 0px; padding: 0px; border-style: none; width: 910px;">
QQ20160913-2.png-33.7kB


解决办法是:大家在官网将设备添加进开发机后,陪下描述文件重新下个描述文件即可。

3.正常情况:Xcode配置登录开发者账号后的图片,耐心等待即可。

id="iframe_0.9293399497400969" src="https://www.cnblogs.com/show-blocking-image.aspx?url=http%3A%2F%2Fstatic.zybuluo.com%2FcoderXu%2F89bctmw1kt24j77yso37gthc%2FQQ20160913-1.png&maxWidth=910&origin=http://www.cnblogs.com&iframeId=iframe_0.9293399497400969" frameborder="0" scrolling="no" height="201" style="margin: 0px; padding: 0px; border-style: none; width: 910px;">
QQ20160913-1.png-25.1kB


等待完成之后的图

id="iframe_0.884468579897657" src="https://www.cnblogs.com/show-blocking-image.aspx?url=http%3A%2F%2Fstatic.zybuluo.com%2FcoderXu%2F3n54scu1nm2elhmm009wuvbd%2FQQ20160913-3.png&maxWidth=910&origin=http://www.cnblogs.com&iframeId=iframe_0.884468579897657" frameborder="0" scrolling="no" height="198" style="margin: 0px; padding: 0px; border-style: none; width: 910px;">
QQ20160913-3.png-27kB

二、Xib文件的注意事项

使用Xcode8打开xib文件后,会出现下图的提示。

id="iframe_0.07884248089976609" src="https://www.cnblogs.com/show-blocking-image.aspx?url=http%3A%2F%2Fstatic.zybuluo.com%2FcoderXu%2Fg61l7p3rpipveka1f9yzta6i%2FQQ20160913-9.png&maxWidth=910&origin=http://www.cnblogs.com&iframeId=iframe_0.07884248089976609" frameborder="0" scrolling="no" height="248" style="margin: 0px; padding: 0px; border-style: none; width: 910px;">
QQ20160913-9.png-41.7kB


大家选择Choose Device即可。
之后大家会发现布局啊,frame乱了,只需要更新一下frame即可。如下图

id="iframe_0.6456487432587892" src="https://www.cnblogs.com/show-blocking-image.aspx?url=http%3A%2F%2Fstatic.zybuluo.com%2FcoderXu%2Fyulrjsd3qs4hhabt16iyikzn%2FQQ20160913-11.png&maxWidth=910&origin=http://www.cnblogs.com&iframeId=iframe_0.6456487432587892" frameborder="0" scrolling="no" height="493" style="margin: 0px; padding: 0px; border-style: none; width: 910px;">
QQ20160913-11.png-113.2kB
  • 注意:如果按上面的步骤操作后,在用Xcode7打开Xib会报一下错误,
id="iframe_0.5065160961821675" src="https://www.cnblogs.com/show-blocking-image.aspx?url=http%3A%2F%2Fstatic.zybuluo.com%2FcoderXu%2Fu6tw3mdjonjspmh0h9uham98%2FQQ20160913-12.png&maxWidth=910&origin=http://www.cnblogs.com&iframeId=iframe_0.5065160961821675" frameborder="0" scrolling="no" height="164" style="margin: 0px; padding: 0px; border-style: none; width: 910px;">
QQ20160913-12.png-32.3kB
  • 解决办法:需要删除Xib里面
    <code class="xml" style="margin: 0px; padding: 0px;"><<span class="hljs-title" style="margin: 0px; padding: 0px; color: rgb(163, 21, 21); line-height: 1.5;">capability <span class="hljs-attribute" style="margin: 0px; padding: 0px; line-height: 1.5;">name=<span class="hljs-value" style="margin: 0px; padding: 0px; line-height: 1.5;">"documents saved in the Xcode 8 format" <span class="hljs-attribute" style="margin: 0px; padding: 0px; line-height: 1.5;">minToolsVersion=<span class="hljs-value" style="margin: 0px; padding: 0px; line-height: 1.5;">"8.0"/></span></span></span></span></span></code>
    这句话,以及把< document >中的toolsVersion和< plugIn >中的version改成你正常的xib文件中的值
    ,不过不建议这么做,在Xcode8出来后,希望大家都快速上手,全员更新。这就跟Xcode5到Xcode6一样,有变动,但是还是要尽早学习,尽快适应哟!

三、代码及Api注意

使用Xcode8之后,有些代码可能就编译不过去了,具体我就说说我碰到的问题。
1.UIWebView的代理方法:
**注意要删除NSError前面的 nullable,否则报错。

<code class="objectivec" style="margin: 0px; padding: 0px;">- (<span class="hljs-keyword" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.5;">void)webView:(<span class="hljs-built_in" style="color: rgb(102, 0, 102); margin: 0px; padding: 0px; line-height: 1.5;">UIWebView *)webView didFailLoadWithError:(nullable <span class="hljs-built_in" style="margin: 0px; padding: 0px; line-height: 1.5;">NSError *)error
{
    [<span class="hljs-keyword" style="color: rgb(0, 0, 136); margin: 0px; padding: 0px; line-height: 1.5;">self hideHud];
}</span></span></span></span></code>

四、代码注释不能用的解决办法

这个是因为苹果解决xcode ghost,把插件屏蔽了。
解决方法
打开终端,命令运行: sudo /usr/libexec/xpccachectl
然后必须重启电脑后生效

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

id="iframe_0.8158712559379637" src="https://www.cnblogs.com/show-blocking-image.aspx?url=http%3A%2F%2Fupload-images.jianshu.io%2Fupload_images%2F707724-9ace6550ccedaa6c.png%3FimageMogr2%2Fauto-orient%2Fstrip%257CimageView2%2F2%2Fw%2F1240&maxWidth=910&origin=http://www.cnblogs.com&iframeId=iframe_0.8158712559379637" frameborder="0" scrolling="no" height="349" style="margin: 0px; padding: 0px; border-style: none; width: 910px;">
QQ20160914-3.png

快捷键的设置在这里

id="iframe_0.5314969879109412" src="https://www.cnblogs.com/show-blocking-image.aspx?url=http%3A%2F%2Fupload-images.jianshu.io%2Fupload_images%2F707724-ed9730ab858c08a7.png%3FimageMogr2%2Fauto-orient%2Fstrip%257CimageView2%2F2%2Fw%2F1240&maxWidth=910&origin=http://www.cnblogs.com&iframeId=iframe_0.5314969879109412" frameborder="0" scrolling="no" height="423" style="margin: 0px; padding: 0px; border-style: none; width: 910px;">
QQ20160914-2.png

貌似Xcode8取消了三方插件的功能,具体可以查阅下Xcode8 Source Editor

五、权限以及相关设置

注意,添加的时候,末尾不要有空格
我们需要打开info.plist文件添加相应权限的说明,否则程序在iOS10上会出现崩溃。
具体如下图:

id="iframe_0.31096021784469485" src="https://www.cnblogs.com/show-blocking-image.aspx?url=http%3A%2F%2Fupload-images.jianshu.io%2Fupload_images%2F707724-d118ca12029c78ab.png%3FimageMogr2%2Fauto-orient%2Fstrip%257CimageView2%2F2%2Fw%2F1240&maxWidth=910&origin=http://www.cnblogs.com&iframeId=iframe_0.31096021784469485" frameborder="0" scrolling="no" height="209" style="margin: 0px; padding: 0px; border-style: none; width: 910px;">
QQ20160914-0.png

麦克风权限:Privacy - Microphone Usage Description 是否允许此App使用你的麦克风?
相机权限: Privacy - Camera Usage Description 是否允许此App使用你的相机?
相册权限: Privacy - Photo Library Usage Description 是否允许此App访问你的媒体资料库?通讯录权限: Privacy - Contacts Usage Description 是否允许此App访问你的通讯录?
蓝牙权限:Privacy - Bluetooth Peripheral Usage Description 是否许允此App使用蓝牙?

语音转文字权限:Privacy - Speech Recognition Usage Description 是否允许此App使用语音识别?
日历权限:Privacy - Calendars Usage Description 是否允许此App使用日历?

定位权限:Privacy - Location When In Use Usage Description 我们需要通过您的地理位置信息获取您周边的相关数据
定位权限: Privacy - Location Always Usage Description 我们需要通过您的地理位置信息获取您周边的相关数据
定位的需要这么写,防止上架被拒。

六、字体变大,原有frame需要适配

经有的朋友提醒,发现程序内原来2个字的宽度是24,现在2个字需要27的宽度来显示了。。
希望有解决办法的朋友,评论告我一下耶,谢谢啦

七、推送

如下图的部分,不要忘记打开。所有的推送平台,不管是极光还是什么的,要想收到推送,这个是必须打开的哟✌️

id="iframe_0.5241540090646595" src="https://www.cnblogs.com/show-blocking-image.aspx?url=http%3A%2F%2Fupload-images.jianshu.io%2Fupload_images%2F707724-2f3b64b1c6cc3f82.png%3FimageMogr2%2Fauto-orient%2Fstrip%257CimageView2%2F2%2Fw%2F1240&maxWidth=910&origin=http://www.cnblogs.com&iframeId=iframe_0.5241540090646595" frameborder="0" scrolling="no" height="203" style="margin: 0px; padding: 0px; border-style: none; width: 910px;">
QQ20160914-4.png

之后就应该可以收到推送了。另外,极光推送也推出新版本了,大家也可以更新下。

PS.苹果这次对推送做了很大的变化,希望大家多查阅查阅,处理推送的代理方法也变化了。

<code class="objectivec" style="margin: 0px; padding: 0px;"><span class="hljs-comment" style="color: green; margin: 0px; padding: 0px; line-height: 1.5;">// 推送的代理
[<UNUserNotificationCenterDelegate>]</span></code>

iOS10收到通知不再是在
[application: didReceiveRemoteNotification:]方法去处理, iOS10推出新的代理方法,接收和处理各类通知(本地或者远程)

<code class="css" style="margin: 0px; padding: 0px;"><span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.5;">- (<span class="hljs-tag" style="color: rgb(0, 0, 0); margin: 0px; padding: 0px; line-height: 1.5;">void)<span class="hljs-rule" style="margin: 0px; padding: 0px; line-height: 1.5;"><span class="hljs-attribute" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.5;">userNotificationCenter:<span class="hljs-value" style="color: rgb(0, 136, 0); margin: 0px; padding: 0px; line-height: 1.5;">(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler { //应用在前台收到通知 <span class="hljs-function" style="color: rgb(0, 102, 102); margin: 0px; padding: 0px; line-height: 1.5;">NSLog(@<span class="hljs-string" style="color: rgb(0, 136, 0); margin: 0px; padding: 0px; line-height: 1.5;">"========%@", notification);}<span class="hljs-tag" style="color: rgb(0, 0, 255); margin: 0px; padding: 0px; line-height: 1.5;">- (<span class="hljs-tag" style="color: rgb(0, 0, 0); margin: 0px; padding: 0px; line-height: 1.5;">void)<span class="hljs-rule" style="margin: 0px; padding: 0px; line-height: 1.5;"><span class="hljs-attribute" style="color: rgb(163, 21, 21); margin: 0px; padding: 0px; line-height: 1.5;">userNotificationCenter:<span class="hljs-value" style="color: rgb(0, 136, 0); margin: 0px; padding: 0px; line-height: 1.5;">(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler { //点击通知进入应用 <span class="hljs-function" style="color: rgb(0, 102, 102); margin: 0px; padding: 0px; line-height: 1.5;">NSLog(@<span class="hljs-string" style="color: rgb(0, 136, 0); margin: 0px; padding: 0px; line-height: 1.5;">"response:%@", response);}</span></span></span></span></span></span></span></span></span></span></span></span></span></span></code>

稍后我会更新文章,对推送做一个详细的讲解。

8.屏蔽杂乱无章的bug

更新Xcode8之后,新建立工程,都会打印一堆莫名其妙看不懂的Log.
如这些

<code class="cpp" style="margin: 0px; padding: 0px;">subsystem: com.apple.UIKit, category: HIDEventFiltered, enable_level: <span class="hljs-number" style="color: rgb(0, 102, 102); margin: 0px; padding: 0px; line-height: 1.5;">0, persist_level: <span class="hljs-number" style="margin: 0px; padding: 0px; line-height: 1.5;">0, default_ttl: <span class="hljs-number" style="margin: 0px; padding: 0px; line-height: 1.5;">0, info_ttl: <span class="hljs-number" style="margin: 0px; padding: 0px; line-height: 1.5;">0, debug_ttl: <span class="hljs-number" style="margin: 0px; padding: 0px; line-height: 1.5;">0, generate_symptoms: <span class="hljs-number" style="margin: 0px; padding: 0px; line-height: 1.5;">0, enable_oversize: <span class="hljs-number" style="margin: 0px; padding: 0px; line-height: 1.5;">1,</span></span></span></span></span></span></span></code>

屏蔽的方法如下:
Xcode8里边 Edit Scheme-> Run -> Arguments, 或者用快捷键打开:ctrl+shift+<,在Environment Variables里边添加
OS_ACTIVITY_MODE = Disable 

id="iframe_0.9166126626078039" src="https://www.cnblogs.com/show-blocking-image.aspx?url=http%3A%2F%2Fupload-images.jianshu.io%2Fupload_images%2F707724-e81adf182229475f.png%3FimageMogr2%2Fauto-orient%2Fstrip%257CimageView2%2F2%2Fw%2F1240&maxWidth=910&origin=http://www.cnblogs.com&iframeId=iframe_0.9166126626078039" frameborder="0" scrolling="no" height="493" style="margin: 0px; padding: 0px; border-style: none; width: 910px;">

如果写了之后还是打印log,请重新勾选对勾,就可以解决了

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值