07-19-2023, 12:08 AM
For me this was caused by some of my code. The detailed compiler output in XCode actually pin-pointed the method where it was crashing.
I then commented out all the code in the method, made it return nil, and it did compile. I then re-implemented the method using different and much simpler code, and it worked.
I filed a bug report with Apple. This is the - admittedly somewhat crazy - code that caused the crash in XCode 7 / Swift 2.0.
func numberAndTitleFromDirectoryName(dirName: String) -> (Int, String)? {
let components = dirName.characters.split(maxSplit: 1, allowEmptySlices: false) { $0 == " " }.map { String($0) }.map { String($0) }
if let number = components.first?.toInt() {
if let title = components.last {
return (number, title)
}
}
return nil;
}
I guess I got a little over-excited using the map function there... The new version is a lot simpler and also more human comprehensible. Still the compiler shouldn't crash. At worst it should show some errors. The code as is worked in Swift 1.x
I then commented out all the code in the method, made it return nil, and it did compile. I then re-implemented the method using different and much simpler code, and it worked.
I filed a bug report with Apple. This is the - admittedly somewhat crazy - code that caused the crash in XCode 7 / Swift 2.0.
func numberAndTitleFromDirectoryName(dirName: String) -> (Int, String)? {
let components = dirName.characters.split(maxSplit: 1, allowEmptySlices: false) { $0 == " " }.map { String($0) }.map { String($0) }
if let number = components.first?.toInt() {
if let title = components.last {
return (number, title)
}
}
return nil;
}
I guess I got a little over-excited using the map function there... The new version is a lot simpler and also more human comprehensible. Still the compiler shouldn't crash. At worst it should show some errors. The code as is worked in Swift 1.x