I recently re-visited a question in swift and noticed that all code from the question and the answers doesn't compile anymore with the current Swift 2.1 release that comes with Xcode 7.2.
The reason is of course that Swift is an evolving language, and incompatible changes were made between releases (in particular in the transition to Swift 1.2/Xcode 6.3 and Swift 2.0/Xcode 7). These changes range from
- "minor changes", such as renaming
- "medium changes", such as replacing most global function by
protocol extension methods, i.e.
- "major changes", such as a completely new error handling model (
I wonder if this should have any effect on existing questions and answers. I assume that the answer is "NO", because
- we must not change the question, and
- each answer refers to the code as it was posted in the question.
The disadvantage however is that future visitors cannot copy/paste code from the answers into their project. Is there any recommendation how this could be handled?
I don't have the intention to edit all my Swift answers with each new Swift/Xcode release, but if I re-visit an answer (e.g. due to a voting change or comment), is there anything sensible that I can/should do?
Update: I am aware that the problem is not restricted to the Swift language (as pointed out in Quill's answer). One thing that might be different compared to other programming languages is that many (most?) Apple developers will install only the latest Xcode because
- only the latest Xcode has support for the current OS X and iOS SDKs and iOS devices, and
- usually, at some point, Apple doesn't allow App Store submission with older Xcode releases anymore.
- older Xcode releases might not run on the current OS X (example: Xcode 6.3.2 can't run on OSX 10.11 El Capitan Developer Preview 3).