Short answer

"can't be opened" or "is damaged and can't be opened" for an app downloaded from the internet is Gatekeeper, the macOS check that only lets signed, notarized software open without a warning. If you trust where the app came from, use Apple's way: try to open it, then go to System Settings, Privacy & Security, and click Open Anyway. Removing the quarantine flag with xattr -cr, the 2019 fix, skips that check without fixing anything; in a test, an app with a broken signature stayed broken after xattr. Check an app first with codesign and spctl, which only read it.

SWIFT TIPS · MAC · SECURITY

First posted on May 30, 2018, as "SwiftyJSONAccelerator.app can't be opened OR App demaged can't be opened", with updates in 2019. Rewritten on November 19, 2026. The checks were run on a Mac with macOS 26.0.1 on a tiny test app built for the test, which was never opened; no security setting was changed. Steps for the Settings app are from Apple's support article and developer news.

In 2018 I downloaded SwiftyJSONAccelerator, a tool that turns JSON into Swift model code, from GitHub, and macOS said it "can't be opened. You should move it to the Trash." The fix in the post: move the app to Applications and run sudo xattr -rd com.apple.quarantine on it. A January 2019 update said that on Mojave a newer version failed with "cannot be opened because of a problem", and that the earlier v1.3.0 worked. A November 2019 update added xattr -cr /path/to/application.app from an OSXDaily article, for apps reported as "damaged".

Those commands do get an app to open. They do it by removing the label that tells macOS to check the app, and the check exists for a reason. This rewrite tests what the commands change and what they don't, and gives Apple's way to open an app you trust.

What macOS is checking

Apple's support article on opening apps safely says that for apps from outside the App Store, macOS checks the Developer ID signature to make sure the app is from an identified developer and hasn't been altered, and that since Catalina it also requires notarization, a scan for known malware by Apple. Files downloaded by a browser get a com.apple.quarantine attribute, and that attribute is what makes macOS run the check the first time you open the app.

What the commands change: a test

I built a small app that does nothing, signed it ad hoc (a signature with no developer identity, like many apps built from source), and gave it a quarantine attribute like a browser download. Then I checked it, broke its signature by changing one byte, and ran the 2019 command:

$ codesign -s - -f Sample.app
Sample.app: replacing existing signature
  (exit 0)
$ codesign -dv Sample.app
Executable=Sample.app/Contents/MacOS/Sample
Identifier=com.example.gktest
Format=app bundle with Mach-O thin (arm64)
CodeDirectory v=20400 size=299 flags=0x2(adhoc) hashes=3+3 location=embedded
Signature=adhoc
Info.plist entries=3
TeamIdentifier=not set
Sealed Resources version=2 rules=13 files=0
Internal requirements count=0 size=12
  (exit 0)
$ codesign --verify --strict Sample.app
  (exit 0)
$ xattr -w com.apple.quarantine "0083;6735a1b2;Chrome;" Sample.app   # sample value, like a browser download
$ xattr -p com.apple.quarantine Sample.app
0083;6735a1b2;Chrome;
  (exit 0)
$ spctl --assess --type execute -vv Sample.app
Sample.app: rejected
  (exit 3)
(one byte appended to the program)
$ codesign --verify --strict Sample.app
Sample.app: main executable failed strict validation
  (exit 1)
$ xattr -c -r Sample.app
  (exit 0)
$ codesign --verify --strict Sample.app
Sample.app: main executable failed strict validation
  (exit 1)
  • codesign -dv shows how an app is signed. Here, Signature=adhoc and TeamIdentifier=not set: no identified developer.
  • spctl --assess asks Gatekeeper's policy without opening anything. It answered "rejected" for the ad hoc app, which is the decision behind the "can't be opened" dialog.
  • A changed app fails its signature check. After one byte was appended, codesign --verify reported that the main executable failed validation. Apple's article says that when macOS detects software that has been modified or damaged, it reports that the app can't be opened, because it might be broken, corrupted or tampered with.
  • xattr -cr didn't repair anything. It removed the attributes, and the signature check failed exactly as before. The command only removes the reason macOS would check; an altered app stays altered.

Opening an app you trust, Apple's way

  1. Prefer the App Store or the developer's own site, and the latest version.
  2. Try to open the app once, and close the warning.
  3. Open System Settings, click Privacy & Security, scroll down, and click Open Anyway. Confirm in the dialog that follows. Apple's article says the app is then saved as an exception, and opens normally afterwards.

Since macOS Sequoia, the old shortcut doesn't work: Apple's developer news from August 2024 says users can no longer Control-click to override Gatekeeper for software that isn't signed correctly or notarized, and must go to Privacy & Security instead.

Apple's article also separates the warnings: "will damage your computer" means macOS detected malicious content or the app's authorization was revoked, and a modified or damaged app is reported as one that can't be opened. Don't override either of those; download the app again from its official source, and if it's still reported, contact the developer.

Check before you trust

codesign -dv --verbose=2 /Applications/SomeApp.app    # who signed it
codesign --verify --deep --strict /Applications/SomeApp.app && echo "signature OK"
spctl --assess --type execute -vv /Applications/SomeApp.app   # Gatekeeper's decision

A Developer ID app shows the developer's name and team. "accepted" with "source=Notarized Developer ID" from spctl is what you want. None of these commands change the app or your settings.

For tools you'd rather build yourself

Many developer tools on GitHub, SwiftyJSONAccelerator included, are open source. Building one from source in Xcode gives you an app your Mac made, which avoids the download warning without turning anything off. For JSON to Swift models today, Codable structs written by hand, or generated by a tool you trust, replace SwiftyJSON code entirely.

A quick check for your Mac

  1. Think back to apps you opened with xattr -cr or xattr -d com.apple.quarantine, and run the three commands above on them.
  2. Replace any that fail with a version from the developer's official download.
  3. Remove apps you don't use anymore.

What the 2018 version said

The post showed the warnings, the app once it opened, and the Terminal command:

macOS warning: SwiftyJSONAccelerator can't be opened. You should move it to the Trash. Chrome downloaded this file from github.com

The SwiftyJSONAccelerator window after it opened

macOS alert: SwiftyJSONAccelerator cannot be opened because of a problem, with Ignore and Report buttons

Terminal running sudo xattr -rd com.apple.quarantine on the app

I left out two screenshots: one of a Finder sidebar that showed other people's computer names, and one of a Signal "damaged" warning that came with the OSXDaily tip. The OSXDaily source is linked below.

If this helped, you can buy me a coffee.

Sources