Post

Replies

Boosts

Views

Activity

SwiftUI debug preview attach failed (Not allowed to attach to process
Hi there, for some time now I'm having trouble debugging SwiftUI previews in Xcode. Whenever I select "Debug Preview" it fails with this error message: error: attach by pid '12009' failed -- attach failed (Not allowed to attach to process. Look in the console messages (Console.app), near the debugserver entries when the attached failed. The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.) When I look into the console messages, it says: macOSTaskPolicy: (com.apple.debugserver) may not get the task control port of (XCPreviewAgent) (pid: 12009): (XCPreviewAgent) is hardened, (XCPreviewAgent) doesn't have get-task-allow, (com.apple.debugserver) is a declared debugger(com.apple.debugserver) is not a declared read-only debugger Running the preview in non-debug mode ("Live Preview") works absolutely fine. It happens always and with an absolute minimal SwiftUI example: Package.swift: // swift-tools-version:5.3 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription let package = Package( name: "SwiftuiDebugIssue", platforms: [.iOS(.v14)], products: [ .library( name: "SwiftuiDebugIssue", targets: ["SwiftuiDebugIssue"]), ], dependencies: [], targets: [ .target( name: "SwiftuiDebugIssue", dependencies: []), ] ) Sources/SwiftuiDebugIssue/MyView.swift: import SwiftUI struct MyView: View { var body: some View { Text("Hello, world!") } } struct MyView_Previews: PreviewProvider { static var previews: some View { MyView() } } Relevant versions: macOS 11.5.2 (20G95) Xcode 12.5.1 (12E507) Thanks for any hints/help
3
0
3.0k
Sep ’21