title: CoreData can't find mapping model in an OSX framework bundle, but works fine in iOS
body: <p>I have CoreData-based data layer (using a SQLite datastore) that I am using in both an iOS app and on the server that the iOS clients talk to.  The data layer (objc code + coredata model / mapping defns) is compiled into the iOS bundle as per usual, and is compiled into a Framework bundle for use on OSX.</p>
  
  <p>I am hitting a brick wall with default migration using mapping models.</p>
  
  <p>On iOS, it works fine.  The first time running the app in the simulator after adding the new datamodel verison, it migrates all the data when you call <code>addPersistentStoreWithType:configuration:...</code> as per the standard Apple docs.</p>
  
  <p>On OSX / PyObjC, it fails with <code>Persistent store migration failed, missing mapping model</code>, i.e. for some reason the mapping model .cdm file can't be found in that bundle even though it is present.</p>
  
  <p>If you manually specify the source / dest / mapping models by looking them up in the bundle and then manually invoke a migration through a NSMigrationManager, everything works fine, e.g.</p>
  
  <pre><code>bundle = objc.loadBundle( "MyApp_OSX", globals(),
                            os.path.join( base, FRAMEWORK_FILENAME ) )
  
  # URLs of input and output datastores
  datastoreURL = NSURL.fileURLWithPath_( datadir + "/MyApp.hsdb" )
  outURL = NSURL.fileURLWithPath_( datadir + "/MyApp-migrated.hsdb" )
  
  # URLs of old and new version MOMs and the mapping model
  momd = bundle.URLForResource_withExtension_( "MyApp.momd", None )
  url1 = momd.URLByAppendingPathComponent_( "MyApp 21.mom" )
  url2 = momd.URLByAppendingPathComponent_( "MyApp 22.mom" )
  mappingURL = bundle.URLForResource_withExtension_( "Test.cdm", None )
  
  # Old and new MOMs and the mapping model
  mom1 = NSManagedObjectModel.alloc().initWithContentsOfURL_( url1 )
  mom2 = NSManagedObjectModel.alloc().initWithContentsOfURL_( url2 )
  mm = NSMappingModel.alloc().initWithContentsOfURL_( mappingURL )
  
  # Do the migration    
  migration = NSMigrationManager.alloc().initWithSourceModel_destinationModel_( 
      mom1, mom2 )
  
  migration.migrateStoreFromURL_type_options_withMappingModel_toDestinationURL_destinationType_destinationOptions_error_(
      datastoreURL, NSSQLiteStoreType, None, mm, outURL, NSSQLiteStoreType, None, None )
  </code></pre>
  
  <p>At this point I have no idea why the iOS version is able to find the mapping model to successfully migrate the datastore but the OSX / PyObjC version can't, despite clearly having the mapping model in the bundle, and the mapping model apparently being valid since it works when you invoke it manually.</p>
  
  <p>Any insight into how CoreData searches for valid / appropriate mapping models in bundles that might help identify how to make this work on OSX would be much appreciated.</p>