I’m getting this error on my Swift iOs app when I try to compile:
Undefined symbols for architecture arm64:
"checkForiOS14 #1 () -> Swift.Bool in App_Clip.NoteView.(reminderSymbolName in _82CBB329F1D225F83535F59E6FD7F4C3).getter : Swift.String", referenced from:
App_Clip.NoteView.(reminderSymbolName in _82CBB329F1D225F83535F59E6FD7F4C3).getter : Swift.String in NoteView.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The property it is referring to is a computed property/private var in a view to check the version of iOS:
private var iosVersion = UIDevice.current.systemVersion
private var reminderSymbolName: String {
if checkForiOS14() {
return "checkmark.circle"
} else {
return "checklist"
}
func checkForiOS14() -> Bool {
if let version = Double(iosVersion) {
if version <= 14.9 {
return true
} else {
return false
}
}
return false
}
}
I have done all the basic stuff, deleting derived data, cleaning my build folder, restarted my mac, I even went back to a commit that builds and copied the changed files to the new commit, but this error will not go away. I am not using any pods, but I am using some SPM packages. Any idea what is going wrong?
2
Answers
Well, isn't that always how it goes? You try everything, post on Stack, and then literally minutes later you fix it? Apparently the answer was taking my method out of the computed property and making it private, like so:
Hope this helps you if you are stuck like I was...
There’s built-in availability checks you can use for this purpose:
See https://nshipster.com/available/