JavaScriptBridge icon indicating copy to clipboard operation
JavaScriptBridge copied to clipboard

iOS 8 support

Open jtreanor opened this issue 10 years ago • 1 comments

Hi there,

Really great project :smile:

There are a few issues with getting this up and running in iOS 8.3:

  • [ ] 1. The segfault as pointed out in #28. Temporary fix is to not export the offending classes.
  • [ ] 2. I get the following error for almost every class (any class that defines a custom init method):
ERROR: Class UIViewController exported more than one init family method via JSExport. Class UIViewController will not have a callable JavaScript constructor function.
  • [ ] 3. Compile error on this line: https://github.com/kishikawakatsumi/JavaScriptBridge/blob/master/Classes/Private/UIView%2BJavaScriptBridge.m#L34
Passing 'void (^const _strong)()' to parameter of incompatible type 'JSValue *'

It would be awesome to get this up and running on iOS 8, I'm happy to do the work but I'm just getting my head around it right now.

Do you have any idea what the cause of 1 is and why is just happens for a small set of classes?

Regarding 2, one idea I had is to replace -(instancetype)initWithX: in protocols with a factory method like +(instancetype)createWithX:. For example UIView's protocol could have the method +(instancetype)createWithFrame:(CGRect)frame and UIView+JavaScriptBridge could have:

+ (instancetype)createWithFrame:(CGRect)frame {
    return [[[self class] alloc] initWithFrame:frame];
}

What do you think of this approach? Is there an automatic way to produce the framework headers so this wouldn't all have to be done manually?

I think 3 shouldn't be a big deal.

jtreanor avatar Apr 26 '15 17:04 jtreanor

Hmm, I retrieved the same problem!

fisherjoe avatar Jun 02 '15 04:06 fisherjoe