title: Different behavior in Build & Archive / TestFlight than building directly to device
body: <p>I recently added to my app the ability to long-press on a UILabel inside a table cell to make the "Copy" menu appear so the user can copy the text to the pasteboard.  It works great both in the simulator and when I build directly to a device.  However, when I build &amp; archive (so I can push to TestFlight) the feature does not work.</p>
  
  <p>I attempted the solution in <a href="https://stackoverflow.com/questions/8813711/why-is-xcode-archive-acting-different-than-xcode-build-run-on-iphone">this Stack Overflow question</a> but it didn't work (and doesn't seem relevant since I'm building for iOS 5.0+).  I have <em>Optimization Level</em> set to <code>None [-O0]</code> in Build Settings.</p>
  
  <ol>
  <li>How can I debug what's failing if it works fine in Xcode?  (IE, is the Gesture Recognizer not working, or the UIMenuController, etc.)</li>
  <li>Why is the Archive copy behaving differently than the build-to-device copy?</li>
  </ol>
  
  <p>Here's the relevant code (although I'm 90% sure the issue is not this code but some Xcode setting):</p>
  
  <p><strong>Adding the Gesture Recognizer:</strong></p>
  
  <pre><code>UIGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]
                                                initWithTarget:self action:@selector(handleLongPressForCopy:)];
  [_postLabel addGestureRecognizer:longPress];            
  [self addSubview:_postLabel];
  </code></pre>
  
  <p><strong>Handle Long Press</strong></p>
  
  <pre><code>- (void)handleLongPressForCopy:(UILongPressGestureRecognizer *)recognizer {
      switch (recognizer.state) {
          case UIGestureRecognizerStateBegan:            
              NSAssert([self becomeFirstResponder], @"Sorry, UIMenuController will not work with %@ since it cannot become first responder", self);
              UIMenuController *theMenu = [UIMenuController sharedMenuController];
              CGRect displayRect = CGRectMake(_postLabel.frame.origin.x, _postLabel.frame.origin.y, 10, 0);
              [theMenu setTargetRect:displayRect inView:self];
              [theMenu setMenuVisible:YES animated:YES];
  
              break;
          default:
              break;
      }
  
  }
  - (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
      return (action == @selector(copy:) );
  }
  </code></pre>
  
  <p>As I said, it works great building to the device and in the simulator, just not after Build &amp; Archive.</p>