All Projects → grab → Cocoapods Pod Merge

grab / Cocoapods Pod Merge

Licence: mit
Cocoapods plugin to merge pods used by your Xcode project, reducing the number of dynamic frameworks your app has to load on startup

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Cocoapods Pod Merge

Pysearch
🔍 An elegant search controller which replaces the UISearchController for iOS (iPhone & iPad) .
Stars: ✭ 3,816 (+1282.61%)
Mutual labels:  cocoapods, pod
Kydrawercontroller
Side Drawer Navigation Controller similar to Android
Stars: ✭ 632 (+128.99%)
Mutual labels:  cocoapods, pod
Kyshutterbutton
KYShutterButton is a custom button that is similar to the shutter button of the camera app
Stars: ✭ 293 (+6.16%)
Mutual labels:  cocoapods, pod
Swiftprogresshud
📦 SwiftProgressHUD is a user-friendly pure swift HUD. 支持Cocoapods 及 Carthage
Stars: ✭ 290 (+5.07%)
Mutual labels:  cocoapods, pod
Abexpandableview
Expandable, collapsible, filterable and single/multi selectable table view.
Stars: ✭ 138 (-50%)
Mutual labels:  cocoapods, pod
Rsformview
A Cocoapods library designed to easily create forms with multiple data entry fields
Stars: ✭ 84 (-69.57%)
Mutual labels:  cocoapods, pod
Badgehub
A way to quickly add a notification badge icon to any view. Make any view of a full-fledged animated notification center.
Stars: ✭ 592 (+114.49%)
Mutual labels:  cocoapods, pod
Bekcurvetabbar
Full Customizable Tabbar with IBInspectables
Stars: ✭ 144 (-47.83%)
Mutual labels:  cocoapods, pod
Luexpandabletableview
A subclass of UITableView with expandable and collapsible sections
Stars: ✭ 125 (-54.71%)
Mutual labels:  cocoapods, pod
Nim ios uikit
网易云信 iOS UI 组件,提供聊天界面,文本消息,图片消息,语音消息,视频消息,地理位置消息,自定义消息(阅后即焚)等消息示例。#推荐客户得比特币,首次推荐得0.02BTC,连续推荐得0.03BTC/单,上不封顶。点击参与https://yunxin.163.com/promotion/recommend
Stars: ✭ 1,326 (+380.43%)
Mutual labels:  cocoapods, pod
Cocoapods Tips
iOS 라이브러리를 관리하는 CocoaPods Tip정보 모음입니다.
Stars: ✭ 141 (-48.91%)
Mutual labels:  cocoapods, pod
Modernavplayer
ModernAVPlayer is a persistence AVPlayer wrapper
Stars: ✭ 179 (-35.14%)
Mutual labels:  cocoapods, pod
Yoshi
A convenient wrapper around the UI code that is often needed for displaying debug menus.
Stars: ✭ 263 (-4.71%)
Mutual labels:  cocoapods
Mobileplayer Ios
📱 🎥 A powerful and completely customizable media player for iOS
Stars: ✭ 2,931 (+961.96%)
Mutual labels:  cocoapods
Uxmpdfkit
An iOS PDF viewer and annotator written in Swift that can be embedded into any application.
Stars: ✭ 260 (-5.8%)
Mutual labels:  cocoapods
Parse Sdk Ios Osx
The Objective-C iOS | macOS | watchOS | tvOS SDK for the Parse Platform
Stars: ✭ 2,788 (+910.14%)
Mutual labels:  cocoapods
Fapaginationlayout
Collection view pagination layout
Stars: ✭ 276 (+0%)
Mutual labels:  cocoapods
Ribbon
🎀 A simple cross-platform toolbar/custom input accessory view library for iOS & macOS.
Stars: ✭ 273 (-1.09%)
Mutual labels:  cocoapods
Corestore
Unleashing the real power of Core Data with the elegance and safety of Swift
Stars: ✭ 3,254 (+1078.99%)
Mutual labels:  cocoapods
Datez
📆 Breeze through Date, DateComponents, and TimeInterval with Swift!
Stars: ✭ 254 (-7.97%)
Mutual labels:  cocoapods

Cocoapods Pod Merge Plugin Gem Version

