MagicKit is an Objective-C file identification framework based on libmagic.
C Objective-C
Latest commit 5e2c4ba Feb 21, 2013 @aidansteele Merge pull request #7 from jmah/master
Error handling, and code reduction
Failed to load latest commit information.
MagicKit.xcodeproj Remove unused InfoPlist.strings Feb 10, 2013
GEMagicKit.h Implementing “+magicForFileAtURL:” and “+magicForFileAtURL:decompress:”. Oct 16, 2012
GEMagicResult.h Remove unnecessary MagicKitPrivate.h header Feb 10, 2013
Info.plist Initial commit. Oct 10, 2010
MagicKit.h Added MIT licence to source files. Clarified LICENCE file. Oct 22, 2010
MagicKit_Prefix.pch Initial commit. Oct 10, 2010
magic.mgc Updating libmagic to version 5.11. Oct 16, 2012



MagicKit.framework is an easy-to-use wrapper around the libmagic file identification library. It provides a high-level Objective-C interface and deals in Foundation types (NSString, NSData, et al).

MagicKit.framework is available for both OS X (as a framework) or iOS as a static library with header files. MagicKit.framework consists of a master class, GEMagicKit, and an intermediary class, GEMagicResult. The GEMagicKit master class has six class methods, listed below in descending order of convenience.

+ (GEMagicResult *)magicForFileAtPath:(NSString *)path;
+ (GEMagicResult *)magicForFileAtURL:(NSURL *)aURL;
+ (GEMagicResult *)magicForData:(NSData *)data;

+ (GEMagicResult *)magicForFileAtPath:(NSString *)path decompress:(BOOL)decompress;
+ (GEMagicResult *)magicForFileAtURL:(NSURL *)aURL decompress:(BOOL)decompress;
+ (GEMagicResult *)magicForData:(NSData *)data decompress:(BOOL)decompress;

These methods all return the GEMagicResult intermediary class. The GEMagicResult class has four properties. These are mimeType, description, uniformType and uniformTypeHierarchy. the first three properties are NSString objects, the final returns an NSArray object.

Example MIME types include:

  • application/xml; charset=us-ascii
  • video/x-msvideo; charset=binary

Or a textual description, respectively:

  • XML document text
  • RIFF (little-endian) data, AVI, 624 x 352, 23.98 fps, video: XviD, audio: MPEG-1 Layer 3 (stereo, 48000 Hz))

Finally, uniformType and uniformTypeHierarchy return Uniform Type Identifiers for the relevant file/data. The type hierarchy is an array of types that the given file conforms to.

GEMagicKit can also decompress compressed files and hence attempt to determine the contents within.

MagicKit.framework is MIT-licensed. libmagic is BSD-licensed.