• Stars
    star
    860
  • Rank 51,090 (Top 2 %)
  • Language
    Objective-C
  • License
    Other
  • Created over 13 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

[DEPRECATED]

WARNING: THIS PROJECT IS DEPRECATED

It will not receive any future updates or bug fixes. If you are using it, please migrate to another solution.


Purpose

iConsole is a simple, pluggable class to enable more useful in-app logging for your iPhone apps. It enables you to check error and crash logs within a built application without needing to connect to the Xcode debugger. It also allows non-technical beta testers of your applications to submit log information to you easily.

iConsole also serves another purpose: Using the command interface it provides an easy way to add debugging commands and let you toggle application features on and off at runtime in a way that can be easily disabled in the final release of your app, and doesn't require you to build additional throwaway user interface components.

Supported OS & SDK Versions

  • Supported build target - iOS 8.0 (Xcode 6.0, Apple LLVM compiler 6.0)
  • Earliest supported deployment target - iOS 5.0
  • Earliest compatible deployment target - iOS 4.3

NOTE: 'Supported' means that the library has been tested with this version. 'Compatible' means that the library should work on this OS version (i.e. it doesn't rely on any unavailable SDK features) but is no longer being tested for compatibility and may require tweaking or bug fixes to run correctly.

ARC Compatibility

As of version 1.5, iConsole requires ARC. If you wish to use iConsole in a non-ARC project, just add the -fobjc-arc compiler flag to the iConsole.m class file. To do this, go to the Build Phases tab in your target settings, open the Compile Sources group, double-click iConsole.m in the list and type -fobjc-arc into the popover.

If you wish to convert your whole project to ARC, comment out the #error line in iConsole.m, then run the Edit > Refactor > Convert to Objective-C ARC... tool in Xcode and make sure all files that you wish to use ARC for (including iConsole.m) are checked.

Installation

To install iConsole into your app, drag the iConsole and (optionally) GTM folder into your project. iConsole has no other dependencies. If you need to update the GTM classes, you can check out the latest version using:

svn checkout http://google-toolbox-for-mac.googlecode.com/svn/trunk/ google-toolbox-for-mac-read-only

To enable iConsole in your application, replace your main window with an instance of the iConsoleWindow. If you are using a standard project template, the easiest way to do this is to change the class of your window in the MainWindow.xib file, or the AppDelegate.m if your window is created programmatically. If you are already using a custom window subclass, change the base class to iConsoleWindow.

Logging

To log to the console from within your app, include the iConsole.h header in your class (or in your .pch file to make it available throughout your project), and then add logging code of the form:

[iConsole log:@"some message"];

The message can have format parameters, and follows the same syntax as the NSLog() command, and will log to both the in app and Xcode console. The iConsole logging commands are also thread safe and so can be used anywhere in place of NSLog().

In addition to the log: method, there are also the following additional log functions that can be use in conjunction with the LOG_LEVEL constant to easily control the amount of logging in a given app build:

[iConsole info:...]; // use for informational logs (e.g. object count)
[iConsole warn:...]; // use for warnings (e.g. low memory)
[iConsole error:...]; // use for errors (e.g. unexpected value)
[iConsole crash:...]; // use for logging conditions that lead to a crash

The console is shown/hidden using a screen swipe by default, but if that is not appropriate for your app, you can show and hide it programmatically using:

[iConsole show];
[iConsole hide];

The console has a button for clearing the log, but if you ever need to clear it programmatically then you can do so using the clear command:

[iConsole clear];

Command Interface

As well as displaying logs, the console can also allow user command input. This is disabled by default. To enable it, you need to create a command delegate, which you do as follows:

  1. Implement the iConsoleDelegate protocol on one of your classes. It doesn't matter which one, but it should be a persistent class that will exist for the duration of the app's lifetime, e.g. your app delegate or main view controller.

  2. Add the handleConsoleCommand: method to your delegate class. This receives a single string representing the command that the user has typed. iConsole does not place any restriction on the command syntax, or provide any helper methods for processing commands at this time.

  3. Use the following code to set your class as the delegate for the iConsole. Note that this code must be called BEFORE the console is first shown, or the input field will not appear:

    [iConsole sharedConsole].delegate = myDelegate;

For an example of how to implement this, look at the HelloWorld app.

Exception Handling

By default, iConsole intercepts unhandled exceptions (crashes) and deciphers the stack trace using the GTM library. You may wish to disable this feature if your app already implements a crash handler, or if you do not want to include GTM as a dependency. To do that, set one or both of these macros to 0:

ICONSOLE_ADD_EXCEPTION_HANDLER
ICONSOLE_USE_GOOGLE_STACK_TRACE

The GTM trace function provides a much more useful stack trace than the default iPhone SDK provides. It is recommended to enable this if you are using the ICONSOLE_ADD_EXCEPTION_HANDLER option. If the ICONSOLE_USE_GOOGLE_STACK_TRACE option is disabled, you can safely remove the GTM source files from the project.

Note: if the ICONSOLE_ADD_EXCEPTION_HANDLER option is disabled, you should call [[NSUserDefaults standardDefaults] synchronize] in your own crash handler to ensure that logs are preserved in the event of a crash.

Configuration

To configure iConsole, there are a number of properties of the iConsole class that can alter the behaviour and appearance of iConsole. These should be mostly self-explanatory, but they are documented below:

@property (nonatomic, assign) BOOL enabled;

Set this to 0 to disable the console. It is a good idea to set this using a compiler macro in your project target settings so it can be switched off in your release build.

@property (nonatomic, assign) iConsoleLogLevel logLevel;

Depending on your use of logging in the project, the log may fill up quickly. Use the log level to selectively disable logs based on severity. You can use the iConsoleLogLevel constants for this. iConsoleLogLevelNone will disable all logging. iConsoleLogLevelInfo will enable all logging levels.

@property (nonatomic, assign) BOOL saveLogToDisk;

If this option is disabled, logs will not be saved between sessions. Note that the ICONSOLE_ADD_EXCEPTION_HANDLER feature is useless if this option is not enabled.

@property (nonatomic, assign) NSUInteger maxLogItems;

Appending additional lines to the log has a small performance cost. The larger the log gets, the greater this performance impact. For this reason, the maximum size of the log is limited to 1000 lines. You can increase or decrease this limit by settings this property.

@property (nonatomic, weak) id<iConsoleDelegate> delegate;

This property is used to set the delegate for implementing the console command interface.

@property (nonatomic, assign) NSUInteger simulatorTouchesToShow;
@property (nonatomic, assign) NSUInteger deviceTouchesToShow;

The number of fingers needed for the consoleactivation swipe. More than three is difficult to pull off on an iPhone unless you have very small fingers. More than two is impossible to execute in the simulator. If your app makes use of two or three fingered swipes for other interactions you may wish to increase this however. If you do not wish to allow swipe activation of the console, set the touches count to 0 or some infeasibly large number. The default is 2 fingers on the simulator and 3 on the device.

@property (nonatomic, assign) BOOL simulatorShakeToShow;
@property (nonatomic, assign) BOOL deviceShakeToShow;

If swiping is not an appropriate activation method in your app, you can optionally enable shake-to-show instead. This is certainly a less fiddly option in the simulator, but may already be used for another purpose in your app. By default, this feature is enabled on the simulator and disabled on the device.

@property (nonatomic, copy) NSString *infoString;

The text that appears at the top of the console. This contains the Charcoal Design copyright by default, but you are permitted to remove the iConsole name and change this to reflect your own company branding, as long as you do not add your own copyright, or otherwise imply that iConsole is your own work.

@property (nonatomic, copy) NSString *inputPlaceholderString;

Helper text that appears in the console input field.

@property (nonatomic, copy) NSString *logSubmissionEmail;

The default "to" address when sending console logs via email from within the app (blank by default).

@property (nonatomic, strong) UIColor *backgroundColor;

The background color for the console (black by default).

@property (nonatomic, strong) UIColor *textColor;

The color of the console text and action button icon (white by default).

Release notes

Version 1.5.3

  • Quick fixes for iOS 8
  • Added va_list method version for Swift compatibility
  • Added Swift example project
  • Known issue: only supports portrait mode on iOS 8

Version 1.5.2

  • Fixed problem with swipe gestures after displaying console
  • Added ability to specify scrollbar color

Version 1.5.1

  • Fixed problem when emailing log if app name contains a space

Version 1.5

  • Now requires ARC (see README for details)
  • Now correctly URL-encodes log when sending via email
  • Fixed rotation issue
  • Added podspec file

Version 1.4.1

  • Fixed crash when inserting first log

Version 1.4

  • iConsole now uses properties for configuration instead of macros
  • Updated GTMlibrary to latest version, which fixes analyzer warnings
  • Console action button now uses more intuitive icon

Version 1.3

  • Updated project structure
  • Added ARC support

Version 1.2

  • Fixed swipe direction when device is rotated
  • Added instruction text to HelloWorld screen

Version 1.1

  • Added shake-to-show option
  • Fully tested on iPad
  • Logging is now thread safe
  • Fixed issue with pressing info button when keyboard is open
  • Correctly handles interface rotation
  • Correctly handles in-call status bar
  • Fixed bug when console exceeds max rows

Version 1.0

  • Initial release.

More Repositories

1

iCarousel

A simple, highly customisable, data-driven 3D carousel for iOS and Mac OS
Objective-C
11,991
star
2

SwiftFormat

A command-line tool and Xcode Extension for formatting Swift code
Swift
7,417
star
3

FXBlurView

[DEPRECATED]
Objective-C
4,941
star
4

iRate

[DEPRECATED]
Objective-C
4,114
star
5

FXForms

[DEPRECATED]
Objective-C
2,929
star
6

SwipeView

SwipeView is a class designed to simplify the implementation of horizontal, paged scrolling views on iOS. It is based on a UIScrollView, but adds convenient functionality such as a UITableView-style dataSource/delegate interface for loading views dynamically, and efficient view loading, unloading and recycling.
Objective-C
2,648
star
7

layout

A declarative UI framework for iOS
Swift
2,222
star
8

iVersion

[DEPRECATED]
Objective-C
1,955
star
9

NullSafe

NullSafe is a simple category on NSNull that returns nil for unrecognised messages instead of throwing an exception
Objective-C
1,941
star
10

RetroRampage

Tutorial series demonstrating how to build a retro first-person shooter from scratch in Swift
Swift
1,454
star
11

XMLDictionary

[DEPRECATED]
Objective-C
1,139
star
12

AutoCoding

AutoCoding is a category on NSObject that provides automatic support for NSCoding and NSCopying to every object.
Objective-C
1,067
star
13

GZIP

A simple NSData category for gzipping/unzipping data in iOS and Mac OS
Objective-C
980
star
14

FastCoding

A faster and more flexible binary file format replacement for NSCoding, Property Lists and JSON
C
975
star
15

AsyncImageView

[DEPRECATED]
Objective-C
908
star
16

FXLabel

[DEPRECATED]
Objective-C
817
star
17

Expression

A cross-platform Swift library for evaluating mathematical expressions at runtime
Swift
803
star
18

CountryPicker

CountryPicker is a custom UIPickerView subclass that provides an iOS control allowing a user to select a country from a list. It can optionally display a flag next to each country name, and the library includes a set of 249 high-quality, public domain flag images from FAMFAMFAM (http://www.famfamfam.com/lab/icons/flags/) that have been painstakingly re-named by country code to work with the library.
Objective-C
738
star
19

SoundManager

Simple sound and music player class for playing audio on Mac and iPhone
Objective-C
631
star
20

FXImageView

FXImageView is a class designed to simplify the application of common visual effects such as reflections and drop-shadows to images, and also to help the performance of image loading by handling it on a background thread.
Objective-C
629
star
21

Euclid

A Swift library for creating and manipulating 3D geometry
Swift
606
star
22

Base64

[DEPRECATED]
Objective-C
578
star
23

FXKeychain

[DEPRECATED]
Objective-C
556
star
24

MustOverride

Provides a macro that you can use to ensure that a method of an abstract base class *must* be overriden by its subclasses.
Objective-C
524
star
25

LayerSprites

LayerSprites is a library designed to simplify the use of sprite sheets (image maps containing multiple sub-images) in UIKit applications without using OpenGL or 3rd-party game libraries. Can load sprite sheets in the Coco2D format.
Objective-C
505
star
26

GLView

[DEPRECATED]
Objective-C
474
star
27

FXNotifications

An alternative API for NSNotificationCenter that doesn't suck
Objective-C
391
star
28

ShapeScript

The ShapeScript 3D modeling app for macOS and iOS
Swift
383
star
29

VectorMath

A Swift library for Mac and iOS that implements common 2D and 3D vector and matrix functions, useful for games or vector-based graphics
Swift
364
star
30

ReflectionView

[DEPRECATED]
Objective-C
360
star
31

Swiftenstein

Simple Wolfenstein 3D clone written in Swift
Swift
357
star
32

LRUCache

LRUCache is an open-source replacement for NSCache that behaves in a predictable, debuggable way
Swift
353
star
33

JPNG

JPNG is a bespoke image file format that combines the compression benefits of JPEG with the alpha channel support of a PNG file. The JPNG library provides an Objective-C implementation of this format along with transparent JPNG loading support for iOS and Mac OS.
Objective-C
338
star
34

StandardPaths

StandardPaths is a category on NSFileManager for simplifying access to standard application directories on iOS and Mac OS and abstracting the iCloud backup flags on iOS. It also provides support for working with device-specific file suffixes, such as the @2x suffix for Retina displays, or the -568h suffix for iPhone 5 and can optionally swizzle certain UIKit methods to support these suffixes more consistently.
Objective-C
337
star
35

ViewUtils

ViewUtils is a collection of category methods designed that extend UIView with all the handy little properties and functionality that you always wished were built-in to begin with.
Objective-C
325
star
36

FXPageControl

Simple, drop-in replacement for the iPhone UIPageControl that allows customisation of the dot colour, size and spacing.
Objective-C
298
star
37

BaseModel

BaseModel provides a base class for building model objects for your iOS or Mac OS projects. It saves you the hassle of writing boilerplate code, and encourages good practices by reducing the incentive to cut corners in your model implementation.
Objective-C
288
star
38

OrderedDictionary

This library provides OrderedDictionary and MutableOrderedDictionary subclasses.
Objective-C
277
star
39

ColorUtils

[DEPRECATED]
Objective-C
257
star
40

Tribute

A command-line tool for tracking Swift project licenses
Swift
246
star
41

OSNavigationController

[DEPRECATED]
Objective-C
234
star
42

iNotify

[DEPRECATED]
Objective-C
226
star
43

Consumer

Mac and iOS library for parsing structured text
Swift
224
star
44

FPSControls

An experimental implementation of touch-friendly first-person shooter controls using SceneKit and Swift
Swift
216
star
45

OSCache

OSCache is an open-source re-implementation of NSCache that behaves in a predictable, debuggable way.
Objective-C
200
star
46

RequestQueue

[DEPRECATED]
Objective-C
175
star
47

FXReachability

Lightweight reachability class for Mac and iOS
Objective-C
173
star
48

Chess

A simple Chess game for iOS, written in Swift
Swift
171
star
49

Sprinter

A library for formatting strings on iOS and macOS
Swift
166
star
50

CryptoCoding

CryptoCoding is a superset of the NSCoding protocol that allows for simple, seamless AES encryption of any NSCoding-compatible object.
Objective-C
148
star
51

RequestUtils

A collection of category methods designed to simplify the process of HTTP request construction and manipulation in Cocoa.
Objective-C
142
star
52

CubeController

CubeController is a UIViewController subclass that can be used to create a rotating 3D cube navigation.
Objective-C
142
star
53

HTMLLabel

[DEPRECATED]
Objective-C
139
star
54

NSOperationStack

[DEPRECATED]
Objective-C
117
star
55

SVGPath

Cross-platform Swift library for parsing SVGPath strings
Swift
105
star
56

HRCoder

HRCoder is a replacement for the NSKeyedArchiver and NSKeyedUnarchiver classes that uses a human-readable/editable format that can easily be stored in a regular Plist or JSON file.
Objective-C
104
star
57

iPrompt

[DEPRECATED]
Objective-C
99
star
58

Presentations

Code samples and projects for presentations that I have given
Objective-C
99
star
59

FXPhotoEditView

[DEPRECATED]
Objective-C
92
star
60

StackView

StackView is a class designed to simplify the implementation of vertical stacks of views on iOS. You can think of it as a bit like a simplified version of UITableView.
Objective-C
73
star
61

WebContentView

[DEPRECATED]
Objective-C
69
star
62

StringCoding

StringCoding is a simple Mac/iOS library for setting object properties of any type using string values. It can automatically detect the property type and attempt to interpret the string as the right kind of value. It's particularly oriented towards iOS app theming (see README for details).
Objective-C
57
star
63

ArrayUtils

[DEPRECATED]
Objective-C
50
star
64

Swune

Swift/UIKit reimplementation of the Dune II RTS game
Swift
46
star
65

Parsing

Supporting code for my talk entitled "Parsing Formal Languages with Swift"
Swift
42
star
66

MACAddress

[DEPRECATED]
Objective-C
39
star
67

RotateView

Objective-C
35
star
68

FXParser

[DEPRECATED]
Objective-C
34
star
69

RandomSequence

A class for creating independent, repeatable pseudorandom number sequences on Mac and iOS
Objective-C
28
star
70

FloatyBalloon

This is the source code for a simple game called Floaty Balloon, based on the gameplay of Flappy Bird. It was created as a tutorial for http://iosdevelopertips.com
Objective-C
25
star
71

Concurrency

Full source code for a simple currency calculator app
Objective-C
15
star
72

FXJSON

[DEPRECATED]
Objective-C
15
star
73

PNGvsJPEG

This is a simple benchmark app to compare JPEG vs PNG loading performance on iOS. Spoiler: JPEG wins.
Objective-C
6
star