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/

相关文章:

ios - UITableViewCell 中的 UITextField——当它出现在屏幕上时以编程方式使其成为 firstResponder?

SwiftUI List 在底部添加空白

iphone - isOrientationSupported 在 IOS 中已弃用

iOS - 推送通知 SSL 证书有效性

iphone - 实现类似于 iPhone 联系人应用程序的 "add photo"按钮

ios - iPhone6 +在模拟器上呈现736点宽,但在实际设备上呈现667点宽

ios - 如何使用 2 个 View 从 IOS 应用程序发送电子邮件?

ios - 在 UICollectionView 中滚动时更新标签

ios - 环球银行金融电信协会3 : How to add headers to columns in UITableViewController?

ios - 第二次单击文本字段时键盘未显示 View