Adding MagicalRecord to your project is simple: Just choose whichever method you're most comfortable with and follow the instructions below.
-
Add the following line to your
Cartfile
:github "MagicalPanda/MagicalRecord"
-
Run
carthage update
in your project directory. -
Drag the appropriate
MagicalRecord.framework
for your platform (located in `Carthage/Build/``) into your application’s Xcode project, and add it to the appropriate target(s).
One of the easiest ways to integrate MagicalRecord in your project is to use CocoaPods:
-
Add the following line to your
Podfile
:a. Plain
pod 'MagicalRecord', :git => 'https://github.com/magicalpanda/MagicalRecord'
b. With CocoaLumberjack as Logger
pod 'MagicalRecord/CocoaLumberjack', :git => 'https://github.com/magicalpanda/MagicalRecord'
-
In your project directory, run
pod update
-
You should now be able to add
#import <MagicalRecord/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 the MagicalRecord framework appropriate to your target's platform
-
You should now be able to add
#import <MagicalRecord/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 like, you can include the following headers to use shorter, non-prefixed category methods:
// Objective-C
#import <MagicalRecord/MagicalRecord.h>
#import <MagicalRecord/MagicalRecord+ShorthandMethods.h>
#import <MagicalRecord/MagicalRecordShorthandMethodAliases.h>
// Swift
import MagicalRecord
If you're using Swift, you'll need to add these imports to your target's Objective-C bridging header.
Once you've included the headers, you should call the +[MagicalRecord enableShorthandMethods]
class method before you setup/use MagicalRecord:
// Objective-C
- (void)theMethodWhereYouSetupMagicalRecord
{
[MagicalRecord enableShorthandMethods];
// Setup MagicalRecord as per usual
}
// Swift
func theMethodWhereYouSetupMagicalRecord() {
MagicalRecord.enableShorthandMethods()
// Setup MagicalRecord as per usual
}
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.