Daniel Bastidas
Daniel Bastidas

Reputation: 1945

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

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

Please some help

Upvotes: 23

Views: 11282

Answers (6)

Daniel Bastidas
Daniel Bastidas

Reputation: 1945

At the moment the quick fix:

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.

Upvotes: 4

Mile Dev
Mile Dev

Reputation: 670

I had the same problem and all I did was to update pods. Swinject pod was causing problem and after update to the latest version everything was solved. You may also try to adjust Swift language version in Pods Targets.

Upvotes: 0

Mustafa
Mustafa

Reputation: 61

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

Upvotes: 3

Evgeny Zhukov
Evgeny Zhukov

Reputation: 11

• Downgrading to Xcode 10.0 solved the issue in my case. You can download it at More Downloads for Apple Developers

Upvotes: -1

Ethan Worley
Ethan Worley

Reputation: 685

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.

Upvotes: 7

Nikita Haiko
Nikita Haiko

Reputation: 371

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!!!

Upvotes: 4

Related Questions