Xamarin.iOS Debugger doesn't attach

2019-06-13 13:18发布

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.

When the debugger detaches, we can see this in XCode's console:

        Jun 18 15:41:51 Hitcents-iPad-2 kernel[0] <Debug>: lockbot[3258] Builtin profile: debugserver (sandbox)
        Jun 18 15:41:51 Hitcents-iPad-2 com.apple.debugserver-199[3270] <Warning>: Got a connection, waiting for debugger instructions.
        Jun 18 15:41:51 Hitcents-iPad-2 com.apple.debugserver-199[3270] <Warning>: 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] <Warning>: 2 +0.004989 sec [0cc6/1303]: error: ::read ( 5, 0x2fe809fc, 18446744069414585344 ) => -1 err = Bad file descriptor (0x00000009)
        Jun 18 15:41:51 Hitcents-iPad-2 com.apple.debugserver-199[3267] <Warning>: 1 +0.000000 sec [0cc3/0303]: error: ::read ( 5, 0x2fd4bebc, 1024 ) => 0 err = Bad file descriptor (0x00000009)
        Jun 18 16:55:11 Hitcents-iPad-2 mobile_installation_proxy[3471] <Error>: main: Could not receive request from host.
        Jun 18 16:55:11 Hitcents-iPad-2 mobile_installation_proxy[3468] <Error>: main: Could not receive request from host.
        Jun 18 16:55:12 Hitcents-iPad-2 BattlePillars[3474] <Warning>: MonoTouch: Debugger not loaded (disabled).

Any ideas? Other apps besides this one work fine, and we can't see any difference in this specific app that would cause it.

My current verions are:

  • Xamarin Studio - 4.0.9
  • Xamarin.iOS - 6.3.6.77
  • XCode - 4.6.3
  • iOS - can be device or simulator, have only tried iOS 6.x
  • Also, happens on every developer's Mac, so seems specific to the project/solution

Here is the snippet of my project file:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
    <ProductVersion>10.0.0</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{07958BCE-7F33-4F8F-9A86-5102FF4632FB}</ProjectGuid>
    <ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <OutputType>Exe</OutputType>
    <RootNamespace>MyAppName</RootNamespace>
    <IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
    <AssemblyName>MyAppName</AssemblyName>
  </PropertyGroup>

<!--Further down-->

    <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
        <Optimize>False</Optimize>
        <OutputPath>bin\iPhone\Debug</OutputPath>
        <DefineConstants>DEBUG, IPHONE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
        <ConsolePause>False</ConsolePause>
        <MtouchDebug>True</MtouchDebug>
        <CodesignKey>iPhone Developer</CodesignKey>
        <CrashReportingApiKey />
        <MtouchI18n />
        <MtouchArch>ARMv7</MtouchArch>
        <IpaPackageName />
        <OptimizePNGs>false</OptimizePNGs>
        <MtouchLink>None</MtouchLink>
        <MtouchExtraArgs>-v -v -v</MtouchExtraArgs>
      </PropertyGroup>

SOLUTION:

There are two places to check for this:

  • Project Options->iOS Build->Additional Options = checked
  • Project Options->Compiler->General Options->Debug Information = Full

In addition, we had an Objective-C binding compounding the issue (TestFlight) that needs this set to fix debug builds:

#if !DEBUG
     TestFlight.TakeOff("key");
#endif

It would crash in Debug otherwise.

2条回答
可以哭但决不认输i
2楼-- · 2019-06-13 13:24

Add "-v -v -v" (without quotes) to the additional mtouch arguments in the project's iOS Build options, recompile, and see if anything is printed to the Application Output and (Device/System) Console.

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-06-13 13:26

Did someone accidentally turn the debugger off? :) check project options -> build -> iOS build -> enable debugging

查看更多
登录 后发表回答