Code Monkey home page Code Monkey logo

xcodewarningsasxcconfig's Introduction

Xcode Warnings to .xcconfig

MIT Linter

warnings2xcconfig is a tool to extract compiler and static analyzer warning flags from Xcode and format them into a xcconfig file you can use in your projects.

It provides sensible defaults for each flag so you can get as much help from the compiler as possible.

Ready-to-use xcconfig files

You can find pre-generated xcconfig files for your version of Xcode in the Xcode-* folders. Each folder contains a few xcconfig files with differents default settings (one per --defaults option, see below for what each option means).

Generating custom xcconfig files (or "how do I use this script?")

To produce a xcconfig file with strict, hand-picked defaults, run:

python3 warnings2xcconfig.py --defaults strict > Warnings.xcconfig

This will produce a xcconfig file with strict, but pragmatic, handpicked default values for each build setting.

You may need to install python 3 to run the script. Python 3 is available using brew:

brew install python3

Available styles

The possible values you can pass to the --defaults flag are:

Strict

Use strict, hand-picked default values. Those are similar to "agressive", but with some warnings turned off to keep day-to-day development sane:

python warnings2xcconfig.py --defaults strict

Clang

Use Clang's default values:

python warnings2xcconfig.py --defaults clang

Xcode

Use Xcode's default values (the ones you get when creating a new project):

python warnings2xcconfig.py --defaults xcode

Aggressive

Enable all warnings, using the most aggressive option available for each flag:

python warnings2xcconfig.py --defaults aggressive

None

If you pass none, or do not include the --defaults flag at all, the xcconfig file will be generated without default values, but with comments listing the valid values for each flag.

For example:

$ python warnings2xcconfig.py --defaults none
// Generated using XcodeWarningsAsXcconfig
// https://github.com/guillaumealgis/XcodeWarningsAsXcconfig

// Apple LLVM 7.1 - Warnings - Objective C and ARC
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = // YES | NO
CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = // YES | NO

... snip ...

// Static Analyzer - Analysis Policy
RUN_CLANG_STATIC_ANALYZER = // YES | NO
CLANG_STATIC_ANALYZER_MODE = // shallow | deep
CLANG_STATIC_ANALYZER_MODE_ON_ANALYZE_ACTION = // shallow | deep

You can then pick the settings you want to enable or not for your specific needs.

Clang Static Analyzer

If you decide to include Clang Static Analyzer flags in your xcconfig (which is the default), remember to enable the Static Analyzer in your project.

It can be done with the following flags (either in your xcconfig or Xcode project):

RUN_CLANG_STATIC_ANALYZER // YES | NO
CLANG_STATIC_ANALYZER_MODE // deep | shallow
CLANG_STATIC_ANALYZER_MODE_ON_ANALYZE_ACTION // deep | shallow

Custom Xcode install

By default, the script will use xcode-select -p to find your Xcode installation path. If you want to extract warnings from another Xcode install (say, a Beta), use the --xcode-path flag:

python warnings2xcconfig.py --xcode-path /Applications/Xcode-Beta.app/

Diff

To find out what changed between two version of Xcode, you can use the following command (in bash):

diff <(grep -E "^[^/ ]" Xcode-10.3/Warnings-XcodeDefaults.xcconfig | sort) <(grep -E "^[^/ ]" Xcode-11.0/Warnings-XcodeDefaults.xcconfig | sort)

(replace the xcconfig files to compare in the command)

Contributing

All PRs are welcome, just try to respect PEP-8, and make sure the code is formatted using Black.

The hand-picked values for the --defaults strict flag are really open to change (see the first few line of the script), I'd be super happy to get feedback on real-world results of using these.

Credits

This project is largely inpired from other great xcconfig projects and blog posts:

Credit to @steipete for finding the Clang Analyzer alpha checkers.

Author

Guillaume Algis (@guillaumealgis)

xcodewarningsasxcconfig's People

Contributors

caiodias avatar guillaumealgis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.