• Stars
    star
    504
  • Rank 87,537 (Top 2 %)
  • Language
    Swift
  • License
    Apache License 2.0
  • Created over 6 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A security blanket for Xcode project files

Xcode Project Linter (xcprojectlint)

Overview

This project provides a security blanket, ensuring neither your co-workers, nor git screw up your Xcode project file. Some of the settings are arguably a matter of personal taste. Fortunately, each option can be enabled separately. xcprojectlint currently supports these checks:

  • build-settings-externalized

    This mode ensures there are no settings configured at the project level, instead encouraging the use of xcconfig files.

  • dangling-source-files

    Ensures all source code files are members of a target.

  • disk-layout-matches-project

    This mode ensures the project references reflect actual file system locations. There are some occasions where you may not be able to exactly map a folder to disk (Frameworks and Products are common examples). For this, there is an additional parameter you can pass: --skip-folders, followed by a list of folders to ignore.

  • files-exist-on-disk

    This mode finds file references in the project which are not backed by files.

  • empty-groups

    This mode reports groups that contain no additional items.

  • items-in-alpha-order

    This mode ensures the project files and folders are in proper order. There are some occasions where you may not be able to exactly sort items in specific folders (Frameworks and Products are common examples). For this, there is an additional parameter you can pass: --skip-folders, followed by a list of folders to ignore.

  • no-white-space-specifications

    This mode ensures that no file or project contains whitespace specifications of: indentWidth, tabWidth, usesTabs, or lineEnding.

  • all

    For convenience, this mode runs all of the above tests.

When a failing condition is detected, as much useful context as possible is emitted to STDOUT, enabling Xcode to display the errors, in place. Further, it optionally can return EX_SOFTWARE, preventing the build from succeeding until the problem is addressed.

Building the Code

To build xcprojectlint tool, run

$ swift package update
$ make build

To work with the projects and tests in Xcode, run

$ xed .

Usage Examples

as a build script phase:

bin/xcprojectlint --report error --validations all --project $PROJECT_FILE_PATH

as a shell command:

xcprojectlint --report error --validations files-exist-on-disk items-in-alpha-order
--project /tmp/Example/Example.xcproject

The Nitty Gritty

xcprojectlint is operating on an undocumented file format. Years of looking at broken git merges has given us a reasonable confidence that we know how the parts all work together. That said, it is still a best guess, so there may be oversights. Fortunately, these linting operations are read-only, and will not modify your project file.

Each run starts by parsing the project file into a series of collections, which represent our understanding of how a project file is composed. It uses both the property list structure, and the comments Xcode writes into the project to assemble its data. Afterwards, xcprojectlint applies validity tests to the extracted collections, ensuring that the rules specified are met.

Clues to Fix By

As much as possible, xcprojectlint will attempt to tell you how to locate the problem. It’ll tell you which build configuration has settings, what the expected order of a group is, and whatever else it can squeeze out of the available context. Sometimes, it’ll even tell you the line number in the project file to look at. This is great, but do not attempt to view the project within Xcode. Terrible, terrible things will happen. Instead, use your favorite text editor to peer inside.

The Rules

  • Build Settings Externalized

    We iterate all the BuildConfiguration blobs, and investigate their BuildSettings entry. Empty settings are A-OK. Any found settings are in error.

  • Dangling Source Files

    Iterating through all the source files that appear in the Project Navigator of a project file, and ensures all are associated with a target within the same project/workspace. Any dangling files found will result in an error. This is particularly useful for test files.

  • Disk Layout Matches Project

    This test grabs the MainGroup out of the project, then recursively traverses the children. If the child node is a file, we retrieve the FileReference by id, then check for a name value. The presence of a name indicates this file reference does not have a matching file on disk.

  • Files Exist on Disk

    This uses a similar recursion to the Layout test, but instead of investigating the name value, it builds a URL to where the file should appear on disk. This is done by assembling the path that led to the file, then appending that to a path derived from the project’s path on disk, then finally testing for the presence of a file at that location.

  • Empty Groups

    One of the simpler tests. We again recurse the MainGroup, but this time look for entries that have zero children.

  • Items in Alpha Order

    We expect our project nodes to contain alphabetized Folders, followed by alphabetized files. We check on that by again recursing the groups, and at each level sifting the entries into groupNames, fileNames, and allNames. We sort the groups and files, contatenate them, then compare that to the list of everything.

  • No White Space Specifications

    Xcode has a way to, at the user-level, specify custom settings for tabs, spaces, indentation amount, and line endings within Preferences -> Text Editing -> Indentation. Formatting preferences can also be set at a file or project level, altering the experience for team-members if passed through PR unnoticed. This rule aims to alieviate the existence of any whitespace specification and provides the appropriate messages for each and their location within the project file.

