iOS notes¶
Swift¶
Herald's concepts are the same on every platform. Where Swift differs, the API follows Swift:
- Calls don't wait or throw.
track,set,identifyand the rest return once every vendor has the call: noawait, notry. Vendor SDKs do their own work in the background, so a call takes very little time. A provider of your own must return quickly too, and do slow work, such as a network request, in aTask. - Vendors report failures instead of throwing them. A vendor that can't send a call passes the
error to
Herald.reportFailure, and Herald sends it to your error reporter with the vendor's name and the call. - Setup mistakes stop the app. A provider without a name or capabilities, two providers with the same name, or a fallback factory that isn't last, stop the app at start-up with a message saying what to change.
- Your own factory that stores a vendor object, such as an
Amplitudeor aMixpanelInstance, needs@preconcurrency importof that vendor's module in Swift 6, because vendor SDKs aren't markedSendable. Xcode offers the fix. HeraldCore.Identity. Amplitude has anIdentitytype too, so in a file that imports both, write the module name in front.
Failures¶
- Each failure reaches the error reporter as soon as its vendor reports it, on the thread that made the call, not after every vendor has finished.
- Your own provider must return quickly, because Herald calls each provider on your thread and waits for it. See Custom providers.