Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Don't initialize classes when registering matchers #649

Merged
merged 1 commit into from
May 21, 2016

Conversation

yas375
Copy link
Contributor

@yas375 yas375 commented Sep 29, 2015

2015-09-28_1940

It's possible that a library may have some assertions in theirs +initialize methods to help developers to find a potential problem in theirs setup. I.e. Facebook SDK makes sure you have specified required url scheme before you use FBSDKAppInviteDialog or FBSDKShareDialog, or FBSDKShareKit/FBSDKMessageDialog.

So we've just upgraded to the latest Facebook SDK and have started seeing exceptions when running tests. Those exceptions were exactly in those +initialize methods in FB sdk classes. But we don't use those features in our app so we don't need to set up all requirements it asserts for. It works fine when we run our apps because we never call those classes and theirs +initialize methods never called.

When we run tests KWMatcherFactory#registerMatcherClassesWithNamespacePrefix: is called and it loops through all available classes and check who conforms to KWMatching protocol. To check this, it uses NSObject#conformsToProtocol: which triggers +initialize call.

  • initialize
    Initializes the class before it receives its first message.
    Discussion
    The runtime sends initialize to each class in a program just before the class, or any class that inherits from it, is sent its first message from within the program.

This doesn't look right. Kiwi doesn't need to trigger initialize methods for every class it can see in runtime. The solution is simply to use class_conformsToProtocol() function for this.

I believe this closes #637, #638, https://groups.google.com/forum/m/#!topic/kiwi-bdd/ZfLol8_Oz8k

@glentregoning
Copy link
Contributor

👍 this PR, this is fixes the root cause of integration issues with Google Analytics / Facebook SDK (and others).

@IndieKevin
Copy link

+1 on the fix

@yas375
Copy link
Contributor Author

yas375 commented Oct 14, 2015

Any feedback on this from maintainers please? Would be very nice to get it merged in. thanks in advance!

@glentregoning
Copy link
Contributor

bump

It'd be great to get this fix onto master.

@ravelantunes
Copy link

Same issue here. Would be great to have it merged!

@ldrr
Copy link

ldrr commented Feb 22, 2016

Same issue here, could you please merge?

@gligorkot
Copy link

Same issue here, could you please merge this fix?

@orta
Copy link
Contributor

orta commented May 21, 2016

OK, cool, looks good to me, let's do it.

@orta orta merged commit 1d83dc1 into kiwi-bdd:master May 21, 2016
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected crash in interaction with Google Analytics
7 participants