Contributing

We welcome your interest in the American Express Open Source Community on Github. Any contributor to any Open Source Project managed by the American Express Open Source Community must accept and sign an agreement indicating agreement to the terms below. Except for the rights granted in this agreement to American Express and to recipients of software distributed by American Express, You reserve all right, title, and interest, if any, in and to your contributions. Please fill out the agreement.

Please feel free to open pull requests. Before submitting a PR, please run your code through swiftformat with the config file provided: swiftformat --config swiftformat.config Sources/ Tests/

License

Any contributions made under this project will be governed by the Apache License 2.0.

Code of Conduct

This project adheres to the American Express Community Guidelines. By participating, you are expected to honor these guidelines.

More Repositories

1

jest-image-snapshot

✨ Jest matcher for image comparisons. Most commonly used for visual regression testing.
JavaScript
3,821
star
2

react-albus

✨ React component library for building declarative multi-step flows.
JavaScript
1,094
star
3

earlybird

EarlyBird is a sensitive data detection tool capable of scanning source code repositories for clear text password violations, PII, outdated cryptography methods, key files and more.
Go
697
star
4

nodes

A GraphQL JVM Client - Java, Kotlin, Scala, etc.
Java
307
star
5

one-app

✨ a fresh, modular take on web application development
JavaScript
292
star
6

baton

HTTP load testing witten in Go
Go
264
star
7

iguazu

✨ Iguazu is a simple Redux-powered Async Query engine
JavaScript
202
star
8

busybee

BusyBee is an alternative API for IdlingResources in Espresso tests
Kotlin
189
star
9

jest-json-schema

✨ JSON schema matcher for Jest
JavaScript
169
star
10

parrot

✨ Scenario-based HTTP mocking
JavaScript
137
star
11

unify-flowret

A lightweight Java based orchestration engine
Java
98
star
12

holocron

✨Set of packages that are used to compose and load React components, enabling the updating and launching of server side rendered user experiences without server restarts
JavaScript
80
star
13

unify-jdocs

A new way of working with JSON documents without using model classes or JSON schemas
Java
72
star
14

hyperledger-fabric-sdk-php

Client SDK for Hyperledger Fabric for use in PHP applications
PHP
47
star
15

react-seo

✨ Simple SEO tag manager for React
JavaScript
45
star
16

fetchye

✨ If you know how to use Fetch, you know how to use Fetchye [fetch-yae]. Simple React Hooks, Centralized Cache, Infinitely Extensible.
JavaScript
41
star
17

eslint-config-amex

✨ This is American Express' eslint config
JavaScript
40
star
18

one-app-cli

✨A set of command line interface (CLI) tools for bundling One App, it's modules, and property files(locale and environment specific files).
JavaScript
36
star
19

k8s-prometheus-proxy

JavaScript
28
star
20

css-to-js

✨ Tool for transforming CSS into JS
JavaScript
28
star
21

grpc-k8s-health-check

A gRPC client-server application illustrating health checks of gRPC servers on Kubernetes
Go
27
star
22

amex-api-java-client-core

Library for authenticating with APIs published to the Amex for Developers portal.
Java
26
star
23

simplemli

Encode and Decode Message Length Indicators for TCP/IP socket based protocols
Go
25
star
24

synapse

Synapse is a set of lightweight foundational framework modules for rapid development, built-in with enterprise-grade maturity and quality.
Java
25
star
25

sfdx-cli-plugin

A plugin for the Salesforce DX CLI based on the Open CLI Framework (OCLIF)
TypeScript
24
star
26

one-service-worker

✨ Minimal, light-weight, Promise based library that unifies the service worker and browser threads under one API
JavaScript
23
star
27

purgecss-loader

✨ A Webpack loader to strip unused selectors from your CSS
JavaScript
22
star
28

redux-lifesaver

✨ redux-lifesaver is a middleware that keeps track of how many times actions of the same type are dispatched within a given period.
JavaScript
22
star
29

iguazu-rest

✨ Iguazu REST is a plugin for the Iguazu ecosystem that allows for pre-built async calls for REST with smart caching.
JavaScript
21
star
30

bucketlist

See what's in your BitBucket Server
Kotlin
18
star
31

react-conditional-flow

React components on top of control flow operations like if, if-else, if-else-if, switch-case, & try-catch
JavaScript
17
star
32

redux-idle-callback

✨ Redux middleware to dispatch actions during a Redux store's idle periods
JavaScript
16
star
33

babel-preset-amex

✨ Standard babel preset for American Express
JavaScript
16
star
34

