How to load resources on a test target when using resource_bundles. #1989

Closed
bilby91 opened this Issue Mar 31, 2014 · 2 comments

Projects

None yet

3 participants

bilby91 commented Mar 31, 2014

Im using cocoapods for managing a private library im working on. Currently i have a subspec with all my models, including the .xcdatamodel file for core data modeling. My podspec file looks like this.

  s.subspec 'Data' do |ds|
            ...
            ds.resource_bundle   = { :DataKit => '/Data/Schema/App.xcdatamodeld' }
            ...
        end 

When i need to access my .xcdatamodel y look up for my DataKit bundle.

For example

    NSURL *url                               = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/DataKit.bundle",[[NSBundle mainBundle] resourcePath]]];
    NSBundle *dataBundle                     = [NSBundle bundleWithURL:url];
    NSManagedObjectModel *managedObjectModel = [NSManagedObjectModel mergedModelFromBundles:@[dataBundle]];

The problem i'm having is the i need to test some code in the Data subspec, so, when i run the tests there is no DataKit bundle. I wouldn't like to add conditional code for loading the bundle depending if im testing or not.

Owner

-[NSBundle bundleForClass:]?

Contributor
kylef commented Sep 14, 2014

Closing for #2462.

@kylef kylef closed this Sep 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment