Xcode 6.1 Swift Extensions - SourceKit Service Cra

2019-07-15 14:04发布

问题:

I am trying to add an extension to Swift so I can format Doubles as found in this answer here

Precision String Format Specifier In Swift

Not ideal, but best solution I can find so far. However I cannot seem to add extensions to my project. Extensions work fine on playground, but when I try to add it to my project, I get the SourceKit service crash error every time I try to add the code in. I also get an error stating "declaration is only valid at file scope".

I have not previously used extensions in Swift before, so I cannot tell if this is directly related to Xcode 6.1 update or not.

Has anyone else had this issues or know anyway to solve this?

回答1:

The SourceKit service crash error is pretty annoying and doesn't only happen with Extensions. I have found breaking your project up into different files has helped.



标签: swift xcode6