• This repository has been archived on 30/Jun/2020
  • Stars
    star
    955
  • Rank 47,869 (Top 1.0 %)
  • Language
    Swift
  • License
    MIT License
  • Created almost 8 years ago
  • Updated over 6 years ago

Reviews

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

Repository Details

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

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).

More Repositories

1

Optimizing-Swift-Build-Times

Collection of advice on optimizing compile times of Swift projects.
Swift
3,579
star
2

MotionBlur

MotionBlur allows you to add motion blur effect to iOS animations.
Objective-C
1,505
star
3

AHKActionSheet

An alternative to the UIActionSheet inspired by the Spotify app.
Objective-C
1,162
star
4

SloppySwiper

UINavigationController delegate that allows swipe back gesture to be started from anywhere on the screen (not just from the edge).
Objective-C
806
star
5

DeallocationChecker

Catch leaking view controllers without opening Instruments.
Swift
793
star
6

AHKBendableView

UIView subclass that bends its edges when its position changes.
Swift
592
star
7

EmojiTextView

Tap to swap out words with emojis. Inspired by Messages.app on iOS 10.
Swift
338
star
8

ReflectableEnum

Reflection for enumerations in Objective-C.
Objective-C
330
star
9

ConfigurableTableViewController

Typed, yet Flexible Table View Controller
Swift
269
star
10

AHKNavigationController

A UINavigationController subclass that re-enables the interactive pop gesture when the navigation bar is hidden or a custom back button is used.
Objective-C
232
star
11

HamburgerButton

Animated hamburger button.
Swift
197
star
12

BouncyView

Action Sheet animation based on Skype's iOS app.
Swift
128
star
13

AHKSlider

A UISlider subclass that improves the precision of selecting values.
Objective-C
59
star
14

SwiftOutTimingFunction

SwiftOutTimingFunction brings Google's new *Swift Out* animation curve to iOS.
Objective-C
44
star
15

AHKBuilder

Initialization for immutable objects based on the builder pattern.
Objective-C
39
star
16

SingleFetchedResultController

Like NSFetchedResultsController but for a single managed object.
Swift
26
star
17

StoryboardDependencyInjectionTemplates

Code generation of initializers for storyboard-based view controllers
HTML
19
star
18

BezierCurveFit

A simple app for fitting Bezier curve based on data points from another curve.
Objective-C
9
star
19

sicp

My solutions to exercises from "Structure And Interpretation Of Computer Programs"
Scheme
5
star
20

cool-compiler-examples

MIPS assembler files generated by my COOL compiler
Assembly
4
star
21

epidemic-simulation

Source code of a research project based on the use of cellular automata.
JavaScript
2
star
22

ContentOffsetJump

Source code of my answer: http://stackoverflow.com/a/19344402/1990236
Objective-C
1
star