Git Product home page Git Product logo

ibanalyzer's Introduction

Build Status codecov

IBAnalyzer

Find common xib and storyboard-related problems without running your app or writing unit tests.

Usage

Pass a path to your project to ibanalyzer command line tool. Here's an example output you can expect:

$ ./ibanalyzer ~/code/Sample/

TwitterViewController doesn't implement a required @IBAction named: loginButtonPressed:
TwitterViewController doesn't implement a required @IBOutlet named: twitterImageView
LoginViewController contains unused @IBAction named: onePasswordButtonTapped:
MessageCell contains unused @IBOutlet named: unreadIndicatorView
MessagesViewController contains unused @IBAction named: infoButtonPressed

With IBAnalyzer, you're able to:

  1. Find unimplemented outlets & actions in classes. Avoid crashes caused by exceptions, like the dreadful:

    *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '
    [<Sample.TwitterViewController 0x7fa84630a370> setValue:forUndefinedKey:]: this
     class is not key value coding-compliant for the key twitterImageView.'
    
  2. Find @IBOutlets and @IBActions defined in code but not connected to from nibs. No more:

    Unnecessary action

    and

    Unnecessary outlet

Drawbacks

This is a new tool, used only on a handful of projects till now. If you encounter any bugs, please create new issues.

Doesn't work with Objective-C. Tested on Swift 3.0.

How It Works

IBAnalyzer starts by parsing all .xib, .storyboard and .swift files in the provided folder. It then uses this data (wrapped in AnalyzerConfiguration) to generate warnings. You can see the source of an analyzer checking connections between source code and nibs here.

New warnings can be implemented by adding a new type conforming to the Analyzer protocol and initializing it in main.swift. Check issues to learn about some ideas for new warnings.

Installation

CocoaPods (Build Phase integration)

Note: This can significantly slow-down your build times.

  1. Add pod 'IBAnalyzer' to your Podfile.

  2. Run pod repo update and then pod install.

  3. Go to target settings -> Build Phases and add a New Run Script Phase. Change its name to something like IBAnalyzer.

  4. Use this script to run analysis on all files in your repository (possibly including 3rd party dependencies, like Pods/):

    "${PODS_ROOT}/IBAnalyzer/bin/ibanalyzer" ./
    

    or this one to run analysis only on a single folder:

    "${PODS_ROOT}/IBAnalyzer/bin/ibanalyzer" FolderName/
    

Binary

Download the newest prebuilt binary from the Releases tab. Unpack and run using:

$ bin/ibanalyzer /path/to/your/project

From Source

  1. Clone or download the repo.
  2. Open IBAnalyzer.xcworkspace in Xcode 8.2 and build the project (⌘-B).
  3. $ cd Build/MacOS
  4. $ ./ibanalyzer /path/to/your/project

Attributions

  • SourceKitten – IBAnalyzer wouldn't be possible without it
  • SwiftGen – inspiration for NibParser
  • Sourcery – IBAnalyzer uses pretty much the same Rakefile

Author

Project initially started by Arek Holko (@arekholko on Twitter).

ibanalyzer's People

Contributors

ethanhuang13 avatar fastred avatar noobish1reviewer avatar

Watchers

 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.