0

I've used Carthage a bit and am trying to understand how to do the same thing in Cocoapods. Basically I have a Core framework that depends on another framework. While developing Core, I can pull in my dependency with

git "file:///pathtodependencyframework" "development-branch"

In Cocoapods, I'd like to first know how I can refer to this framework locally. I tried adding this under the Project Linking section

s.framework = "DependencyFramework", :path => '~/pathtodependencyframework'

But I get, failed to load podspec. File: syntax error, unexpected =>, expecting key word_end

I also see that there's a Project Settings s.dependency. What is the proper way to refer to a dependency framework that does work with Carthage locally in Cocoapods? Does the dependency framework need a podspec itself? Currently it does not have one since Carthage does not require it.

Secondly, how would the proposed solution change once I'm ready to release and put it on Github?

halfer
  • 19,824
  • 17
  • 99
  • 186
Crystal
  • 28,460
  • 62
  • 219
  • 393

1 Answers1

0

You can't add local pods as dependencies to local pods. Have a look at this issue.

You can add DependencyFramework as a subspec and add it as dependency to Core subspec:

   s.subspec 'DependencyFramework' do |df|
       df.source_files = "DependencyFramework/**/*.swift"
   end

   s.subspec 'Core' do |core|
       core.source_files = "Core/**/*.swift"
       core.dependency 'Core/DependencyFramework'
   end

So you need only 1 podpec.

When you put this library on Github, you need to publish pod (please refer to Release section of documentation). Once pod is published, you can simply add it without mentioning local path: pod 'MyLib/Core'

Please note that there could be some problems with dependencies if your framework has cocoapods dependencies and you want to use it with carthage.