pod-merge is a Cocoapods plugin to merge dependencies (or pods) used by your Xcode project, to reduce the number of dynamic frameworks your app has to load on app startup.

The plugin introduces a new file to your project: the MergeFile, and hooks into the pre-install phase of pod install to merge your dependencies.

Benchmarks

Based on measurements taken on this repo's example project, merging 8 pods into 3.

pod-merge Benchmarks

According to our experience in Grab, improvements on older devices like the iPhone 5, 6 are more drastic. As a general rule, we've seen dylib loading times decrease by upto 50 ms per dynamic framework reduced on our user's slowest devices. More info here.

Installation

Using Bundler

If your Xcode project does not have a Gemfile yet, it's highly recommended you use bundler to maintain consistent versions of tools like cocoapods within your team. Learn how to set it up here.

To use cocoapods-pod-merge, add this line to your app's Gemfile:

gem 'cocoapods-pod-merge'

And then install it using bundler by executing:

$ bundle install

Note than this is a cocoapods plugin, hence it requires cocoapods as a dependency.

Usage

Using this plugin to merge your pods is a simple three step process:

1. Create a MergeFile

This plugin requires a file called MergeFile. This is how it looks:

group 'Networking'
	pod 'AFNetworking'
	pod 'SDWebImage'
end

The above MergeFile:

  • Defines a group named Networking. This will be the name of the resulting merged pod.
  • Tells the plugin to merge AFNetworking & SDWebImage into Networking

Here's a few important tips to decide what pods to merge.

Important: The MergeFile is pretty strict about it's syntax, so please avoid adding comments or random text to it. To make your life easier, tell your text editor to treat it like a Ruby file.

2. Update your Podfile

Now, update your Podfile to use the plugin, as well as the merged pods:

Add the line plugin 'cocoapods-pod-merge' to the top of your existing Podfile, and modify it to use the merged pod.

plugin 'cocoapods-pod-merge'

target 'MyApp'
	# pod 'AFNetworking' # Not needed anymore, since we'll use the merged Pod
	# pod 'SDWebImage' # Not needed anymore, since we'll use the merged Pod
	pod 'Networking', :path => 'MergedPods/Networking' # The merged pod
end

Things to note:

  • We commented out the pods 'AFNetworking' & 'SDWebImage' above, since these will now be installed as part of the merged Networking framework.
  • We add the merged framework Networking, which is named as the group name defined in our MergeFile
  • The path is fixed, since the plugin will put your merged pods in the MergedPods/<group name> directory.

3. Run Pod Install & Update your Code!

That's it! Just run:

$ bundle exec pod install

If all goes well, the pods should be merged according to your MergeFile, and should be available to use in your project.

There's one more thing! There's no framework such as AFNetworking or SDWebImage available to your project now, since these are now merged into a pod namedNetworking So, as a one time process, replace imports of the merged libraries in your project like

import AFNetworking

to

import Networking.AFNetworking

And that's it! You're done!

Example Project

There's a example project in the repo which shows the plugin in action. To try it out, just open the Terminal in the PodMergeExample directory, and run:

$ bundle install
$ bundle exec pod install

Benchmarks & More Info

To learn more about the performance improvements you can expect, checkout benchmarks.

Curious about how the plugin actually works? Check out inner workings.

MergeFile

The MergeFile has a very similar syntax to your Podfile. It also supports defining multiple groups, which creates multiple merged pods.

Consider a more common Podfile, with lots of pods, fixed versions, and different sources:

target 'MyApp'
	pod 'AFNetworking', '2.7.0'
	pod 'SDWebImage', '~> 5.0'
	pod 'IQKeyboardManager', '6.2.1'
	pod 'TTTAttributedLabel', '2.0.0'
	pod 'MBProgressHUD', :git => 'https://github.com/jdg/MBProgressHUD.git', :tag => '1.1.0'
	pod 'FLAnimatedImage', '1.0.12'
end

Let's group these Pods into two: UI, and Networking. The MergeFile to achieve this would look like this:

group 'Networking'
	pod 'AFNetworking', '2.7.0'
	pod 'SDWebImage', '~> 5.0'
end

