Commit 1b5b9bfe by Brent Gulanowski

Use a resources bundle to store the data model in CocoaPods.

parent 52ed7a2f
......@@ -39,6 +39,11 @@ NSString * const BUYDeliveryRangeTransformerName = @"BUYDeliveryRange";
NSString * const BUYFlatArrayTransformerName = @"BUYFlatArray";
NSString * const BUYProductTagsTransformerName = @"BUYProductTags";
@interface NSBundle (BUYAdditions)
+ (instancetype)frameworkBundle;
+ (instancetype)resourcesBundle;
@end
@interface BUYModelManager ()
@property (nonatomic, strong) NSManagedObjectModel *model;
@end
......@@ -57,7 +62,7 @@ NSString * const BUYProductTagsTransformerName = @"BUYProductTags";
- (instancetype)init
{
return [self initWithManagedObjectModel:[NSManagedObjectModel mergedModelFromBundles:@[[NSBundle bundleForClass:[self class]]]]];
return [self initWithManagedObjectModel:[NSManagedObjectModel mergedModelFromBundles:@[[NSBundle resourcesBundle]]]];
}
- (instancetype)initWithManagedObjectModel:(NSManagedObjectModel *)model
......@@ -120,3 +125,26 @@ NSString * const BUYProductTagsTransformerName = @"BUYProductTags";
}
@end
@implementation NSBundle (BUYAdditions)
+ (instancetype)frameworkBundle
{
return [NSBundle bundleForClass:[BUYModelManager class]];
}
+ (NSURL *)resourcesBundleURL
{
return [[self frameworkBundle] URLForResource:@"Buy" withExtension:@"bundle"];
}
+ (instancetype)resourcesBundle
{
#if COCOAPODS
return [NSBundle bundleWithURL:[self resourcesBundleURL]];
#else
return [self frameworkBundle];
#endif
}
@end
......@@ -7,11 +7,12 @@ Pod::Spec.new do |s|
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = 'Shopify Inc.'
s.platform = :ios, '8.0'
s.resource_bundles = { 'Buy' => 'Mobile Buy SDK/Mobile Buy SDK/Models/Mobile Buy SDK.xcdatamodeld' }
s.source = { :git => 'https://github.com/Shopify/mobile-buy-sdk-ios.git', :tag => s.version }
s.source_files = 'Mobile Buy SDK/Mobile Buy SDK/**/*.{h,m,mm}'
s.public_header_files = 'Mobile Buy SDK/Mobile Buy SDK/Buy.h', 'Mobile Buy SDK/Mobile Buy SDK/**/*.h'
s.header_dir = 'Buy'
s.module_name = 'Buy'
s.header_dir = 'Buy'
s.module_name = 'Buy'
s.frameworks = 'PassKit'
s.libraries = 'c++'
s.requires_arc = true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment