Xcode 8.0 Swift 3.0 slow indexing and building
Go to project settings, then Editor > Add Build Setting > Add User-Defined Setting, and add the following:
SWIFT_WHOLE_MODULE_OPTIMIZATION = YES
Adding this flag dropped our clean-build compile times from 7 mins to 65s for a 40KLOC swift project, miraculously. Also can confirm 2 friends have seen similar improvements on enterprise projects.
I can only assume this is some kind of bug in Xcode 8.0
I solved the problem by commenting all files and then removing comments one by one. I found that the problem is still in the array declaration as described here.
I had code like this and project was not indexing:
class {
var first: String!
var second: String!
var third: String!
var fourth: String!
var fifth: String!
func abc() -> [String] {
var array = [first, second, third, fourth, fifth]
}
}
I've changed it to this and indexing started working:
class {
var first: String!
var second: String!
var third: String!
var fourth: String!
var fifth: String!
func abc() -> [String] {
var array = [first]
array.append(second)
array.append(third)
array.append(fourth)
array.append(fifth)
}
}