Adding MagicalRecord to your project is simple: Just choose whichever method you're most comfortable with and follow the instructions below.
The easiest way to integrate MagicalRecord in your project is to use CocoaPods:
-
Add the following line to your
Podfile
:pod "MagicalRecord"
If you are planing to use Shorthand Category Methods (see below) then add this line instead:
pod "MagicalRecord/Shorthand"
-
In your project directory, run
pod update
-
You should now be able to add
#import <MagicalRecord/CoreData+MagicalRecord.h>
to any of your target's source files and begin using MagicalRecord!
Xcode sub-projects allow your project to use and build MagicalRecord as an implicit dependency.
-
Add MagicalRecord to your project as a Git submodule:
$ cd MyXcodeProjectFolder $ git submodule add https://github.com/magicalpanda/MagicalRecord.git Vendor/MagicalRecord $ git commit -m "Add MagicalRecord submodule"
-
Drag
Vendor/MagicalRecord/MagicalRecord.xcproj
into your existing Xcode project -
Navigate to your project's settings, then select the target you wish to add MagicalRecord to
-
Navigate to Build Phases and expand the Link Binary With Libraries section
-
Click the + and find the version of MagicalRecord appropriate to your target's platform (
libMagicalRecord-iOS.a
for iOS,libMagicalRecord-OSX.dylib
for OS X) -
Navigate to Build Settings, then search for Header Search Paths and double-click it to edit
-
Add a new item using +:
"$(SRCROOT)/Vendor/MagicalRecord/MagicalRecord"
and ensure that it is set to recursive -
You should now be able to add
#import "CoreData+MagicalRecord.h"
to any of your target's source files and begin using MagicalRecord!
Note Please be aware that if you've set Xcode's Link Frameworks Automatically to No then you may need to add the CoreData.framework to your project on iOS, as UIKit does not include Core Data by default. On OS X, Cocoa includes Core Data.
If you don't want to use CocoaPods or use an Xcode subproject, you can add MagicalRecord's source directly to your project.
-
Add MagicalRecord to your project as a Git submodule
$ cd MyXcodeProjectFolder $ git submodule add https://github.com/magicalpanda/MagicalRecord.git Vendor/MagicalRecord $ git commit -m "Add MagicalRecord submodule"
-
Drag
Vendor/MagicalRecord/MagicalRecord
into your Xcode project, and ensure that you add it to the targets that you wish to use it with. -
You should now be able to add
#import "CoreData+MagicalRecord.h"
to any of your target's source files and begin using MagicalRecord!
Note Please be aware that if you've set Xcode's Link Frameworks Automatically to No then you may need to add the CoreData.framework to your project on iOS, as UIKit does not include Core Data by default. On OS X, Cocoa includes Core Data.
By default, all of the category methods that MagicalRecord provides are prefixed with MR_
. This is inline with Apple's recommendation not to create unadorned category methods to avoid naming clashes.
If you're prepared to take the risk, and prefer the shorter method names you can do so by following setting the MR_SHORTHAND variable before the first time you import MagicalRecord's header into your project:
#define MR_SHORTHAND 1
#import "CoreData+MagicalRecord.h"
Please note that we do not offer support for this feature. If it doesn't work, please file an issue and we'll fix it when we can.