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 fil
Not that I think this is related to OP's issue, but XCode 8 for me recently slowed to a halt. I eventually found it was my mistake (and I remember inadvertently doing it) - I added XCode.app as a Framework reference. This essentially made XCode search and index the entire XCode.app folder. Once I saw the mistake and remove the Framework it came good again :)
My problem was the dictionary. I had vary large dictionary.
let values = ["address":addressTextField.text,"city":cityTextField.text,"zipCode":zipCodeTextField.text,"state":stateTextField.text,"pet":answerLabel.text,"rentStart":rentStartTextField.text,"rentEnd":rentEndTextField.text,"rent":rentTextField.text,"phone":phoneTextField.text,"email":emailTextField.text,"status":leaseStatusTextField.text,"bedrooms":bedroomTextField.text,"parking":parkingLabel.text,"furnish":furnishLabel.text,"utilities":utilitiesTextField.text,"laundry":laundryTextField.text,"paymentCycle":paymentCycleTextField.text,"note":noteTextView.text]
I broke it down to:
var values = ["address":addressTextField.text]
values["city"] = cityTextField.text
values["zipCode"] = zipCodeTextField.text
values["state"] = stateTextField.text
values["pet"] = answerLabel.text
values["rentStart"] = rentStartTextField.text
values["rentEnd"] = rentEndTextField.text
values["rent"] = rentTextField.text
values["phone"] = phoneTextField.text
values["email"] = emailTextField.text
values["status"] = leaseStatusTextField.text
values["bedrooms"] = bedroomTextField.text
values["parking"] = parkingLabel.text
values["furnish"] = furnishLabel.text
values["utilities"] = utilitiesTextField.text
values["laundry"] = laundryTextField.text
values["paymentCycle"] = paymentCycleTextField.text
values["note"] = noteTextView.text
values["owner"] = userID
What solves this for me is using keys to set dictionary values
let dict: [string:any]()
dict["key"] = "value"
dict["key1"] = "value"
dict["key2"] = "value"
return dict
If you have a long dictionary it may or may not cause a compile loop resulting in long build times. Anything longer than 8 keys should be set way.
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 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.