The bug 🐛
This past week I came across a fascinating bug, the kind I don't think I've encountered before. I'm working on a project where we use the [Vision framework][0] to detect [PDF-417 barcodes][1].
In order to do that we create a VNDetectBarcodesRequest
with its symbologies set to PDF-417, like so:
When using the release candidate for Xcode 13 (build 13A233) which ships with the iOS 15 SDK and Swift 5.5 toolchain, there is now a warning saying that .PDF417
has been renamed to .pdf417
.
However, if you change the symbol name to the new, lowercased version and try to run on an earlier version of iOS (e.g. iOS 13) this results in a crash at runtime:
SIGABRT: missing lazy symbol called
As you would expect, the lowercased symbol name works fine on devices running iOS 15.
The Workaround 🔨
Initially I thought, I'll wrap this in an @available
conditional and the problem will go away. Shouldn't be necessary but it fixes the problem:
However, we're still using Xcode 12.5 on CI to build and test, and if this is an issue how many more monsters are out there?
It may be wiser to wait until Xcode 13.1 before moving to this new toolchain.
The band-aid 🩹
So to get the best of both worlds and ensure this works on both older and the latest versions of iOS, regardless of your choice of Xcode (limited to 12.5 or 13), I ended up going with the following:
It doesn't feel that clean, but it does work. 🤷♂️
Feedback: FB9659813.