Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 874
Daniel Bastidas Avatar asked Mar 30 '19 21:03

Daniel Bastidas


4 Answers

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.

like image 67
Ethan Worley Avatar answered Oct 18 '22 03:10

Ethan Worley


In my case the only one dependency that has +load method is RxAtomic. Which, by the way, is the only one that didn't update to the current moment to swift 5.0. So I suppose this bug caused by RxSwift. And I also have Swinjects dependencies, but updated all to the newest releases that support swift 5 - it didn't help.

EDIT

I just open Pods project file. Select RxAtomic Target. And change User-Defined property 'SWIFT_VERSION' from 5.0 to 4.2. And it works!!!

like image 45
Nikita Haiko Avatar answered Oct 18 '22 03:10

Nikita Haiko


At the moment the quick fix:

  • Download the previous version of Xcode 10.1

Once you've done that, rebuild your project and it works just fine on any device.

I think the problem is related to Swift 5. What we would probably need to do is update all the dependencies to Swift 5. At the moment I don't have the time to do so.


The long fix: Is update your pods and slowly migrate toward swift5.

The pod that was giving more problems was: Swinject with SwinjectStoryboard, and RxOptional.

like image 34
Daniel Bastidas Avatar answered Oct 18 '22 03:10

Daniel Bastidas


upgrade to react-native version ^0.59.5

solved it without RCT_EXPORT_MODULE_NO_LOAD,

to update react-native version,

rm -rf node_modules
yarn add react-native@^0.59.5

so this will update other dependancies packages with the new version

like image 32
Mustafa Avatar answered Oct 18 '22 04:10

Mustafa