title: Xamarin.iOS Debugger doesn't attach
body: <p>We have a specific app that the debugger just won't attach with Xamarin Studio. We have tried the latest Stable and Beta channels with no luck. It happens in the simulator or on the device.</p>
  
  <p>When the debugger detaches, we can see this in XCode's console:</p>
  
  <pre><code>        Jun 18 15:41:51 Hitcents-iPad-2 kernel[0] &lt;Debug&gt;: lockbot[3258] Builtin profile: debugserver (sandbox)
          Jun 18 15:41:51 Hitcents-iPad-2 com.apple.debugserver-199[3270] &lt;Warning&gt;: Got a connection, waiting for debugger instructions.
          Jun 18 15:41:51 Hitcents-iPad-2 com.apple.debugserver-199[3270] &lt;Warning&gt;: 1 +0.000000 sec [0cc6/0303]: error: ::ptrace (request = PT_THUPDATE, pid = 0x0cc7, tid = 0x2503, signal = -1) err = Invalid argument (0x00000016)
          Jun 18 15:41:51 Hitcents-iPad-2 com.apple.debugserver-199[3270] &lt;Warning&gt;: 2 +0.004989 sec [0cc6/1303]: error: ::read ( 5, 0x2fe809fc, 18446744069414585344 ) =&gt; -1 err = Bad file descriptor (0x00000009)
          Jun 18 15:41:51 Hitcents-iPad-2 com.apple.debugserver-199[3267] &lt;Warning&gt;: 1 +0.000000 sec [0cc3/0303]: error: ::read ( 5, 0x2fd4bebc, 1024 ) =&gt; 0 err = Bad file descriptor (0x00000009)
          Jun 18 16:55:11 Hitcents-iPad-2 mobile_installation_proxy[3471] &lt;Error&gt;: main: Could not receive request from host.
          Jun 18 16:55:11 Hitcents-iPad-2 mobile_installation_proxy[3468] &lt;Error&gt;: main: Could not receive request from host.
          Jun 18 16:55:12 Hitcents-iPad-2 BattlePillars[3474] &lt;Warning&gt;: MonoTouch: Debugger not loaded (disabled).
  </code></pre>
  
  <p>Any ideas? Other apps besides this one work fine, and we can't see any difference in this specific app that would cause it.</p>
  
  <p>My current verions are:</p>
  
  <ul>
  <li>Xamarin Studio - 4.0.9 </li>
  <li>Xamarin.iOS - 6.3.6.77 </li>
  <li>XCode - 4.6.3 </li>
  <li>iOS - can be device or simulator, have only tried iOS 6.x</li>
  <li>Also, happens on every developer's Mac, so seems specific to the project/solution</li>
  </ul>
  
  <p>Here is the snippet of my project file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
    &lt;PropertyGroup&gt;
      &lt;Configuration Condition=" '$(Configuration)' == '' "&gt;Debug&lt;/Configuration&gt;
      &lt;Platform Condition=" '$(Platform)' == '' "&gt;iPhoneSimulator&lt;/Platform&gt;
      &lt;ProductVersion&gt;10.0.0&lt;/ProductVersion&gt;
      &lt;SchemaVersion&gt;2.0&lt;/SchemaVersion&gt;
      &lt;ProjectGuid&gt;{07958BCE-7F33-4F8F-9A86-5102FF4632FB}&lt;/ProjectGuid&gt;
      &lt;ProjectTypeGuids&gt;{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}&lt;/ProjectTypeGuids&gt;
      &lt;OutputType&gt;Exe&lt;/OutputType&gt;
      &lt;RootNamespace&gt;MyAppName&lt;/RootNamespace&gt;
      &lt;IPhoneResourcePrefix&gt;Resources&lt;/IPhoneResourcePrefix&gt;
      &lt;AssemblyName&gt;MyAppName&lt;/AssemblyName&gt;
    &lt;/PropertyGroup&gt;
  
  &lt;!--Further down--&gt;
  
      &lt;PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' "&gt;
          &lt;Optimize&gt;False&lt;/Optimize&gt;
          &lt;OutputPath&gt;bin\iPhone\Debug&lt;/OutputPath&gt;
          &lt;DefineConstants&gt;DEBUG, IPHONE&lt;/DefineConstants&gt;
          &lt;ErrorReport&gt;prompt&lt;/ErrorReport&gt;
          &lt;WarningLevel&gt;4&lt;/WarningLevel&gt;
          &lt;ConsolePause&gt;False&lt;/ConsolePause&gt;
          &lt;MtouchDebug&gt;True&lt;/MtouchDebug&gt;
          &lt;CodesignKey&gt;iPhone Developer&lt;/CodesignKey&gt;
          &lt;CrashReportingApiKey /&gt;
          &lt;MtouchI18n /&gt;
          &lt;MtouchArch&gt;ARMv7&lt;/MtouchArch&gt;
          &lt;IpaPackageName /&gt;
          &lt;OptimizePNGs&gt;false&lt;/OptimizePNGs&gt;
          &lt;MtouchLink&gt;None&lt;/MtouchLink&gt;
          &lt;MtouchExtraArgs&gt;-v -v -v&lt;/MtouchExtraArgs&gt;
        &lt;/PropertyGroup&gt;
  </code></pre>
  
  <p><strong>SOLUTION:</strong></p>
  
  <p>There are two places to check for this:</p>
  
  <ul>
  <li>Project Options->iOS Build->Additional Options = checked</li>
  <li>Project Options->Compiler->General Options->Debug Information = Full</li>
  </ul>
  
  <p>In addition, we had an Objective-C binding compounding the issue (TestFlight) that needs this set to fix debug builds:</p>
  
  <pre><code>#if !DEBUG
       TestFlight.TakeOff("key");
  #endif
  </code></pre>
  
  <p>It would crash in Debug otherwise.</p>