Diagnosing "System extension cannot be used"

I'm delivering an application alongside two generic kernel extensions which get placed in /Library/Extensions. When uninstalling I'd sometimes get an alert for each kext with the title "System extension cannot be used" and body "The system extension -- was installed improperly and cannot be used. Please try reinstalling it, or contact the product's vendor for an update.". I'm unable to reproduce this consistently.

The uninstall flow for the kexts involves calling KextManagerUnloadKextWithIdentifier on both kexts, followed by removal of the kext bundles from /Library/Extensions and finally, "touching" the folder with:


[NSFileManager.defaultManager setAttributes:@{NSFileModificationDate: [NSDate date]}
                               ofItemAtPath:@"/Library/Extensions"
                                      error:nil]


Is there somewhere I could look to get a more descriptive reason as to why the alert popped up?

Is this the correct flow to uninstall a generic kext? (currently supporting versions 10.10-14)