上面的代码在 Xcode 7 中具有正确的语法高亮显示。它是 Obj-C + Swift 的混合体:
我更新了项目以支持 Xcode 8 并且只有几处发生了变化:
毕竟该项目已针对 Xcode 8编译良好strong>。
但是 Swift 中集成的 Obj-C 代码没有任何语法高亮显示,反之亦然:
删除派生数据没有帮助,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/