Xcode debugger can't attach to compiler after upgrade macOS Mojave


#1

I am a learner about swift compiler.
I usually use $ utils/build-script --xcode --debug to build compiler.
And I use 2 ways to trace compiler internal execution.

First is open Xcode and set Launch = automatically in scheme for Run, and input Cmd + R to start compiler.
Second is set Launch = Wait for executable to be launched, input Cmd + R to wait starting compiler process, and type $ swift in terminal with $PATH including build product location.

It works good until now.

After I upgraded macOS to Mojave, second style does not work at all.
For example when I type $ swift --version, compiler immediately prints

$ swift --version
Swift version 5.0-dev (LLVM cbe8d5e28f, Clang 3452631569, Swift 2ef35ac80e)
Target: x86_64-apple-darwin18.2.0

xcode prints Message from debugger: unable to attach, and finish debugging.

I have gotten no information about fight to this from 3 weeks ago.
Please help me.


(Jordan Rose) #2

That definitely still ought to work. What version of Xcode do you have?


(Jordan Rose) #3

It's also possible that upgrading to Mojave reset the "developer mode" setting on the machine, which you can check by running DevToolsSecurity -status.


#4

Thanks.

macOS Mojave 10.14.1
Xcode 10.1 (10B61)

$ DevToolsSecurity -status -verbose
Getting rights definition for: system.privilege.taskport.debug
Current rights definition dictionary:
"(null)" : 1
"(null)" : "(null)"
"(null)" : 539349230
"(null)" : 0
"(null)" : 541783963
"(null)" : "(null)"
"(null)" : { "(null)", "(null)", "(null)" }

Developer mode is currently enabled.

I have two mac and both have this issue.
One is private machine at home.
Another is work machine at office.
System management is independent.
OS and Xcode versions are same.

DevToolsSecurity is output of one at home.


#5

I tried to completely reinstall Xcode and all packages from homebrew.
I removed all sources of swift compiler.
And checkout and build from clean state.
But issue happened.

Is anyone who face same issue?
I think it is common problem in Mojave.


#6

Today suddenly issue is resolved.
I used latest master.

commit adba3824a29c905c9bc4cd5ba08a8b086ded8713 (HEAD -> master, origin/master, origin/HEAD)
Merge: 570840f670 9818b55266
Author: Pavel Yaskevich <xedin@apache.org>
Date:   Wed Dec 12 00:44:44 2018 -0800

    Merge pull request #21238 from xedin/diag-property-as-member-via-fix
    
    [CSFix] Call a function/member which is incorrectly used as a property

One need to do is set Debug Process as to root.
I tested root setting already before.
So some changes about xcodeproj made by cmake in recent may resolve issue.