I've installed Xcode 8.0 and converted Swift 2.2 to 3.0 (that process also took a lot of time, I just left my Mac running all night). I have not a big project (about 20 files). I am also using Pods
. Indexing of previous Xcode version (< 8.0) worked fast but now, after upgrade, the progress bar is stuck on one position (I am already waiting for an hour).
Things I've tried that didn't help me:
DerivedData
folder and restarted XcodePods
directory with <project>.xcworkspace
and then installed againIt is really not cool to make such releases of software when developers have to spend hours on solving such ridiculous problems. It is very disappointing. Any ideas how to fix this?
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)
}
}
I've had the same issue only since upgrading to Swift 3/XCode 8 and it seems to be caused by large array literals.
I was able to fix the issue by adding type annotations to the variables being assigned to the array literal, e.g.
let array: Array<String> = ["1", "2", "3", "4", "5", "6", "7", "8"]
instead of
let array = ["1", "2", "3", "4", "5", "6", "7", "8"]
I had similar problem and followed this guide to debug : http://irace.me/swift-profiling My problem was i had nil coalescing operator in some strings for example:
let name = "\(someString ?? "")"
and four methods with this were causing 2 min additional building time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With