group 'UI'
	pod 'IQKeyboardManager', '6.2.1'
	pod 'TTTAttributedLabel', '2.0.0'
	pod 'MBProgressHUD', :git => 'https://github.com/jdg/MBProgressHUD.git', :tag => '1.1.0'
	pod 'FLAnimatedImage', '1.0.12'
end

Two things to note here:

  • The MergeFile supports defining Pods just like your Podfile, with all the options that the Podfile supports, like the :path, :git, :branch arguments.
  • You can have any number of groups in your MergeFile. The resulting merged dependencies will be named by the groups defined in your MergeFile.

You can now modify your original Podfile to use the plugin, and the merged pods instead of the individual pods:

plugin 'cocoapods-pod-merge'

target 'MyApp'
	pod 'Networking', :path => 'MergedPods/Networking'
	pod 'UI', :path => 'MergedPods/UI'
end

That's it! Now just run bundle exec pod install!

Note: Once the pods are merged according to your MergeFile, you should commit the MergeFile into your version control system (like git)

Special Flags

has_dependencies!

If you have a group of Pods that depend on each other and you want merge them, add this flag into that group.

group 'SomePods'
	has_dependencies!
	pod 'ABC'
	pod 'ABCDependsOnThis'
end

This enables an experimental feature where the plugin tries to fix dependency imports. For example, If pod ABC has code like import <ABCDependsOnThis/File.h>, the plugin will automatically convert this import into #import "File.h", since after the merge, the both the pods will be in the same framework.

swift_version!

If you have a group of Swift pods, the plugin automatically finds out the common compatible Swift version across those pods, and sets that as the Swift version for the merged Pod. If you'd like to manually set the Swift version of a group, you can use the swift_version flag like:

group 'SwiftPodsGroup'
	swift_version! '5.0'
	pod 'SwiftPodA'
	pod 'SwiftPodB'
	pod 'SwiftPodC'
end

This is especially handy if some of the pods in your group do not have a Swift Version defined in their podspec.

platform

If you have multiple platforms in your base Podfile, you can specify the platform for each group in your MergeFile

group 'SwiftPodsGroup'
	platform :ios, '11.0'

	pod 'SwiftPodA'
	pod 'SwiftPodB'
	pod 'SwiftPodC'
end

This is helpful when you have a Podfile with Pods for iOS, WatchOS, etc...

Version Control (like git)

You should definitely commit the MergeFile into your repository, since this is just like your Podfile, and is required for the plugin to work.

The plugin creates a directory called MergedPods, where it keeps the source code and podspecs for the merged pods. Whether you decide you commit this directory depends entirely on your team's workflow. A good rule of thumb is if you commit the Pods/ directory created by Cocoapods, then you should commit this directory as well. The obvious upside is that the merged pods are cached, and the merge does not take place everytime pod install is run, unless something changes.

The plugin also creates another directory called MergeCache when it's running. While this directory is removed when the plugin is done, it can be good practice to add to your .gitignore file just in case the plugin fails to remove it.

MergeCache/

If you decide not to commit the MergedPods directory, add that to the .gitignore as well:

MergeCache/
MergedPods/

Tips

This plugin is not a magic bullet that'll merge all your cocoapods into a single framework. Here's a few tips to save you from hard to debug issues after merging your pods.

  • Start small, by merging a small number (2 to 4) of your Pods, and check everything works after the merge.
  • Only pods which expose their full source code can be merged. Pods that do not expose sources, eg: Fabric / Firebase cannot be merged.
  • Don't mix up Swift and Objective-C Pods in the same group.
  • Try to make logical sense of your groups, don't just merge every single Pod your app uses into one giant pod. This can be very fragile, and can lead to hard to debug compilation / linking issues.
  • Refrain from merging complex or specialized pods (like pods written in C/C++). Such pods can have special build settings and compiler flags that can break the other pods that are merged with them.
  • Make sure you add the required flags to relevant groups in your MergeFile.

Troubleshooting

If the above guidelines still do not solve your problem, please report it! Merging Pods is a complex process, and the plugin does not cover all possible use cases or podspec formats. Any feedback or feature suggesions are also encouraged. Bug reports and pull requests are welcome.

License

The cocoapods-pod-merge plugin is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].