How to create a CocoaPod with nested git submodules?
Asked Answered
E

1

37

I'm trying to create a CocoaPod with nested git submodules. I can create the pod, however, I can't fully install it.

When I run pod install --verbose I can see that git submodule update --init is being run instead of git submodule update --init --recursive which doesn't pull the nested submodule.

Does CocoaPods support nested submodules, or no? I have scoured the web for potential leads, but can't find anything!

I should also mention that I that lint passes with pod lib lint but not pod spec lint. pod spec lint complains that it can't find the header file in the nested submodule. I'm not sure if this is related to the problem above.

(Also note that this particular Pod I'm working on is only a proof of concept. I'll be creating a much more complex Pod that depends on socket.IO-objc. Unfortunately socket.IO-objc is not available as a Pod, and depends on SocketRocket as a submodule.)

Here's my PodSpec:

Pod::Spec.new do |s|
  s.name             = "DebugTools"
  s.version          = "0.1.0"
  s.summary          = "Awesome tools for debugging iOS apps."
  s.homepage         = "https://github.com/robertcrabtree/DebugTools"
  s.license          = 'MIT'
  s.author           = { "Robert Crabtree" => "[email protected]" }
  s.source           = { :git => "https://github.com/robertcrabtree/DebugTools.git", :tag => s.version.to_s, :submodules => true }

  s.platform     = :ios, '7.0'
  s.requires_arc = true

  s.source_files = 'Pod/Classes/**/*', 'Pod/Submodules/LogMaster/LogMaster/*.{h,m}', 'Pod/Submodules/LogMaster/LogMaster/LogCore/*.h'
  s.resource_bundles = {
    'DebugTools' => ['Pod/Assets/*.png']
  }
end

Here's my Podfile:

pod "DebugTools", :git => "https://github.com/robertcrabtree/DebugTools.git", :submodules => true
Erbil answered 14/5, 2015 at 0:51 Comment(0)
O
1

I believe that CocoaPods is created exactly to avoid GIT submodules usage.

Here is cool explanation why: https://roadfiresoftware.com/2013/05/a-case-for-switching-to-cocoapods-from-git-submodules/

Let’s say your project depends on AFNetworking. You add it as a git submodule, and then, someday, due to an Act of God (or just because the author feels like it), AFNetworking disappears from its home on GitHub. It’s all gone, vanished into thin air. Now when someone new clones your project repo, they run git submodule update --init …and it fails. So now they can’t build the project. And you’d better be careful, too, cause if you lose the AFNetworking source code, you can’t build either…

So now we use CocoaPods, and we push the source for each dependency to our central repo. Now when someone git clones a repo, they get all the code they need, and they can build the project just fine. They don’t even need CocoaPods to build the app – it just works.

So, let CocoaPods do its job. CocoaPods manages dependencies for your Xcode projects. (c) https://github.com/CocoaPods/CocoaPods

Ockeghem answered 17/6, 2022 at 21:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.