magicalpanda / MagicalRecord

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

NSFetchRequest could not locate an NSEntityDescription for entity name 'FRUser' #953

Open pranavss11 opened 9 years ago

pranavss11 commented 9 years ago

Hey guys,

I am currently trying to setup MagicalRecord 3.0 in my project (swift) but my app is crashing.

Here is my setup for Magical Record:

MagicalRecord.setupAutoMigratingStack()

My Model:

@objc(FRUser)
public class FRUser: NSManagedObject {
    @NSManaged var userID: String
}

The request that I'm making:

let user = FRUser.MR_findFirstByAttribute("userID", withValue:"12345")

Any thoughts on how I can fix this?

EDIT:

I've also tried adding this method to my FRUser class:

override public class func MR_entityName() -> String {
   return "FRUser"
}
tonyarnold commented 9 years ago

Can you post the full backtrace of the crash for me? Thanks.

pranavss11 commented 9 years ago

2015-02-10 10:05:57.795 xctest[16839:18252769] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSFetchRequest could not locate an NSEntityDescription for entity name 'FRUser''
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010b418f35 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010b0b1bb7 objc_exception_throw + 45
    2   CoreData                            0x000000010ed8f594 -[NSFetchRequest(_NSInternalMethods) _resolveEntityWithContext:] + 404
    3   CoreData                            0x000000010ed8e22a -[NSManagedObjectContext executeFetchRequest:error:] + 106
    4   MagicalRecord                       0x000000010ec6f5e2 __67+[NSManagedObject(MagicalRecord) MR_executeFetchRequest:inContext:]_block_invoke + 66
    5   CoreData                            0x000000010edd3f06 developerSubmittedBlockToNSManagedObjectContextPerform + 198
    6   CoreData                            0x000000010edd3de1 -[NSManagedObjectContext performBlockAndWait:] + 241
    7   MagicalRecord                       0x000000010ec6f432 +[NSManagedObject(MagicalRecord) MR_executeFetchRequest:inContext:] + 418
    8   MagicalRecord                       0x000000010ec6f91b +[NSManagedObject(MagicalRecord) MR_executeFetchRequestAndReturnFirstObject:inContext:] + 123
    9   MagicalRecord                       0x000000010ec6c673 +[NSManagedObject(MagicalFinders) MR_findFirstByAttribute:withValue:inContext:] + 179
    10  MagicalRecord                       0x000000010ec6c54d +[NSManagedObject(MagicalFinders) MR_findFirstByAttribute:withValue:] + 205
    11  Engine                       0x000000010ed3435f _TFC13Engine13DataManager14getCurrentUserfS0_FFTGSqCS_6FRUser_GSqCSo7NSError__T_T_ + 1087
    12  EngineTests                  0x000000010cbe3944 _TFFC18EngineTests17NetworkingTests13testUserLoginFS0_FT_T_U_FSbT_ + 164
    13  Engine                       0x000000010ed33478 _TFFC13Engine16SessionManager6signInFS0_FTSS8passwordSS8userTypeOS_8UserType17completionHandlerFSbT__T_U0_FTGSqCS_9Session_GSqCSo7NSError__T_ + 216
    14  Engine                       0x000000010ed33399 _TTRXFo_oGSqC13Engine9Session_oGSqCSo7NSError__dT__XFdCb_dGSqS0__dGSqS1___dT__ + 73
    15  Engine                       0x000000010ed2f33b _TTRXFdCb_dGSqC13Engine9Session_dGSqCSo7NSError__dT__XFo_oGSqS0__oGSqS1___dT__ + 43
    16  Engine                       0x000000010ed2f2eb _TFFC13Engine12SENetworking11loginFMS0_FTSS8passwordSS17completionHandlerFTGSqCS_9Session_GSqCSo7NSError__T__T_U_FTCSo12NSURLRequestGSqCSo17NSHTTPURLResponse_GSqS1__GSqS2___T_ + 123
    17  Engine                       0x000000010ed3ef81 _TFFE13EngineC9Alamofire7Request14responseObjectFDS1_US_26ResponseObjectSerializable__FFTCSo12NSURLRequestGSqCSo17NSHTTPURLResponse_GSqQ__GSqCSo7NSError__T_DS1_U0_FTS3_GSqS4__GSqPSs9AnyObject__GSqS5___T_ + 449
    18  Engine                       0x000000010ed3da8f _TPA__TFFE13EngineC9Alamofire7Request14responseObjectFDS1_US_26ResponseObjectSerializable__FFTCSo12NSURLRequestGSqCSo17NSHTTPURLResponse_GSqQ__GSqCSo7NSError__T_DS1_U0_FTS3_GSqS4__GSqPSs9AnyObject__GSqS5___T_ + 111
    19  Alamofire                           0x000000010eb07242 _TFFFC9Alamofire7Request8responseFDS0_FT5queueGSqCSo8NSObject_10serializerFTCSo12NSURLRequestGSqCSo17NSHTTPURLResponse_GSqCSo6NSData__TGSqPSs9AnyObject__GSqCSo7NSError__17completionHandlerFTS2_GSqS3__GSqPS5___GSqS6___T__DS0_U_FT_T_U_FT_T_ + 434
    20  Alamofire                           0x000000010eb05127 _TTRXFo__dT__XFdCb__dT__ + 39
    21  libdispatch.dylib                   0x000000010c68caf6 _dispatch_call_block_and_release + 12
    22  libdispatch.dylib                   0x000000010c6a6af4 _dispatch_client_callout + 8
    23  libdispatch.dylib                   0x000000010c692265 _dispatch_main_queue_callback_4CF + 490
    24  CoreFoundation                      0x000000010b380fe9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    25  CoreFoundation                      0x000000010b343eeb __CFRunLoopRun + 2043
    26  CoreFoundation                      0x000000010b343486 CFRunLoopRunSpecific + 470
    27  Foundation                          0x000000010ac6eb42 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 275
    28  XCTest                              0x000000010f134728 -[XCTestCase(AsynchronousTesting) waitForExpectationsWithTimeout:handler:] + 943
    29  EngineTests                  0x000000010cbe3096 _TFC18EngineTests17NetworkingTests13testUserLoginfS0_FT_T_ + 1542
    30  EngineTests                  0x000000010cbe31d2 _TToFC18EngineTests17NetworkingTests13testUserLoginfS0_FT_T_ + 34
    31  CoreFoundation                      0x000000010b310c8c __invoking___ + 140
    32  CoreFoundation                      0x000000010b310ae2 -[NSInvocation invoke] + 290
    33  XCTest                              0x000000010f1260f7 -[XCTestCase invokeTest] + 253
    34  XCTest                              0x000000010f1262f8 -[XCTestCase performTest:] + 150
    35  XCTest                              0x000000010f12fbf5 -[XCTest run] + 260
    36  XCTest                              0x000000010f124ffb -[XCTestSuite performTest:] + 379
    37  XCTest                              0x000000010f12fbf5 -[XCTest run] + 260
    38  XCTest                              0x000000010f124ffb -[XCTestSuite performTest:] + 379
    39  XCTest                              0x000000010f12fbf5 -[XCTest run] + 260
    40  XCTest                              0x000000010f124ffb -[XCTestSuite performTest:] + 379
    41  XCTest                              0x000000010f12fbf5 -[XCTest run] + 260
    42  XCTest                              0x000000010f1220bc __25-[XCTestDriver _runSuite]_block_invoke + 56
    43  XCTest                              0x000000010f12cead -[XCTestObservationCenter _observeTestExecutionForBlock:] + 162
    44  XCTest                              0x000000010f121ff0 -[XCTestDriver _runSuite] + 269
    45  XCTest                              0x000000010f122a1d -[XCTestDriver _checkForTestManager] + 234
    46  XCTest                              0x000000010f132af0 +[XCTestProbe runTests:] + 182
    47  xctest                              0x000000010ab9e196 xctest + 4502
    48  xctest                              0x000000010ab9e40d xctest + 5133
    49  xctest                              0x000000010ab9de13 xctest + 3603
    50  libdyld.dylib                       0x000000010c6d7145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
pranavss11 commented 9 years ago

Any ideas?

tonyarnold commented 9 years ago

Not really — this isn't specific to MagicalRecord. CoreData can't find your FRUser entity:

NSFetchRequest could not locate an NSEntityDescription for entity name 'FRUser'

I've honestly not tried to use MagicalRecord with Swift for anything more than very simple tests.