iguazu-graphql

✨ Iguazu GraphQL is a plugin for the Iguazu ecosystem that allows for GraphQL requests backed by a simple cache.
JavaScript
16
star
35

amex-jest-preset

✨ An opinionated Jest preset
JavaScript
14
star
36

fetch-enhancers

✨ Library of middleware for enhancing Fetch
JavaScript
13
star
37

amex-jest-preset-react

✨ An opinionated Jest preset for React modules
JavaScript
13
star
38

xcode-result-bundle-processor

xcode-result-bundle-processor converts Xcode test result bundles into friendly HTML reports
Ruby
12
star
39

lumberjack

✨ Lumberjack is a minimal, configurable Console with utilities.
JavaScript
12
star
40

vitruvius

✨Vitruvius extends redux's combineReducers to allow developers to include a buildInitialState method on their reducer
JavaScript
11
star
41

jexm

Library to facilitate reading from Excel files
Java
10
star
42

targeted-offers-client

SDK for AMEX targeted offers API
JavaScript
10
star
43

task-status-pr-checker

This is triggered when a pull request is created. If the pull request has pending tasks. The pull request won't be merged and the status is updated on the pull request checks.
JavaScript
10
star
44

codeandsolve

9
star
45

parrot-jest-image-snapshot-example

✨ Example demonstrating usage of parrot for more deterministic jest-image-snapshot tests
JavaScript
9
star
46

amex-api-dotnet-client-core

Library for authenticating with APIs published to the Amex for Developers portal.
C#
9
star
47

express-checkout-tutorials

Code samples for use with Express Checkout API
HTML
8
star
48

one-app-ducks

✨Redux ducks used within the One App ecosystem.
JavaScript
8
star
49

env-config-utils

✨ Utilities for runtime configuration validations
JavaScript
8
star
50

create-shared-react-context

✨A memoized wrapper around React.createContext. Used by One App as a dependency to pass React context between Holocron modules without external usage.
JavaScript
8
star
51

middle-manager

An easy migration path away from the Java WorkManager concurrency API
Java
7
star
52

dux-socket

WebSocket middleware for Redux applications
JavaScript
7
star
53

one-app-dev-cdn

✨ Load remote modules for local development
JavaScript
7
star
54

gabby

Gabby provides a way to interface with several chatbot providers through "adapters". Adapters interface with different services such as api.ai and Watson Conversation.
TypeScript
7
star
55

json-parse-context

✨ Add the context of a json parse error to the error message with syntax highlighting if possible.
JavaScript
6
star
56

jacos

Java/Spring based SDK to enable insert, update and upsert of files and records in the SalesForce in Bulk, Single Record and Multi Record Mode
Java
6
star
57

react-iterative-flow

JavaScript
6
star
58

one-app-dev-proxy

✨ Proxy requests to remote servers locally while also allowing for an express middleware to be provided and applied to all requests
JavaScript
6
star
59

easydist

An end-to-end distributed deep learning tool that mimics the single-machine keras programming model
Python
6
star
60

findxcprojorphan

Finds source files unreferenced in Xcode project
Ruby
5
star
61

SPAN

A stored procedures framework
Java
5
star
62

jakasu

Powerful config driven SDK to easily consume events from one or multiple Kafka topics in both standard and streaming modes
Java
5
star
63

iguazu-rpc

✨ Iguazu RPC is a plugin for the Iguazu ecosystem that allows for configurable async calls and caching strategies.
JavaScript
5
star
64

fabric-integration

Project born out of a need to have a "stable" interface to the Fabric node SDK across various versions.
TypeScript
5
star
65

mlflow-server-proxy

Jupyter server proxy extension for mlflow tracking server
Python
4
star
66

bloom

BLooM is a configuration driven bigdata framework to load massive data into MemSQL
Java
4
star
67

suwannee

RESTful API to enable smart contract interaction from any language or platform
TypeScript
4
star
68

create-using-template

JavaScript
4
star
69

un-locode-java

Java
4
star
70

dydaq

DyDaQ framework connects GraphQL service layer with database efficiently
Java
4
star
71

omnitransform

Declarative and config driven Big Data/ETL framework based on Apache Spark
Java
3
star
72

rate-limiting-scheduled-executor

Java
3
star
73

jakapu

Config driven SDK to publish events into any Kafka topic without writing code
Java
3
star
74

yelp-search

Programmatically search Yelp for businesses using the public version 2.0 of the Yelp Search API
Swift
3
star
75

hide

Config Driven Big Data component which can generate data extracts in various formats from any Hive Tables
Shell
3
star
76

connectchain

Python
2
star
77

chaincode-guide

1
star