Skip to content

Instantly share code, notes, and snippets.

@gauravkeshre
Last active January 13, 2019 19:48
Show Gist options
  • Save gauravkeshre/2aebd7bc23318ab294081b57966c2b6d to your computer and use it in GitHub Desktop.
Save gauravkeshre/2aebd7bc23318ab294081b57966c2b6d to your computer and use it in GitHub Desktop.
Integrating custom frameworks using private pods without creating a new git repo

Integrating custom frameworks using private pods without creating a new git repo

Read this if

  1. You have broken your app into custom frameworks (reusable features)
  2. Integrated these private frameworks manually.
  3. Integrated these private frameworks using Custom Scripts
  4. You want to move them to private cocoapods but don't want to create privatee repositories
  5. You don't mind keeping (organizing) the frameworks in the main project

Organize your dependencies

In your project's root, create a folder name Dependencies and move all your frmeworks' folders inside that. So you have one place where all your internal dependencies are stored.

Clean

Undo whatever you have done to use your frmeworks in your app manually. This could require you to

  • remove the post archive scripts from Your Frameworks' schemes
  • remove Your Frameworks form main app's embedded binaries
  • remoe the path to Your Framework from App Target > Build Phases > Copy Run Path
  • Etc

Private Pods

By deafault when you create private pods, you need to supply the git url for your framework. We will go a different route.

Crux

In your Podfile, you can specify where do you want to pick that pod from. By default, it is cocoapod/specs.git repo, in addition to this you can specify more "Sources" (on top of your Podfile.

In some cases you don't want to specify an external source for your pods as it is part of your main project code-base. You can simply specify the :path => arguments to the pod <PodName> in your Podfile

eg:

  pod 'HelpAndSupportFramework', :path => './Dependencies/HelpAndSupportFramework/'
$ cd ./Dependencies

Repeat the following for every folder in Dependencies folder

$ cd HelpAndSupportFramework
pod spec create HelpAndSupportFramework

Now you have private cocoapods for your internal dependencies. All you need to do is to update the .podspecfile

Pod::Spec.new do |s|

  s.name         = "HelpAndSupportFramework"
  s.version      = "1.0.0"
  s.summary      = "HelpAndSupportFramework is a reusable library that allows you to integrate FAQ in the app ."

  s.description  = "HelpAndSupportFramework is a reusable library that allows you to integrate FAQ in the app ."

  s.homepage     = "http://www.gauravkeshre.com"
  s.license      = "Copyright Gaurav pvt. ltd."
  s.author             = { "Gaurav Keshre" => "gaurav.keshre@gmail.com" }
   s.platform     = :ios, "9.0"


  s.source       = { :git => "GIT HUB URL PATH TO YOUR FRAMEWORK PROJECT", :tag => "#{s.version}" }

  s.source_files  = "Classes", "HelpAndSupportFramework/**/*.swift"
  s.exclude_files = "Classes/Exclude"

end

Use

In your Podfile

...
def private_pods
  pod 'HelpAndSupportFramework', :path => './Dependencies/HelpAndSupportFramework/'
end


target "YourAppTarget" do
    ...
    private_pods
end
@gauravkeshre
Copy link
Author

initial commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment