Swift class extensions and categories on Swift classes are not allowed to have +load methods

Daniel Bastidas picture Daniel Bastidas · Mar 30, 2019 · Viewed 8.6k times · Source

I have updated Xcode Version 10.2 (10E125) and testing on devices (not only simulator)

I get this message when I execute the app:

objc[3297]: Swift class extensions and categories on Swift classes are not allowed to have +load methods

  • It's just not working on devices with iOS 12.2. I would like to know if there was any update that was affecting the swift classes. So far no answer about this in other forums just saw that apple has some issues with other apps in production as well.

-I'm using extensions of swift classes but I don't think that is the problem

  • Using Cocoapods and Firebase dependencies.

  • I searched in my project any functions that could contain "load" functions, none found.

Please some help

Answer

Ethan Worley picture Ethan Worley · Apr 9, 2019

Just to add a solution for React Native projects.

This issue occurred because one of our custom react native modules was using the RCT_EXPORT_MODULE() macro which calls the init function and we were also including swift code. Since react-native version 0.59.3, there's a new macro RCT_EXPORT_MODULE_NO_LOAD(js_name, objc_name) which avoids the call to init. Replacing RCT_EXPORT_MODULE() with RCT_EXPORT_MODULE_NO_LOAD(js_name, objc_name) and updating to react native version 0.59.3 fixed the issue.