Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

+[NSManagedObjectModel setDefaultManagedObjectModel:]: unrecognized selector #665

Closed
samirGT opened this issue Feb 6, 2014 · 7 comments
Closed

Comments

@samirGT
Copy link

samirGT commented Feb 6, 2014

Hello,

I've been implementing a custom static framework for iOS and i have integrated the MagicalRecord library to my framework, everything was working well until my recent pod update ( today). Here is the MagicalRecord setup code

#pragma mark - Core Data stack
+ (void)setupCoreData {
    //1  Locate my-sdk.bundle (the bundle in the framework)
    NSString *mainBundlePath = [[NSBundle mainBundle] resourcePath];
    NSString *frameworkBundlePath = [mainBundlePath stringByAppendingPathComponent:@"my-sdk.bundle"];
    NSBundle *frameworkBundle = [NSBundle bundleWithPath:frameworkBundlePath];
    
    //2 Create an NSManagedObject Model by merging all models from the project and your framework. This simplifies saving as you can use a single persistent store coordinator to save a single managed object model.
    NSArray *bundles = [NSArray arrayWithObjects:[NSBundle mainBundle], frameworkBundle, nil];
    NSManagedObjectModel *models = [NSManagedObjectModel mergedModelFromBundles:bundles];
    
    [MagicalRecord setShouldAutoCreateManagedObjectModel:YES];
        [MagicalRecord setShouldDeleteStoreOnModelMismatch:NO];
    [NSManagedObjectModel setDefaultManagedObjectModel:models];
    
    
    // CoreData init with MagicalRecord
    NSURL *urlToStore = [[UserData applicationDocumentsDirectoryURL] URLByAppendingPathComponent:@"myName.sqlite"];
    
    // Note: we want the SQLite store in directory Documents/
    // we use NSURL instead of NSString to force our path instead of a default one in Library/Application Support/
    // To prevent a warning of incompatible type we cast to (id)
    [MagicalRecord setupCoreDataStackWithAutoMigratingSqliteStoreNamed:(id)urlToStore];
}

And to import the ShortHand categorie i am doing in .pch :

#define MR_SHORTHAND
#import 

it seems that MagicalAggregationShortHand is not imported :

+[NSManagedObjectModel setDefaultManagedObjectModel:]: unrecognized selector
@peterwilli
Copy link

I've got this lately too with other errors:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[MissingRelation deleteAllMatchingPredicate:]: unrecognized selector sent to class 0x73813c'

@casademora
Copy link
Member

There should be a new podspec up on the repo. Try a ‘pod update’ command to download the updates.

@vasyares
Copy link

vasyares commented Feb 6, 2014

I found problem in Pods-MagicalRecord-prefix.pch
After pod install I lost #define MR_SHORTHAND

file must be like this

#ifdef __OBJC__
#import <UIKit/UIKit.h>
#endif

#import "Pods-environment.h"
#ifdef __OBJC__
#define MR_SHORTHAND
#import "CoreData+MagicalRecord.h"
#endif

@donskifarrell
Copy link

Thanks, adding #define MR_SHORTHAND to Pods-MagicalRecord-prefix.pch worked for me also.

Suspect the issue stems from this pull request: CocoaPods/Specs#7699

@keith
Copy link

keith commented Feb 6, 2014

That pull request adds a subspec that you can use for the defines. We did this so the shorthand syntax wouldn't be enabled by default. You can now use MagicalRecord/Shorthand in your Podfile

@samirGT
Copy link
Author

samirGT commented Feb 7, 2014

@Keithbsmiley +1 . Thanks

@naterock101
Copy link

its also important to have the "-ObjC" flag in your projects other linker flags

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants