问题
I have a very puzzling problem. My app uses several custom buttons that use gesture recognizers to determine a tap or a long press.
When I run the app from XCode on my device everything works as it should. However, when I package the app in an .ipa file and install that on the same device the buttons no longer work! None of the gestures are recognized nor do they change state when pressed. Everything else seems to work fine...
The devices I tested are an iPhone 5 (running iOS 6.1.4) and iPhone 4 & 4S (both running iOS 6.1.3). And I'm using XCode 4.6.2 on Max OSX 1.8.3.
Any ideas what might be causing this very strange behavior?
PS: The "Xcode generated" code keeps on working after I've disconnected it from XCode.
回答1:
Typically the code you archive into an IPA file would use a different configuration than from when you run it from XCode. I can't guess what's wrong specifically without looking at your project file or having some more information, but the first thing I would try would be to do an Edit Scheme on the scheme you're using and compare the build configuration used for the Run action and the Archive action.
回答2:
It could be Optimization Level! You probably build AdHoc builds with Fastest, Smallest [-Os]
. See Optimization Level in your build settings. Build your debug with Fastest, Smallest [-Os]
, then you can see your misbehaviour in action, so you can fix it, and still submit apps with the preferred way of optimization (with Release configuration).
Fastest, Smallest [-Os]
somehow releases weak references more strictly, as far as I experienced.
回答3:
Same kind of surprising situation happened to me. I had all project related strings in GameStrings.h file defined against different macros. Those strings were detected while going to use them from the .ipa file in my iPad 2 but they were not shown on the screen. It's all about the target scheme configurations. As @ScorpioCurse has told that building and archiving a project may use different build configurations ,these type of problems may arise.
Just check whether these two(Build and Archive) schemes use the same configuration or not. Make sure that both of these schemes use the same build configuration.
来源:https://stackoverflow.com/questions/16618423/app-behaves-different-when-run-from-xcode-compared-to-ipa