Giter Club home page Giter Club logo

warnings-xcconfig's Introduction

Warnings

This is an xcconfig file to make it easy for you to turn on a large suite of useful warnings in your Xcode project. These warnings catch bugs, so turning them on may identify bugs you can fix now and having them on will prevent bugs later.

If you have an existing project you've developed without these warnings turned on, you probably will have a number of warnings after turning them on. These are bugs in your code, newly revealed—fixing the warnings is fixing bugs.

The file also turns on Treat Warnings as Errors—so you can't just ignore warnings; you must fix them in order to be able to build—and the setting to run the Clang Static Analyzer in every build, which will find even more bugs (mostly leaks and crashers).

If you are new to Objective-C, you may find that you encounter build errors more frequently when using these settings. That is correct, expected, and good—the errors are bugs that would otherwise have gone undetected! Use these settings to identify your bad habits and things you don't fully understand, and take the opportunities to learn. You will learn better and faster with these warnings enabled.

The xcconfig file

Usage

  1. Copy it to your own project's root directory (the directory containing the .xcodeproj package).
  2. Add it to the project. In a modern project, it should be at the top level, either at the top of the list or below all of the per-target groups.
  3. Edit the project object (the very topmost item in the Project Navigator).
  4. Select the project, not any target.
  5. Select the Info tab.
  6. Under Configurations, expand both/all of the configurations.
  7. For each configuration, set the pop-up menu for the project to “Warnings” (which is the xcconfig file you just added).

What if you're already using an xcconfig file?

Xcode supports preprocessor directives in xcconfig files, so you can #include the Warnings file from your existing xcconfig file.

The test project

WarningsTest is an Xcode project containing a unit test bundle target. The project uses the xcconfig file, and the tests demonstrate the kinds of bugs that the file tells the compiler to warn about.

Usage

Open it in Xcode, hold down on the verb button (the one that says Run by default) and choose Test. This will attempt to build the unit test bundle and run the tests.

It will fail, because the tests are all written to demonstrate the warnings, not to test other code. (There is no code under test.) Because of all the warnings and the Treat Warnings as Errors setting, the build will never succeed.

Credits

warnings-xcconfig's People

Contributors

boredzo avatar tewha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

warnings-xcconfig's Issues

Documentation error

The second paragraph in the README.md file starts, "If you have an existing project you've developed with these warnings enabled, . . . " Should "enabled" be "disabled"?

Enable warnings for Swift

I've followed the direction in the README to attach warnings.xconfig to the project:
image

Then I've done some things to specifically test that some of these errors are thrown:

// empty loop
for _ in 0..<3 { } 

// shadowed variable
var index = 0
func another(){
  var index = 3 
}

I can build and run with no problem, however, and the errors aren't shown either as warnings or build blockers. Do I have this configured wrong? I'm probably doing something basic and silly, I'm very new to iOS, just want to start with guard rails.

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.