I have one .swift file that holds a static array of structures that look like this:
struct ListOption: Hashable, Identifiable {
let id: UUID = UUID()
var name: String
var validIfOnlyOptionSelected: Bool = false
var data1: String = ""
var data2: String = ""
}
let ListOptions: Array<ListOption> = [
ListOption(name: "Code Not Found", validIfOnlyOptionSelected: true, data1: "X", data2: "99999"),
ListOption(name: "Code1", data1: "X", data2: "54669"),
ListOption(name: "Code2", data1: "Y", data2: "39078"),
ListOption(name: "Code3", data1: "Z", data2: "36199"),
ListOption(name: "Code4", data1: "X", data2: "36200"),
ListOption(name: "Code5", data1: "Y", data2: "36191"),
ListOption(name: "Code6", data1: "Z", data2: "36192"),
ListOption(name: "Code7", data1: "X", data2: "36203"),
ListOption(name: "Code8", data1: "Y", data2: "36204"),
...
]
With 350 members in the array, Xcode compiles in 4.3 seconds
With it's normal 5100 members it takes 23008.7 seconds (about 6.3 hours)
Even if there were no changes to this fie.
I would rather take the hit at compile time, then have the users wait for this data to load from a local JSON file.
Anyone know of something in the Swift compiler like with ObjC and precompiled headers?
Why is Xcode re-compiling this files if there were no changes to it, or the structure?
Is there a better way?
Thank you for your help