0

I was trying to migrate my project from swift 3 to swift 5. I (think) converted all the codes successfully and error free. However, when I try to run the project on Simulator (and device too), the app immediately crashes with the following error -

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

I'm not sure what this error means, and how could I solve it. I surfed through many similar questions on stackoverflow but nothing helped.

I tried searching for the pods that include +load method (I searched for +(BOOL)), and set their swift version from 5 to 4.2, as described in one of the other questions asked. But I'm still getting the error.

Here is my podfile -

# Uncomment the next line to define a global platform for your project
# platform :ios, '10.0'

target 'abc' do
  use_frameworks!
  pod 'Alamofire'
  pod 'AlamofireImage'
  pod 'AlamofireObjectMapper'
  pod 'Eureka'
  pod 'Firebase'
  pod 'Firebase/Core'
  pod 'Firebase/RemoteConfig'
  pod 'IQKeyboardManagerSwift'
  pod 'SideMenuController'
  pod 'SnapKit'
  pod 'Fabric'
  pod 'Crashlytics'
  pod 'MGSwipeTableCell'
  pod 'SSZipArchive'
  pod 'RealmSwift'
  pod 'Realm'
  pod 'React', :path => '../node_modules/react-native', :subspecs => [
    'Core',
    'DevSupport',
    'RCTText',
    'CxxBridge',
    'RCTNetwork',
    'RCTImage',
    'RCTAnimation',
    'RCTLinkingIOS',
#    'RCTWebSocket', # needed for debugging
    # Add any other subspecs you want to use in your project
  ]
  pod 'react-native-image-picker', :path => '../node_modules/react-native-image-picker'
  # Explicitly include Yoga if you are using RN >= 0.42.0
  pod "yoga", :path => "../node_modules/react-native/ReactCommon/yoga"
  pod 'react-native-image-picker', :path => '../node_modules/react-native-image-picker'

 end
robben
  • 637
  • 1
  • 7
  • 14
  • I'm very new to swift and iOS, so if someone could explain and guide me in simple words, that would be great. – robben Jun 25 '19 at 11:09
  • I'm using Swift 5 and Xcode 10.2.1 – robben Jun 25 '19 at 11:14
  • The type of a load method is `void`, the declaration in ObjC looks like `+ (void)load { ... }`, see the [docs](https://developer.apple.com/documentation/objectivec/nsobject/1418815-load?language=objc). The **Important** note in the docs might be a clue as to your issue. HTH – CRD Jun 25 '19 at 18:08
  • I will look into that. Also, I tried running it on iOS 11.4 (device) and it works fine. But not working in iOS 12 (both device and simulator), it crashes with the same above mentioned error. Can you explain why is that happening? – robben Jun 26 '19 at 03:35

1 Answers1

0

Okay I solved the issue by updating the pods, especially Follly and React (and Yoga). If anybody face a similar problem in future, they might refer to it.

robben
  • 637
  • 1
  • 7
  • 14