ios - Xcode 8 语法突出显示不起作用

标签 ios objective-c swift xcode syntax-highlighting

上面的代码在 Xcode 7 中具有正确的语法高亮显示。它是 Obj-C + Swift 的混合体:

enter image description here

我更新了项目以支持 Xcode 8 并且只有几处发生了变化:

  • 在build设置中支持 Swift 2.3 enter image description here

  • 并修复了一些与 UIKit 中隐式解包属性相关的错误 enter image description here

毕竟该项目已针对 Xcode 8编译良好

但是 Swift 中集成的 Obj-C 代码没有任何语法高亮显示,反之亦然:

enter image description here

自动完成存在<<错误类型>>问题: enter image description here

删除派生数据没有帮助,Xcode 要么重新启动 :) CocoaPods 版本 0.38.2,iOS 7

最佳答案

这个答案对我有帮助 https://forums.developer.apple.com/thread/46223我的一个项目:

I got help from an apple engineer at WWDC on this issue and resolved it. The problem stemmed from cocoapods... Apparently cocoapods was copying .h files into the build directory and SourceKit was getting confused. I'm not entirely sure why the .h files were being copied - they aren't needed there. So the fix was to add a post-build script in your build phases section that removes the headers after a build.
It would look something like this:

function removeHeaders() {  
    find $BUILD_ROOT/Debug-iphonesimulator/  -name '*.h' -exec rm -f {} \;  
}  
removeHeaders  

关于ios - Xcode 8 语法突出显示不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39598543/

相关文章:

objective-c - CMAccelerometerData 类与。弃用的 UIAccelerometer 类

iphone - CFRelease 但仍然泄漏

iphone - 设置编辑 :animated: is missing animation?

ios - UICollectionView,单元格与导航栏重叠

multithreading - 在多个线程上读/写自定义对象

ios - 应用程序不要求照片库使用权限

ios - 在 iOS 上没有登录的 OAuth 2.0?

iphone - 使用 URL 中的变量编写脚本的整数?

ios - 有没有一种方法可以控制图像选择器完成后转到哪个 View Controller

Swift:我的 NSTimer 有问题吗?