To a weak class mix, for example. MyUploadManager in your own executable:
To keep the linker happy, add it to Other Linker Flags in the project:
-Wl,-U,_OBJC_CLASS_$_MyUploadManager
This allows the class symbol to be undefined, even if it is not embedded in your executable. Instead, it will be considered for dynamic search, in fact the same as the symbol of the dynamic library.
To maintain run-time health, add this to your class header:
__attribute__((weak_import)) @interface MyUploadManager
When the dynamic linker is running, it replaces nil instead of the class symbol instead of the class symbol.
Now you can run this without linker or runtime errors:
if ([MyUploadManager class]) { self.uploadButton.hidden = NO; }
Note. Starting with Xcode 7, the -U linker options conflict with BitCode, so you wonβt be able to use this method for future projects.
source share