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"; ...@@ -39,6 +39,11 @@ NSString * const BUYDeliveryRangeTransformerName = @"BUYDeliveryRange";
NSString * const BUYFlatArrayTransformerName = @"BUYFlatArray"; NSString * const BUYFlatArrayTransformerName = @"BUYFlatArray";
NSString * const BUYProductTagsTransformerName = @"BUYProductTags"; NSString * const BUYProductTagsTransformerName = @"BUYProductTags";
@interface NSBundle (BUYAdditions)
+ (instancetype)frameworkBundle;
+ (instancetype)resourcesBundle;
@end
@interface BUYModelManager () @interface BUYModelManager ()
@property (nonatomic, strong) NSManagedObjectModel *model; @property (nonatomic, strong) NSManagedObjectModel *model;
@end @end
...@@ -57,7 +62,7 @@ NSString * const BUYProductTagsTransformerName = @"BUYProductTags"; ...@@ -57,7 +62,7 @@ NSString * const BUYProductTagsTransformerName = @"BUYProductTags";
- (instancetype)init - (instancetype)init
{ {
return [self initWithManagedObjectModel:[NSManagedObjectModel mergedModelFromBundles:@[[NSBundle bundleForClass:[self class]]]]]; return [self initWithManagedObjectModel:[NSManagedObjectModel mergedModelFromBundles:@[[NSBundle resourcesBundle]]]];
} }
- (instancetype)initWithManagedObjectModel:(NSManagedObjectModel *)model - (instancetype)initWithManagedObjectModel:(NSManagedObjectModel *)model
...@@ -120,3 +125,26 @@ NSString * const BUYProductTagsTransformerName = @"BUYProductTags"; ...@@ -120,3 +125,26 @@ NSString * const BUYProductTagsTransformerName = @"BUYProductTags";
} }
@end @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,6 +7,7 @@ Pod::Spec.new do |s| ...@@ -7,6 +7,7 @@ Pod::Spec.new do |s|
s.license = { :type => 'MIT', :file => 'LICENSE' } s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = 'Shopify Inc.' s.author = 'Shopify Inc.'
s.platform = :ios, '8.0' 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 = { :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.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.public_header_files = 'Mobile Buy SDK/Mobile Buy SDK/Buy.h', 'Mobile Buy SDK/Mobile Buy SDK/**/*.h'
......
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