SwinjectStoryboard
SwinjectStoryboard copied to clipboard
'@objc' class method in extension of subclass of 'SwinjectStoryboard' requires iOS 13.0.0
macOS Monterey 12.4 (21F79)
Xcode Version 13.2.1 (13C100)
inside my podfile Target:
platform :ios, '10.0'
pod 'Swinject', '~> 2.6.2'
pod 'SwinjectStoryboard'
Do I have to target iOS 13 to use this version of Swinject?
Update: tried targeting ios 13 and it did not resolve the issue.
I also tried updating Swinject to 2.7.1, which did not resolve the issue. I tried Swinject 2.8.2, which did nothing.
I tried specifying SwinjectStoryboard 2.2.0, 2.2.1, and 2.2.2.
import SwinjectStoryboard
import Foundation
extension SwinjectStoryboard {
@objc class func setup() { // THE ERROR IS ON THIS LINE
defaultContainer.register(JsonClient.self) { _ in
let mobileToken = preferences.string(forKey: "mobileAuthToken") ?? ""
return JsonClient(mobileToken: mobileToken, baseUrl:BaseUrl )
}
defaultContainer.storyboardInitCompleted(SignInViewController.self) { r, c in
c.client = r.resolve(JsonClient.self)!
}
```
I've same issue, anybody has a solution?
import SwinjectStoryboard
extension SwinjectStoryboard {
@objc class func setup() { <--- IS NEVER CALLED SINCE iOS 13!!
...
for those who struggles with setup method in XCode 14, Either turn off dead strip option, or use this workaround:
__attribute__((constructor)) static void swinjectStoryboardSetupEntry(void);
@interface SwinjectStoryboard (SetUp)
@end
@implementation SwinjectStoryboard (SetUp)
// will never get called from outside, but allows to keep swinjectStoryboardSetupEntry away from stripping
- (void) avoidDeadStripping {
swinjectStoryboardSetupEntry();
}
@end
__attribute__((constructor)) static void swinjectStoryboardSetupEntry(void) {
if ([SwinjectStoryboard conformsToProtocol:@protocol(SwinjectStoryboardProtocol)] &&
[SwinjectStoryboard respondsToSelector:@selector(setup)]) {
[SwinjectStoryboard performSelector:@selector(setup)];
}
}
Could you try this code? I think, it is important - using static func
(not @objc func
).
extension SwinjectStoryboard {
static func setup() { // <- Static here, instead of @objc
// ...
}
}
If it works, i create PR for fixing docs.
I have already removed SwinjectStoryboard from my app - I will add it back in on Monday and attempt your change.
Could you try this code? I think, it is important - using
static func
(not@objc func
).extension SwinjectStoryboard { static func setup() { // <- Static here, instead of @objc // ... } }
If it works, i create PR for fixing docs.
I use Xcode 14, but I still have the same problem. Should I remove SwinjectStoryboard in my project?
in my case is never entering the library SwinjectStoryboard, like it doesn't exists in my project