magicalpanda / MagicalRecord

Super Awesome Easy Fetching for Core Data!
Other
10.79k stars 1.79k forks source link

Using 3.0 branch in my project #672

Closed koenvanderdrift closed 10 years ago

koenvanderdrift commented 10 years ago

With MR 2.2, I dragged the MR folder inside the main folder into my project With the newer 3.0 branch, there is no longer such a folder, instead there now is a Library folder. If I drag that one into my project, I get lots of compiler errors for missing MagicalRecord components. If I drag the complete MR folder into my project, same thing.

The Install docs still have the instructions for 2.2.

How I can I try the 3.0 branch in my project?

casademora commented 10 years ago

Drag the project in your current project as a subproject. From there, you’ll need to add the libMagicaRecord.a static library into your linker step if Xcode doesn’t already do that for you. You may also have to set the -ObjC and -all_load flags to have all the categories in MagicalRecord be available for you. After that, you should be ok to continue as before, namely, import the CoreData+MagicalRecord header file and get started.

Saul Mora

koenvanderdrift commented 10 years ago

Thanks Saul. Unfortunately it's not working yet, it looks like the MR libs are not compiling, see the screenshots attached.

screen shot 2014-02-13 at 11 53 13 am screen shot 2014-02-13 at 10 52 33 am

casademora commented 10 years ago

Ah yes, you need to set your header search paths to “<SRCROOT/path/to/magicalrecord>/Library/**” Give that a try.

koenvanderdrift commented 10 years ago

Still no luck :(

screen shot 2014-02-13 at 12 07 14 pm

Maybe this is a clue, the scheme for libMagicalRecord-iOS is missing:

screen shot 2014-02-13 at 12 08 53 pm

koenvanderdrift commented 10 years ago

OK, it's working now, I had to add the scheme manually.

Edit: I spoke too early. The static lib is compiling now, but I still get the compile errors.

koenvanderdrift commented 10 years ago

I went back to Xcode 5.0, and now I see a bunch of 'ARC Semantic Issue' errors:

screen shot 2014-02-15 at 12 52 49 pm

screen shot 2014-02-15 at 12 53 07 pm

Interestingly if I use MR 2.2, I also see 'ARC Semantic Issue' errors, with the exclamation mark in the red circle, but the project nevertheless compiles without an error.

tonyarnold commented 10 years ago

Can you try again with the latest code in release/3.0? I've put a lot of work into tidying things up this last few weeks.

koenvanderdrift commented 10 years ago

I added the MR project file into my project, and added the static library to my build phase. I get the following error:

'CoreData+MagicalRecord.h' file not found

On Apr 8, 2014, at 9:44 AM, Tony Arnold notifications@github.com wrote:

Can you try again with the latest code in release/3.0? I've put a lot of work into tidying things up this last few weeks.

— Reply to this email directly or view it on GitHub.

tonyarnold commented 10 years ago

It's just "MagicalRecord.h" now. We're still updating the docs.

koenvanderdrift commented 10 years ago

Getting these errors now:

/Users/koen/Documents/Development/Projects/FrameWorks/MagicalRecord/Library/Categories/CoreData/NSManagedObjectContext/NSManagedObjectContext+MagicalObserving.m:90:59: No visible @interface for 'NSManagedObjectContext' declares the selector 'isEqualTo:'

/Users/koen/Documents/Development/Projects/iOS/InDigestion/InDigestion/IDAppDelegate.m:58:20: No known class method for selector 'setupCoreDataStackWithStoreNamed:'

/Users/koen/Documents/Development/Projects/iOS/InDigestion/InDigestion/IDAppDelegate.m:91:30: No known class method for selector 'MR_defaultContext'

/Users/koen/Documents/Development/Projects/iOS/InDigestion/InDigestion/IDSearchResultViewController.m:319:20: No known class method for selector 'saveWithBlock:completion:'

On Apr 8, 2014, at 6:27 PM, Tony Arnold notifications@github.com wrote:

It's just "MagicalRecord.h" now. We're still updating the docs.

— Reply to this email directly or view it on GitHub.

tonyarnold commented 10 years ago

Please try a fresh checkout — that use of isEqualTo: wasn't valid, so I've replaced it with isEqual:.

As for the other errors, can you share the code from your project that the errors are referring to?

koenvanderdrift commented 10 years ago

Here's some code:

` [MagicalRecord setupCoreDataStackWithStoreNamed: kIDStoreName];

[[NSManagedObjectContext MR_defaultContext] MR_saveToPersistentStoreAndWait];

self.fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest: fetchRequest
                                                                    managedObjectContext: [NSManagedObjectContext MR_defaultContext]
                                                                      sectionNameKeyPath: nil
                                                                               cacheName: nil];

`

tonyarnold commented 10 years ago

OK, so a lot has changed in MagicalRecord 3.0 — we're rewriting the docs at the moment, but your code needs to be updated. I've started writing a "Concepts" guide for MagicalRecord 3.0, but not a 2.x to 3.x migration guide yet.

It might be best if you wait until we've finished the first round of changes to the documentation.

So your code would look more like:

ClassicSQLiteMagicalRecordStack *defaultStack = 
[ClassicSQLiteMagicalRecordStack stackWithStoreNamed:kIDStoreName];

[MagicalRecordStack setDefaultStack:defaultStack];

NSManagedObjectContext *defaultContext = 
[[MagicalRecordStack defaultStack] context];

[defaultContext MR_saveToPersistentStoreAndWait];

self.fetchedResultsController = 
[[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
                                    managedObjectContext:defaultContext
                                      sectionNameKeyPath:nil
                                               cacheName:nil];
koenvanderdrift commented 10 years ago

Sounds good. I made a branch for MR 3.0 on my project where I can do some testing with the code examples you provided. I'll post back here later with my progress.

On Tue, Apr 8, 2014 at 7:36 PM, Tony Arnold notifications@github.comwrote:

OK, so a lot has changed in MagicalRecord 3.0 — we're rewriting the docs at the moment, but your code needs to be updated. I've started writing a "Concepts" guide for MagicalRecord 3.0 http://wiki/MagicalRecord-3:-Concepts, but not a 2.x to 3.x migration guide yet.

It might be best if you wait until we've finished the first round of changes to the documentation.

— Reply to this email directly or view it on GitHubhttps://github.com/magicalpanda/MagicalRecord/issues/672#issuecomment-39914394 .

tonyarnold commented 10 years ago

No problems. I'll close this issue for now — feel free to re-open it if you feel the issue needs to be further addressed (we have separate issues for documentation and the change log already filed. Thanks!

koenvanderdrift commented 10 years ago

Made good progress and all the changes, except for [MagicalRecord saveWithBlock: ^(NSManagedObjectContext *localContext). What's the MR 3.0 replacement for that method?

tonyarnold commented 10 years ago
[[MagicalRecordStack defaultStack] saveWithBlock:^(NSManagedObjectContext *localContext) { 
    // … 
}];

You can replace [MagicalRecordStack defaultStack] with an instance of the stack.