hyperlab / TiMixpanel

Mixpanel integration for Titanium Mobile
22 stars 12 forks source link

iOS: App crashes when trying to show a survey or in-app notification #29

Open skypanther opened 8 years ago

skypanther commented 8 years ago

When my app calls mixpanel.showSurvey() it crashes with the stack trace below.

Environment:

[ERROR] The application has crashed with an uncaught exception 'NSInvalidArgumentException'.
[ERROR] Reason:
[ERROR] Could not find a storyboard named 'MPSurvey' in bundle NSBundle </var/mobile/Containers/Bundle/Application/BD88ECCF-D811-4470-AAA1-DB1E2EF14D82/DEMO.app> (loaded)
[ERROR] Stack trace:
[ERROR]   
[ERROR] 0   CoreFoundation                      0x241022eb <redacted> + 126
[ERROR] 1   libobjc.A.dylib                     0x238cedff objc_exception_throw + 38
[ERROR] 2   UIKit                               0x28986f71 <redacted> + 0
[ERROR] 3   DEMO                                0x006a716b DEMO + 6611307
[ERROR] 4   DEMO                                0x006a7567 DEMO + 6612327
[ERROR] 5   libdispatch.dylib                   0x23c9fdd7 <redacted> + 10
[ERROR] 6   libdispatch.dylib                   0x23c9fdc3 <redacted> + 22
[ERROR] 7   libdispatch.dylib                   0x23ca4671 _dispatch_main_queue_callback_4CF + 1532
[ERROR] 8   CoreFoundation                      0x240c4fc5 <redacted> + 8
[ERROR] 9   CoreFoundation                      0x240c34bf <redacted> + 1590
[ERROR] 10  CoreFoundation                      0x24015bb9 CFRunLoopRunSpecific + 516
[ERROR] 11  CoreFoundation                      0x240159ad CFRunLoopRunInMode + 108
[ERROR] 12  GraphicsServices                    0x2528faf9 GSEventRunModal + 160
[ERROR] 13  UIKit                               0x28301fb5 UIApplicationMain + 144
[ERROR] 14  DEMO                                0x00060693 DEMO + 30355
[ERROR] 15  libdyld.dylib                       0x23cc8873 <redacted> + 2
[ERROR] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Could not find a storyboard named 'MPSurvey' in bundle NSBundle </var/mobile/Containers/Bundle/Application/BD88ECCF-D811-4470-AAA1-DB1E2EF14D82/DEMO.app> (loaded)'
[ERROR] *** First throw call stack:
[ERROR] (0x241022eb 0x238cedff 0x28986f71 0x6a716b 0x6a7567 0x23c9fdd7 0x23c9fdc3 0x23ca4671 0x240c4fc5 0x240c34bf 0x24015bb9 0x240159ad 0x2528faf9 0x28301fb5 0x60693 0x23cc8873)

Issues https://github.com/hyperlab/TiMixpanel/issues/4 and https://github.com/hyperlab/TiMixpanel/pull/22 suggest that the necessary storyboards should be compiled in automatically. That appears to not be working. Perhaps I've missed a step.

skypanther commented 8 years ago

If I manually add the storyboards and assets per #4 the app doesn't crash and the survey is displayed. However, the UI of my app is totally changed after building from Xcode. For example, tab icons are missing, the title bar title is missing, spacing of graphics is too large, etc.

inakiabt commented 8 years ago

Seems like Ti changed the way a native module handles assets (I saw that it now supports storyboards in latest version, could be that). I'll take a look this weekend. Could you try to copy the assets under iphone folder to assets folder and re build de module?

skypanther commented 8 years ago

I probably did this wrong, but I still get the same crashes.

