This has been happening to me on Swift 3.1, Xcode 8.3.2 for a month, I was coding okay, But it came to a point that all the text was only plain text, no colours, no auto complete, no indent. What a torture.....
Xcode was showing an error for NSAttributedString
, but it was compiling fine, I could even see the underlined button in the app no problem. When I removed this code xcode went back to normal. How strange.
Took me days to figure out. I checked out every single commit from github until I found a version of my project that doesnt throw An internal error occurred. Source editor functionality is limited. error.
Then I compared the commit versions and I figured this started to happen when I edited UIButton text thru the code.
Error caused because of NSAttributedString
I wanted to underline to the button text as following
let titleAttributes:[String : Any] = [NSForegroundColorAttributeName : Constants.forgotPassColor, NSUnderlineStyleAttributeName : NSUnderlineStyle.styleSingle.rawValue]
let localizedForgotPass = NSLocalizedString("forgotPassword", tableName: "Localizable", comment: "forgot button text")
let titleString = NSAttributedString(string: localizedForgotPass, attributes: titleAttributes)
forgetPasswordButton.setAttributedTitle(titleString, for: .normal)
Removing this solved the problem. There is something wrong with NSAttributedString
in Swift 3.1