Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Own CocoaPods Pod Core Data file can't be accessed

I created my own CocoaPods Pod to use for my apps internally. This Pod should also use Core Data. I added my file xy.xcdatamodeld to my source files but it's not compiled into a xy.momd folder.

Do I need to set any other properties in my Pod to get Core Data to work?

My current pod file:

 Pod::Spec.new do |s|
 s.name         = "Test"
 s.version      = "1.0"
 s.summary      = "..."
 s.homepage     = "..."
 s.license      = 'MIT (example)'
 s.author       = { "Felix Krause" => "[email protected]" }
 s.source       = { :git => "http://EXAMPLE/Example.podspec.git", :tag => "0.0.1" }
 s.platform     = :ios, '6.0'
 s.source_files = 'TS/Classes/**/*.{h,m}', 'TS/Views/**/*.{h,m}', 'TS/TSResources/**/*.{json,xcdatamodeld}'
 s.resources = "TS/TSResources/**/*"
 s.frameworks = 'CoreData', 'QuartzCore', 'Accounts', 'MessageUI', 'CoreLocation', 'CoreGraphics', 'MobileCoreServices', 'SystemConfiguration'
 s.requires_arc = true
 s.ios.xcconfig = { 'HEADER_SEARCH_PATHS' => '$(PODS_ROOT)/../../TS/**' }
 s.ios.xcconfig ={ 'FRAMEWORK_SEARCH_PATHS' => '"$(PODS_ROOT)/../.." "$(PODS_ROOT)/.." "$(SRCROOT)/.."' }
 s.xcconfig = { 'OTHER_LDFLAGS' => '-all_load' }
 s.dependency 'JSONKit'
 end
like image 293
KrauseFx Avatar asked Oct 16 '12 16:10

KrauseFx


3 Answers

Just so I can come back to this, it is actually supported. All you need to do is ensure that your pod spec lists the .xcdatamodeld under resources. Something to the effect of:

Pod::Spec.new do |s|
    s.name = "MyPod"
    s.version = "0.1"
    s.platform = :ios, '8.0'
    s.requires_arc = true

    s.public_header_files = 'Pod/Classes/**/*.h'
    s.source_files = 'Pod/Classes/**/*{h,m}'
    s.resources = 'Pod/Classes/CoreData/*.xcdatamodeld'
    s.frameworks = 'CoreData'
end
like image 81
Daniel Galasko Avatar answered Nov 16 '22 14:11

Daniel Galasko


There is currently no explicit support for this. Here is an example of how you could do it. Note, however, that that code was untested, but it should be something along those lines. That specific user moved the model definition into code, in the end, btw.

HTH

like image 43
alloy Avatar answered Nov 16 '22 13:11

alloy


Take a look at the following:

https://github.com/CocoaPods/Xcodeproj/issues/81#issuecomment-23142404 https://github.com/Ashton-W/CoreDataPodSample

like image 1
Ari Braginsky Avatar answered Nov 16 '22 13:11

Ari Braginsky