Attempt 1: I copied TiMixpanel/ios/platform/iphone/* to TiMixpanel/assets, recompiled the module, tested in my app. Same crash.

Attempt 2: I copied TiMixpanel/ios/platform/iphone/* to myapp/app/assets/iphone, recompiled my app. Same crash.

skypanther commented 8 years ago

@inakiabt have you had any time to look at this? Appcelerator suggested some steps in https://jira.appcelerator.org/browse/TIMOB-20473 which unfortunately have not worked for me.

inakiabt commented 8 years ago

@skypanther I've played a bit on the weekend, but I couldn't test it completely. BTW, I built an app with same Ti SDK and iOS version (I didn't touch anything about TiMixpanel module since last version built with Ti SDK 5.0) and test it on my device and it worked. Can you try build the module with Ti SDK 5.0 or earlier but build your app with 5.2? That's what I did.

skypanther commented 8 years ago

@inakiabt

Can you try build the module with Ti SDK 5.0 or earlier but build your app with 5.2? That's what I did.

I think this is essentially the same as simply using the 0.8 version in your dist folder. But, I tried this as you suggested and get the same crash. I used the 3.5.1.GA SDK to build the module and the 5.2.0.GA SDK to build the app. For example, with an in-app notification (uses the same storyboards as in-app surveys), I get this error:

[ERROR] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Could not find a storyboard named 'MPNotification' in bundle NSBundle </var/mobile/Containers/Bundle/Application/849AD582-B5DC-42B0-9D94-0469F21C6EE1/DEMO.app> (loaded)'
[ERROR] *** First throw call stack:

You say when you did this, the app worked on device. Did you send a survey or simply run the app to gather analytics data? We can gather analytics without troubles. The issue comes when we create and send a survey or in-app notification (not push notification). When the app goes to show it, the app/module can't find the Mixpanel storyboards and causes the app to crash.

Could it be the age of the Mixpanel SDK included in your module? They're up to 2.9.4 and your module is using 2.6 (a year old).

jonatansberg commented 8 years ago

I haven't had time to look in to this, but my guess would be that the storyboard compilation step is broken for newer version of Xcode. The module Xcode project has a build step that should compile them for you automatically when building the module, creating a set of .storyboardc files in the platform folder if I remember correctly.

@skypanther If you have the time and ability I'd suggest trying 2 things:

  1. If you're using Xcode 7; try to build the module and app using Xcode 6.4 to see if that makes any difference. You can download older releases from the developer portal.
  2. Look at the build log for a "successful" Xcode build (i.e. one where the rest of your UI breaks) and try to identify the command run to compile the storyboards and compare that to the commands in the module build step. It could also help to look at an archive/release build.

Please feel free to update the Mixpanel SDK as well, if you have the time :)

skypanther commented 8 years ago

The storyboards are being compiled. Though, maybe they're not being compiled correctly?? I do get .storyboardc files and I see this in the console output:

Staring...
    MPNotification.storyboard found, staring compilation...
    MPSurvey.storyboard found, staring compilation...
Done

CompileC build/TiMixpanel.build/Release-iphoneos/TiMixpanel.build/Objects-normal/armv7/MPObjectSerializer.o Vendor/Mixpanel/MPObjectSerializer.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler

...lots more CompileC related output, followed eventually by

** BUILD SUCCEEDED **

Build settings from command line:
    SDKROOT = iphonesimulator9.2

=== BUILD TARGET TiMixpanel OF PROJECT TiMixpanel WITH CONFIGURATION Release ===

As for updating the Mixpanel SDK, I'm pretty green with module development. With the latest MP SDK source included, I've gotten the module to compile, but then it causes builds of my app to fail with the following:

[ERROR] ** BUILD FAILED **
[ERROR] The following build commands failed:
[ERROR]         Ld build/Intermediates/DEMO.build/Debug-iphoneos/DEMO.build/Objects-normal/arm64/DEMO normal arm64
[ERROR] (1 failure)

Normally, that would mean I have a missing architecture in the manifest file. However, it has architectures: armv7 i386 x86_64 arm64 listed. I'll keep poking at that.

cansoysal commented 7 years ago

Any update on this?