I'm not sure whether this is reproducible...
My swift iOS project is taking a long time to build. Actually, it does not build, the progress bar just stays there for about 15 minutes now:
This is really weird.
This is what I have done before building it:
- Changed the version and build number
- Archive project
- Wrote some code while the archive is being uploaded to app store
- The Archive has an error after uploading so I cleaned the project
- Archive again
- I noticed that I forgot to add a pod to the Linked Binaries section in the project settings so I added it
- Archived again
- Uploaded to app store
- Asked this question (I don't think this matters)
And now, the progress bar is staying there.
What can I do to make it faster?
P.S.
Yesterday it didn't take long to build. I only added a few lines of code today so I don't think the problem it is because of my project is too big. Maybe a bug in Xcode.
Fun fact: the progress bar is still there when I finish writing the question.
UPDATE
After checking out this post, I found out that compilation is always stuck at this file:
class UserSettings {
static var valueOfPi: Double {
let π = NSUserDefaults.standardUserDefaults().doubleForKey("valueOfPi")
return π == 0.0 ? M_PI : π
}
static var usePiLiteral: Bool {
return NSUserDefaults.standardUserDefaults().boolForKey("usePiLiteral")
}
enum SigFigOptions{
case No
case Yes(Int)
func correctTo (i: Double) -> Double {
switch self {
case .No:
return i
case let .Yes(sigFig):
if i == 0 {
return 0
}
let d = ceil(log10(i < 0 ? -i : i))
let power = sigFig - Int(d)
let magnitude = pow(10.0, Double(power))
let shifted = round(i * magnitude)
return shifted / magnitude
}
}
}
enum AngleMeasures : String {
case Degrees = "Degrees"
case Radians = "Radians"
case Gradians = "Gradians"
}
static var sigFigOption: SigFigOptions {
let userPref = NSUserDefaults.standardUserDefaults().integerForKey("sigFigOption")
return userPref == 0 ? .No : .Yes(userPref)
}
static var angleMeasure: AngleMeasures {
let measureId = NSUserDefaults.standardUserDefaults().integerForKey("angleMeasure")
switch measureId {
case 0:
return .Radians
case 1:
return .Degrees
case 2:
return .Gradians
default:
return .Radians
}
}
static func convertToPref (angleRadians: Double) -> Double {
switch angleMeasure {
case .Radians:
return angleRadians
case .Degrees:
return 180 * angleRadians / UserSettings.valueOfPi
case .Gradians:
return 180 * angleRadians / UserSettings.valueOfPi * (10.0 / 9.0)
}
}
static func convertFromPref (prefAngle: Double) -> Double {
switch angleMeasure {
case .Radians:
return prefAngle
case .Degrees:
return prefAngle * UserSettings.valueOfPi / 180.0
case .Gradians:
return prefAngle / (10 / 9) * UserSettings.valueOfPi / 180.0
}
}
static var pref90Degrees: Double {
return convertToPref(valueOfPi / 2)
}
static var pref180Degrees: Double {
return pref90Degrees * 2
}
static var prefHideWarning: Bool {
get { return NSUserDefaults.standardUserDefaults().boolForKey("hideWarning") }
set { NSUserDefaults.standardUserDefaults().setBool(newValue, forKey: "hideWarning") }
}
static var aValue: Double {
get { return NSUserDefaults.standardUserDefaults().doubleForKey("aValue") }
set { NSUserDefaults.standardUserDefaults().setDouble(newValue, forKey: "aValue") }
}
static var bValue: Double {
get { return NSUserDefaults.standardUserDefaults().doubleForKey("bValue") }
set { NSUserDefaults.standardUserDefaults().setDouble(newValue, forKey: "bValue")}
}
static var cValue: Double {
get { return NSUserDefaults.standardUserDefaults().doubleForKey("cValue") }
set { NSUserDefaults.standardUserDefaults().setDouble(newValue, forKey: "cValue")}
}
}
What piece of code in that file can possibly cause this? I think it's related to NSUserDefaults
, right?