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

Could not cast value of type 'DetoxAppDelegateProxy' (0x1043b7118) to 'AppDelegate' (0x104142a68). #165

Closed
pvinis opened this issue Jun 20, 2017 · 9 comments

Comments

@pvinis
Copy link

pvinis commented Jun 20, 2017

this error appears on the simulator system log, during the detox init.
then the init just times out.

@LeoNatan
Copy link
Contributor

I need more info. Please provide a demo project that replicates this. Thanks

@LeoNatan
Copy link
Contributor

LeoNatan commented Jul 5, 2017

@pvinis Hello. Still waiting for that demo project. Thanks

@LeoNatan
Copy link
Contributor

Hmm, this seems to be the issue discussed elsewhere about Swift.

@jlongster
Copy link

@LeoNatan Yep, I am hitting this as well. Unfortunately this is a closed source app so I can't show it. This is the full stack trace:

Could not cast value of type 'DetoxAppDelegateProxy' (0x10560bed0) to 'Blink.AppDelegate' (0x104fef0e0).
Signal caught: Abort trap: 6
0   EarlGrey                            0x000000011d478339 grey_signalHandler + 249
1   libsystem_platform.dylib            0x000000010d70bb3a _sigtramp + 26
2   libsystem_kernel.dylib              0x000000010d6cf430 libsystem_kernel.dylib + 1072
3   libsystem_c.dylib                   0x000000010d47a88f abort + 127
4   libswiftCore.dylib                  0x000000010cb32d55 _ZN5swift10fatalErrorEjPKcz + 149
5   libswiftCore.dylib                  0x000000010cb10dbb _ZN5swift24swift_dynamicCastFailureEPKvPKcS1_S3_S3_ + 75
6   libswiftCore.dylib                  0x000000010cb10e20 swift_dynamicCastClass + 0
7   libswiftCore.dylib                  0x000000010cb10ec0 swift_dynamicCastClassUnconditional + 80
8   Blink                               0x000000010490684c _TFC5Blink11ChatManager10deactivatefT_T_ + 204
9   Blink                               0x00000001049077d0 _TFC5Blink11ChatManagerD + 32
10  Blink                               0x0000000104907822 _TToFC5Blink11ChatManagerD + 34
11  libobjc.A.dylib                     0x000000010642fb8e _ZN11objc_object17sidetable_releaseEb + 202
12  Blink                               0x0000000104bdb5a8 -[RCTModuleData .cxx_destruct]

We use Swift heavily, and it's interesting that I see a reference to the deactivate method of our ChatManager class. Can you explain what DetoxAppDelegateProxy is and I might be able to figure this out?

@jlongster
Copy link

jlongster commented Jul 24, 2017

Oh, I bet this is the line that's failing:

        let appDelegate  = UIApplication.shared.delegate as! AppDelegate

I'm guessing detox injects a different delegate class or something? I'm not too advanced with Swift. Any pointers on what I should debug next? I'll keep looking, and if I can't figure it out I'll try to make a demo project.

@jlongster
Copy link

I am able to get it work if I comment out these lines! So the question is: how can we get access to the app delegate in Swift?

@LeoNatan
Copy link
Contributor

I think I have an idea why it happens and will be able to provide a fix soon.
The problem is the strict Swift checking; proxy objects need to be more careful.

@pvinis
Copy link
Author

pvinis commented Jul 25, 2017

my app is also a mix of swift and objc. @jlongster how did you get that stacktrace?

@LeoNatan
Copy link
Contributor

Alright guys, I pushed a fix for this issue. Apologies it took a while. Should be available in the next release of Detox.

LeoNatan added a commit that referenced this issue Jul 30, 2017
…ObjC runtime to dynamically subclass the delegate class with own functionality. Closes #165

Add Swift example project for testing.
@wix wix locked and limited conversation to collaborators Jul 23, 2018
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

No branches or pull requests

4 participants