Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CocoaPod spec: Unable to find other source ref for Model.xcdatamodeld

Tags:

ios

cocoapods

I am trying to create a pod with CoreData model inside. I've followed the tips to use resources and reserve_path. But when I try to lint the spec with pod lib lint there is this weird error that I don't even understand:

- ERROR | [iOS] unknown: Encountered an unknown error (Unable to find other source ref for /Users/rzolin/Projects/ArmorText/iOS-Pod-Test/SampleMessengerCocoapodFramework/SampleMessengerCocoapodFramework/Code/DataManagement/Model/Model.xcdatamodeld/Model.xcdatamodel/contents for target SampleMessengerCocoapodFramework.) during validation.

The spec is based on couple of subspecs, which could complicate the issue a bit. And search on the Internet didn't produce any help so far.

There is a test spec that replicates the error, if somebody is willing to take a look.

The full spec is here:

Pod::Spec.new do |s|
    s.name             = 'SampleMessengerCocoapodFramework'
    s.version          = '0.2.0'
    s.summary          = 'some desc'

    s.description      = <<-DESC
    some desc
    DESC

    s.homepage         = 'http://www.example.com'
    s.license          = { :type => 'MIT', :file => 'LICENSE' }
    s.author           = { 'rzolin' => '[email protected]' }
    s.source           = { :git => 'https://github.com/rzolin/SampleMessengerCocoapodFramework.git', :tag => s.version.to_s }

    # Platform setup
    s.requires_arc = true
    s.ios.deployment_target = '8.0'

    s.default_subspec = 'Core'

    ### Subspecs
    s.subspec 'Core' do |cs|
        cs.dependency 'SampleMessengerCocoapodFramework/DataManagement'
        cs.dependency 'SampleMessengerCocoapodFramework/Networking'
    end

    s.subspec 'DataManagement' do |ds|
    ds.source_files = 'SampleMessengerCocoapodFramework/Code/DataManagement.h', 'SampleMessengerCocoapodFramework/Code/DataManagement/**/*'
      ds.resources = [ 'SampleMessengerCocoapodFramework/Code/DataManagement/Model/Model.xcdatamodeld', 'SampleMessengerCocoapodFramework/Code/DataManagement/Model/Model.xcdatamodeld/*.xcdatamodel' ]
      ds.preserve_paths = 'SampleMessengerCocoapodFramework/Code/DataManagement/Model/Model.xcdatamodeld'
    end

    s.subspec 'Networking' do |ns|
    ns.source_files = 'SampleMessengerCocoapodFramework/Code/Networking.h', 'SampleMessengerCocoapodFramework/Code/Networking/**/*.{h,m,swift}'
    end

    # s.resource_bundles = {
    #   'SampleMessengerCocoapodFramework' => ['SampleMessengerCocoapodFramework/Assets/*.png']
    # }

    # s.public_header_files = 'Pod/Classes/**/*.h'
    # s.frameworks = 'UIKit', 'MapKit'
    # s.dependency 'AFNetworking', '~> 2.3'
end

I've tried to ask the question in Cocoapods, but was referred here

Any help would be appreciated!

like image 536
Roman Zolin Avatar asked Aug 24 '17 12:08

Roman Zolin


1 Answers

I had the same problem and error message as you. I wanted to have the .xcdatamodel in my pod. Here is my solution:

  1. Add only your code in the source_files:

     s.source_files = 'MyPodDiR/**/*.{h,m,swift}'
    
  2. Add your xcdatamodel path as a resources:

     s.resources = 'MyPodDir/CoreData/MyPodModel*.xcdatamodeld'
    
like image 180
kew Avatar answered Nov 15 '22 17:11

kew