1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

motionBegan (shake) works via XCode run, but not via distribution!

Discussion in 'iPhone/iPad Programming' started by mms13, Aug 3, 2011.

  1. macrumors 6502

    I'm experiencing a very weird issue with my app:

    I'm going about the standard way of detecting a shake event. I have implemented the canBecomeFirstResponder method, and I call becomeFirstResponder in viewDidAppear and resignFirstResponder in viewWillDisappear. Then I implement the motionBegan method to handle the shake events.

    When I build and run my application onto my device through XCode, everything works great. The motionBegan event fires and my program properly handles the shake event. All good, so I submitted my application. I was shocked to find out that when I downloaded it from the App Store, that my shake events weren't working! Now, in trying to fix this problem, I've also found that it doesn't work if I archive my app as an .ipa file and then load it onto my phone through iTunes.

    In short, the shake event fires through a run on XCode, but not when it's been put onto a device via distribution methods!

    This doesn't make any sense to me so I'm really hoping someone knows what's wrong!

    PS - this issue occurs regardless of how application.applicationSupportsShakeToEdit is set.
  2. macrumors 65816


    Sounds like an issue because caused by debug build verses release build. Release build turns on compiler optimisations, which can expose bugs that aren't apparent without optimisations. Which version of XCode are you using?
  3. macrumors 6502

    Well, I was using XCode 4.2 to build on my iOS 5 device. Then I would open the project in XCode 4.0.2 to archive/submit to iTunes Connect. Perhaps that was the issue.

    But anyway, I fixed the problem by using the motionEnded() event handler as opposed to motionBegan(). Maybe motionBegan can't detect the shake event? Either way though it's weird that it works in debug but not release.

Share This Page