跳到正文
DEV Community· Zane ⚡️ Zipp開発者·· 7 天前AI 評分56

5 種 macOS 常見錯誤的快速排查方法,涵蓋 Gatekeeper、Xcode codesign、Rust ld、Homebrew 與雙欄 PDF

5 Uncopyable macOS Errors Developers Hit Weekly (Gatekeeper, Xcode codesign, Rust ld, Homebrew, Two-Column PDFs) — Real Screenshots & Quick Triage

AI 導讀

文章整理 Gatekeeper、Xcode codesign、Rust/Cargo 連結器、Homebrew 和雙欄 PDF 的 5 類 macOS 問題,並提供逐項排查方法。

正文

The common thread

Some macOS errors are not selectable text. They are drawn: dialogs, IDE overlays, console panes, the page image of a PDF. You cannot drag-select them, you cannot copy them, and Cmd+F finds nothing.

That changes the workflow. Normally you copy the message, paste it into a search engine, and read. Here you first have to get the text out. Below are five errors I hit repeatedly, each with the real triage commands first — and a note on the reading problem second.

Every screenshot is a real screen, reproduced as a before/after comparison.


1. Gatekeeper: "cannot be opened because the developer cannot be verified"

Gatekeeper dialog on macOS

"AppName" cannot be opened because the developer cannot be verified.

The variant that makes people panic:

"AppName" is damaged and can't be opened. You should move it to the Trash.

Neither means the binary is corrupt. Check, in order:

# 1. is the quarantine attribute attached?
xattr -l /Applications/AppName.app

# 2. what does Gatekeeper think?
spctl --assess --type execute -vv /Applications/AppName.app

# 3. is it signed at all?
codesign -dv --verbose=4 /Applications/AppName.app

If codesign reports code object is not signed at all, the build is unsigned — usually an ad-hoc distribution. If the distributor is trustworthy and only the quarantine flag blocks it:

xattr -dr com.apple.quarantine /Applications/AppName.app

Or from the GUI: right-click → Open → Open once.

The expensive mistake is deleting the app because the dialog said "damaged".

→ Gatekeeper triage page


2. Xcode: codesign failed with exit code 1

Xcode code sign error

Command /usr/bin/codesign failed with exit code 1

Three things determine this, in this order: certificate → provisioning profile → Bundle ID.

# 1. do we have a usable signing identity?
security find-identity -v -p codesigning

# 2. what is the build actually going to use?
xcodebuild -showBuildSettings 2>/dev/null \
  | grep -iE "CODE_SIGN|provisioning|DEVELOPMENT_TEAM"

# 3. what happened, verbosely?
xcodebuild -scheme YourScheme -configuration Debug build 2>&1 \
  | grep -iE "codesign|signing|profile"

The three common causes:

  • security find-identity returns 0 valid identities → no certificate in the keychain
  • DEVELOPMENT_TEAM is empty → no team selected
  • profile Bundle ID ≠ target Bundle ID

Verify an already-built product:

codesign --verify --deep --strict --verbose=2 App.app

→ Xcode codesign triage page


3. Rust / Cargo: the linker error is a result, not a cause

Rust linker error in a terminal

error: linking with `cc` failed: exit code: 1

The cause is a few lines above:

ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1

So read backwards:

# pull the linker lines, not only the last line
cargo build 2>&1 | grep -nE "ld:|undefined|note: reference|error:" | head -40

# what did the linker actually try?
cargo build -v 2>&1 | tail -60

# what does the binary ask for?
otool -L target/debug/your_bin | head
nm -u target/debug/your_bin | head

Typical causes: architecture mismatch (arm64 vs x86_64), an unresolved C/Objective-C symbol from build.rs, or a library path that needs RUSTFLAGS="-L /opt/homebrew/lib".

→ Rust linker triage page


4. Homebrew: undefined method / invalid option

Homebrew error in a macOS terminal

Error: undefined method `writable?' for nil:NilClass
Error: invalid option: --with-python3.8

Homebrew puts the conclusion on line 1. brew doctor comes second, not first.

# 1. sync the core first
brew update

# 2. then read errors only (warnings are normal and noisy)
brew doctor 2>&1 | grep -nE "^Error|Warning: " | head -20

# 3. which prefix are we even using?
brew --prefix
  • invalid option → the flag was removed (--with-* is largely gone)
  • undefined method → core/formula version mismatch, usually fixed by brew update
  • still broken → brew reinstall <name>

→ Homebrew triage page


5. Two-column PDFs: copy-paste scrambles the columns

Two-column paper page

Copy a paragraph from a two-column paper and the right column's opening gets glued to the left column's ending. Nothing is corrupted — the reading order is wrong, because extraction walks the row, not the column.

# does the PDF even have a text layer?
pdffonts paper.pdf

# extract preserving layout, then check the order
pdftotext -layout paper.pdf out.txt

Two fixes that work:

  1. Copy per column — select only the left column, then only the right one.
  2. Read a region instead of the stream — in Preview, hold ⌥ while dragging to force a rectangular selection, or capture the region and read it in place.

→ Two-column triage page


Reading the ones you cannot copy

The commands above all assume you can read the message. Half the time you cannot: the dialog has no text layer, the IDE overlay disappears when the pointer moves, the console pane refuses selection.

What I do instead of re-typing error messages by hand: press ⌃S, drag a box over the region, read the result in place. Escape closes it.

How it is wired, because the boundary matters for anyone under an NDA:

  • Recognition runs on-device via Apple Vision. The screen capture is not uploaded — the image stays local.
  • Translation is online. Only the recognized text is sent; the image never is.
  • Offline: recognition still works, translation does not.

Environment: macOS 13 or later, Apple silicon (arm64) only — it does not run on Intel Macs. The build is not notarized, so first launch is right-click → Open (see section 1 for why that warning is not corruption).

The full gallery — 18 real errors, same triage format for each entry:
Unity の Metal シェーダ警告の切り分け


The pattern worth keeping

  1. Dialogs are drawings. Check spctl / codesign / xattr before trusting the wording.
  2. Linker and build errors are bottom-up. The last line is the result; the cause is above it.
  3. Package managers put the conclusion first. Read line 1 before running the doctor.
  4. Column order is a layout problem, not an OCR accuracy problem. Changing the extraction route fixes the symptom.
  5. Get the text out without retyping it. Re-typing cannot be opened because the developer cannot be verified from a screenshot is where the hour goes.

來源:DEV Community · dev.to