xcode
An Xcode project: property lists that parse, complete string catalogs, asset catalogs that hold their images, Swift files that belong to a target, no arbitrary loads, and entitlements on a list. Guide: Swift.
Selected when
Section titled “Selected when”A scope has a project file *.xcodeproj.
Checks
Section titled “Checks”plutil
Section titled “plutil”Parses every property list and entitlements file with plutil.
Runs at the commit stage, on macOS.
A broken plist fails the build, or ships an app whose settings fell back to their defaults.
What to do
Section titled “What to do”Fix the element plutil names.
Example
Section titled “Example”A plist with an unclosed dictionary fails plutil. Close the dictionary element.
Turn it off
Section titled “Turn it off”gspot ignore xcode/plutil --paths "<path>" --reason "<why>"build-settings
Section titled “build-settings”Reports a target without strict concurrency, a run-script phase with no declared files, and a run-script phase that runs the linter or the formatter.
Runs at the commit stage, once per scope.
A phase with no declared files runs on every build, and data races pass the compiler without strict concurrency.
What to do
Section titled “What to do”Set SWIFT_STRICT_CONCURRENCY = complete, declare the input and output files of each run-script phase, and take the linter and the formatter out of the build.
Example
Section titled “Example”A run-script phase that calls swiftlint reports lint-script. Delete the phase: gspot runs SwiftLint before each commit.
Lint rules
Section titled “Lint rules”| Rule | What it checks | What to do |
|---|---|---|
strict-concurrency |
Each target sets SWIFT_STRICT_CONCURRENCY = complete or builds with Swift 6. |
Set SWIFT_STRICT_CONCURRENCY = complete, or move the target to Swift 6. |
undeclared-script |
Each run-script phase declares its input or output files. | List the files that the script reads and writes in the phase. |
lint-script |
No run-script phase runs SwiftLint or SwiftFormat. | Remove the lint step from the build phase. |
syntax |
A file that the check reads parses without errors. | Fix the syntax at the reported line. |
Turn it off
Section titled “Turn it off”gspot ignore xcode/build-settings --paths "<path>" --reason "<why>"gspot ignore xcode/build-settings --rule strict-concurrency --reason "<why>"xcstrings
Section titled “xcstrings”Checks that each string catalog parses and translates every string into all its locales.
Runs at the commit stage, once per scope.
A string with no translation shows its source language in the middle of a translated screen.
What to do
Section titled “What to do”Add the translation, or mark the string as not translated in the catalog.
Example
Section titled “Example”A catalog string that lacks a required locale reports a finding. Add the translation, or mark the string as not translated.
Lint rules
Section titled “Lint rules”| Rule | What it checks | What to do |
|---|---|---|
missing-translation |
Each string of a catalog has a translation for each locale that the catalog uses. | Translate the string, or set shouldTranslate to false for it. |
syntax |
A file that the check reads parses without errors. | Fix the syntax at the reported line. |
Turn it off
Section titled “Turn it off”gspot ignore xcode/xcstrings --paths "<path>" --reason "<why>"gspot ignore xcode/xcstrings --rule missing-translation --reason "<why>"assets
Section titled “assets”Checks that each asset Contents.json parses, and that its image set holds each file it names.
Runs at the commit stage, once per scope.
An image set with no image draws nothing at run time.
What to do
Section titled “What to do”Add the image or delete the asset.
Example
Section titled “Example”A Contents.json that names a missing icon.png reports a finding. Add the image beside it, or remove the reference.
Lint rules
Section titled “Lint rules”| Rule | What it checks | What to do |
|---|---|---|
empty-set |
Each image set names at least one image file. | Add the image files to the set, or delete the set. |
missing-image |
Each image file that a set names exists in the set folder. | Add the file to the set folder, or remove its entry from Contents.json. |
syntax |
A file that the check reads parses without errors. | Fix the syntax at the reported line. |
Turn it off
Section titled “Turn it off”gspot ignore xcode/assets --paths "<path>" --reason "<why>"gspot ignore xcode/assets --rule empty-set --reason "<why>"unused-assets
Section titled “unused-assets”Finds asset sets that no source or Xcode build setting names.
Runs at the commit stage, once per scope.
An asset nobody names ships in the app for nothing.
What to do
Section titled “What to do”Delete the asset, or name it in the code that loads it.
Example
Section titled “Example”An asset set that no source file or build setting names reports unused-asset. Delete it, or reference it where the app loads it.
Turn it off
Section titled “Turn it off”gspot ignore xcode/unused-assets --paths "<path>" --reason "<why>"files-without-target
Section titled “files-without-target”Finds the Swift files in the tree that no target of the project names.
Runs at the commit stage, once per scope.
Xcode never compiles a Swift file that belongs to no target, so it breaks unnoticed.
What to do
Section titled “What to do”Add the file to a target, or delete it.
Example
Section titled “Example”A Swift file in no target reports a finding. Add the file to a target, or delete it.
Turn it off
Section titled “Turn it off”gspot ignore xcode/files-without-target --paths "<path>" --reason "<why>"entitlements
Section titled “entitlements”Checks each entitlement against xcode.allowed_entitlements, when the settings hold that list.
Runs at the commit stage, once per scope. It skips until you set xcode.allowed_entitlements.
Each entitlement grants the app a system capability, so a new one needs its own review.
What to do
Section titled “What to do”Remove the entitlement, or add it to xcode.allowed_entitlements.
Example
Section titled “Example”An .entitlements key missing from xcode.allowed_entitlements reports a finding. Remove it, or add it to that list.
Turn it off
Section titled “Turn it off”gspot ignore xcode/entitlements --paths "<path>" --reason "<why>"app-transport-security
Section titled “app-transport-security”Refuses a property list that allows arbitrary loads, which turns transport security off for every host.
Runs at the commit stage, once per scope.
Arbitrary loads let the app send plain HTTP to any host, and one forgotten debug setting ships that.
What to do
Section titled “What to do”Remove the key, and add an exception for the one host that needs it.
Example
Section titled “Example”An Info.plist with NSAllowsArbitraryLoads reports a finding. Remove the key, and add an exception only for a host that needs one.
Turn it off
Section titled “Turn it off”gspot ignore xcode/app-transport-security --paths "<path>" --reason "<why>"Settings
Section titled “Settings”| Setting | What it sets |
|---|---|
xcode.allowed_entitlements |
The entitlements the app may hold; empty turns the check off. |
Rules for coding agents
Section titled “Rules for coding agents”| Rule file | Installed when |
|---|---|
.gspot/rules/XCODE.md |
Always |
Tools and versions
Section titled “Tools and versions”| Tool | Version |
|---|---|
| plutil | Any, install it yourself |
Paths that must stay out of Git
Section titled “Paths that must stay out of Git”**/xcuserdata/** and **/*.xcuserstate. repository/local-files reports a tracked file at these paths.