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

Overview

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

Comments
  • SwiftLint integration

    SwiftLint integration

    I don't use neither IBAnalyzer nor SwiftLint but I guess it would be marvellous to be able to lint for something like this. It might not make sense though so feel free to close.

    opened by wokalski 4
  • IBAnalyzer Installed from cocoapods not working

    IBAnalyzer Installed from cocoapods not working

    I Installed IBAnalyzer from cocoapods and it is working oppositely.

    Example: Added line @IBOutlet private weak var someLabel: UILabel!

    There is no any warning. Connected UILabel to this IBOutlet And appeared warning /Users/.../XcodeProjects/ScriptsTest/ScriptsTest/Base.lproj/Main.storyboard:37:94: warning: IBOutlet missing: someLabel is not implemented in Main.storyboard

    But I compiled sources and replaced IBAnalyzer.app in cocoapods folder and it works correctly.

    opened by bonyadmitr 3
  • Fixed build errors

    Fixed build errors

    Xcode9.2 fails to build the project because of SourceKittenFramework. Like:

    Clang+SourceKitten.swift:81:52: error: cannot use optional chaining on non-optional value of type 'String'
            return rootXML["Declaration"].element?.text?
    

    Changes:

    • fixed build errors;
    • fixed swiftlint warnings;
    • updated project to use recommended settings;
    • updated project's dependencies to the latest versions.
    opened by sgl0v 3
  • Decide on a distribution model

    Decide on a distribution model

    Building the project from scratch to be able to use it is cumbersome. We should come up with a better way to distribute it, e.g. by building a binary the way SwiftGen does.

    enhancement help wanted 
    opened by fastred 3
  • Relative paths aren't working

    Relative paths aren't working

    I installed this in ~/bin so I could access it from any project. However, when launching it, it complains that it cannot find the file.

    e.g.

    ibanalyzer MyProject results in Path /Users/troy/bin/IBAnalyzer.app/Contents/MyProject doesn't exist.

    However, launching it like ibanalyzer ~/Projects/MyProject works.

    bug starter 
    opened by troya2 2
  • Made the scripts in the README more robust

    Made the scripts in the README more robust

    The scripts in the README are now wrapped in quotes and the PODS_ROOT environmental variable is wrapped with curly brackets as that is the normal way of using it.

    This makes them more robust for spaces in paths and CI etc.

    opened by Noobish1 1
  • Building releasable binary

    Building releasable binary

    The current way of distribution is obviously too cumbersome. To be able to easily distribute IBAnalyzer through CocoaPods or Homebrew we have to be able to build a single binary containing all required dynamic frameworks.

    I didn't look into that yet but I think that Sourcery and SwiftGen have this already figured out.

    opened by fastred 1
  • Run Script?

    Run Script?

    Just a suggestion - anyway that this could be turned into a run script when you build or run your app? It'll throw a warning/error if it finds an issue. Alternatively, SwiftLint integration seems appropriate, since these types of issues are akin to their force_try rule, which throws an error if you implicitly unwrap any optionals.

    Just my $0.02.

    Thanks for your work!

    opened by ArtSabintsev 1
  • Swift 4.1 false positives

    Swift 4.1 false positives

    Environment

    XCode 9.3 Swift 4.1

    Problem

    IBAnalyzer gives and an error xib:19:88: warning: IBOutlet missing: tableHeight is not implemented in SomeView.xib even though tableHeight is implemented. There's no such error with XCode 9.2 and Swift 4.0.3.

    Solution

    The root of the problem is incorrect parsing, which results in Class with empty outlets/actions. Need to fix code parsing for Swift 4.1.

    opened by devandsev 0
  • Use multiple exit codes using strict mode.

    Use multiple exit codes using strict mode.

    Hi @fastred .

    Does this approach make sense to you all?

    exit 0 No errors, maybe warnings in non-strict mode exit 1 Usage or system error exit 2 Style violations of severity "error" exit 3 No style violations of severity "error", but violations of severity "warning" with strict

    opened by hryk224 0
  • Support for ignored files list. Files which needs not to be analysed for broken outlets.

    Support for ignored files list. Files which needs not to be analysed for broken outlets.

    I don't want IBAnalyzer to parse every folder and file in my project folder. I need to maintain an ignore list, this will make my analysing more faster. Is there any support for this?

    opened by dheerajjha 0
  • Does the development continue?

    Does the development continue?

    Hey, I finally got some time to test IBAnalyzer in some projects I'm working on. It shows some nice results :-) But I also miss some features like ignoring files or specifying multiple paths for analyzing.

    As there are no commits in the last months: Are you still have plans to continue the development?

    opened by tschob 3
  • Warnings shown when another object in the xib is linked to an outlet

    Warnings shown when another object in the xib is linked to an outlet

    So we have some xibs where we have a UIViewController and another object in the xib (you can do this by dragging in an Object from the Object Library) and the UIViewController has some buttons and we link the actions from the buttons to the Object. This causes IBAnalyzer to show warnings because the action isn't linked to the UIViewController.

    opened by Noobish1 1
  • Output view controller name or id

    Output view controller name or id

    /.../.../UI/Search/SearchStoryboard.storyboard:53:106: warning: IBAction missing: cancelButton: is not implemented in SearchStoryboard.storyboard

    I saw this output and am thinking it can be improved by elaborate the view controller name or id. Something like:

    /.../.../UI/Search/SearchStoryboard.storyboard:53:106: warning: IBAction missing: cancelButton: is not implemented in SearchStoryboard.storyboard in Sub Genre View Controller Scene

    Thanks.

    opened by ethanhuang13 1
  • Add ability to disable reporting for selected classes

    Add ability to disable reporting for selected classes

    There are some issues that we won't be able to address, e.g. when a superclass's source isn't available but it already defines outlets or actions (see #21). For that case we should allow a user to pass a list of types that we should simply ignore, e.g.:

    ibanalyzer --ignored="MyView,SomeViewController ./
    
    opened by fastred 0
Releases(0.3.0)
Owner
Arek Holko
Arek Holko
Find memory leaks in your iOS app at develop time.

中文介绍 | FAQ中文 MLeaksFinder MLeaksFinder helps you find memory leaks in your iOS apps at develop time. It can automatically find leaks in UIView and UIV

Tencent 5.3k Dec 22, 2022
A library that enables dynamically rebinding symbols in Mach-O binaries running on iOS.

fishhook fishhook is a very simple library that enables dynamically rebinding symbols in Mach-O binaries running on iOS in the simulator and on device

Meta 4.9k Jan 8, 2023
Commit fully-formatted Objective-C as a team without even trying.

[ Space Commander] [ Space Commander] provides tools which enable a team of iOS developers to commit Objective-C code to a git repository using a unif

Square 1.1k Nov 17, 2022
An Xcode formatter plug-in to format your swift code.

Swimat Swimat is an Xcode plug-in to format your Swift code. Preview Installation There are three way to install. Install via homebrew-cask # Homebrew

Jintin 1.6k Jan 7, 2023
Asserts on roids, test all your assumptions with ease.

KZAsserts - Asserts on roids, test all your assumptions with ease. There are many ways in which we can improve quality of our code-base, Assertions ar

Krzysztof Zabłocki 101 Jul 1, 2022
An xcconfig (Xcode configuration) file for easily turning on a boatload of warnings in your project or its targets.

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

Peter Hosey 438 Nov 8, 2022
decoupling between modules in your iOS Project. iOS模块化过程中模块间解耦方案

DecouplingKit 中文readme Podfile platform :ios, '7.0' pod 'DecouplingKit', '~> 0.0.2' DecouplingKit, decoupling between modules in your iOS Project. D

coderyi 139 Aug 23, 2022
Skredvarsel app - an iOS, iPadOS, and macOS application that provides daily avalanche warnings from the Norwegian Avalanche Warning Service API

Skredvarsel (Avalanche warning) app is an iOS, iPadOS, and macOS application that provides daily avalanche warnings from the Norwegian Avalanche Warning Service API

Jonas Follesø 8 Dec 15, 2022
Simple iOS app blackbox assessment tool. Powered by frida.re and vuejs.

Discontinued Project This project has been discontinued. Please use the new Grapefruit #74 frida@14 compatibility issues frida@14 introduces lots of b

Chaitin Tech 1.6k Dec 16, 2022
In-app memory usage monitoring for iOS

What's Stats Stats displays load statuses such as the memory usage, the CPU load, and the number of subviews in-app, and in realtime. How to use Just

Shuichi Tsutsumi 170 Sep 18, 2022
Manipulates the undocumented interchange format for the Apple Notes app.

NotesArchive A Swift package for reading and writing an undocumented interchange format for the Apple Notes app in macOS 12 Monterey1. Enabling the De

Zachary Waldowski 7 Jul 5, 2022
A static source code analysis tool to improve quality and reduce defects for C, C++ and Objective-C

OCLint - https://oclint.org OCLint is a static code analysis tool for improving quality and reducing defects by inspecting C, C++ and Objective-C code

The OCLint Static Code Analysis Tool 3.6k Dec 29, 2022
Measure Swift code metrics and get reports in Xcode, Jenkins and other CI platforms.

Taylor ⚠️ Taylor is DEPRECATED. Use SwiftLint instead. A tool aimed to increase Swift code quality, by checking for conformance to code metrics. Taylo

YOPESO 301 Dec 24, 2022
A tool for Swift code modification intermediating between code generation and formatting.

swift-mod A tool for Swift code modification intermediating between code generation and formatting. Overview swift-mod is a tool for Swift code modifi

Ryo Aoyama 95 Nov 3, 2022
SwiftCop is a validation library fully written in Swift and inspired by the clarity of Ruby On Rails Active Record validations.

SwiftCop is a validation library fully written in Swift and inspired by the clarity of Ruby On Rails Active Record validations. Objective Build a stan

Andres Canal 542 Sep 17, 2022
A command-line tool and Xcode Extension for formatting Swift code

Table of Contents What? Why? How? Command-line tool Xcode source editor extension Xcode build phase Via Applescript VSCode plugin Sublime Text plugin

Nick Lockwood 6.3k Jan 8, 2023
A tool to enforce Swift style and conventions.

SwiftLint A tool to enforce Swift style and conventions, loosely based on the now archived GitHub Swift Style Guide. SwiftLint enforces the style guid

Realm 16.9k Jan 9, 2023
Cross-platform static analyzer and linter for Swift.

Wiki • Installation • Usage • Features • Developers • License Tailor is a cross-platform static analysis and lint tool for source code written in Appl

Sleekbyte 1.4k Dec 19, 2022
Trackable is a simple analytics integration helper library. It’s especially designed for easy and comfortable integration with existing projects.

Trackable Trackable is a simple analytics integration helper library. It’s especially designed for easy and comfortable integration with existing proj

Vojta Stavik 145 Apr 14, 2022