Search code examples
iosobjective-ccocoapods

Preserve folder structure Cocoa Pods


I have create a simple and private pod with this tutorial: http://pablin.org/2013/05/18/cocoapods-for-internal-libraries/

In fact my repo has just a group of classes

All is ok and I can install my pod perfectly. The only problem is all files are installed inside of the main folder so it doesn't preserve the folder structure.

I have this folder structure, repository named: myRepository

 Classes 
 |
 ------ foo.h and foo.m
 ------ Controller Layer
        |
        ----------- foo2.h and foo2.m
 ------ ViewLayer
        |
        ----------- foo3.h and foo3.m

All files are copied inside of a folder called myRepository.

This is my podspec:

Pod::Spec.new do |s|

  s.name         = "fooClasses"
  s.version      = "0.0.1"
  s.summary      = "Common clases of foo"

  s.homepage     = "http://foo.com"

  s.license      = 'BSD'
  s.license      = { :type => 'Foo License', :file => 'LICENSE.txt' }

  s.author       = { "me" => "me@me.com" }

  s.platform     = :ios, '7.0'

  s.source       = { :git => "https://github.com/myRepository.git", :tag => "0.0.1" }

  s.source_files  = "**/*.{h,m}"

  s.requires_arc = true
end

I have tried with s.preserve_path = "*" and s.preserve_path = "Classes"

Any idea?

Thanks!!!!!!!!


Solution

  • Well I have achieved to create my own folders with subspec.

    You can create a subspec with this line:

    s.subspec 'folder name' do |ss|
        ss.source_files = 'files'
        ss.frameworks = 'frameworks'
    end
    

    The ss.frameworks is not mandatory.

    You can see the complete answer from the CocoaPods mail list:

    https://groups.google.com/forum/#!topic/cocoapods/0kV8r2xnqA8

    Thanks mcitrrus

    I preferred to follow the AFNetworking pod spec:

    https://github.com/AFNetworking/AFNetworking/blob/master/AFNetworking.podspec