- Status: Proposed
The purpose of this proposal is to improve CocoaPods support by:
- Deprecate the
framework
tag usage oftype="podspec"
- Improve readability
- Add missing default configurations
<podspec>
<config>
<source url="https://github.com/brightcove/BrightcoveSpecs.git" />
<source url="https://github.com/CocoaPods/Specs.git"/>
</config>
<pods use-frameworks="true">
<pod name="PromiseKit" />
<pod name="Foobar1" spec="~> 2.0.0" />
<pod name="Foobar2" git="git@github.com:hoge/foobar1.git" />
<pod name="Foobar3" git="git@github.com:hoge/foobar2.git" branch="next" />
<pod name="Foobar4" swift-version="4.1" />
<pod name="Foobar5" swift-version="3.0" />
<pods>
</podspec>
- Available in the global scope
- Available in the platform scope
- Has no attributes
- Has a body consisting of two tags
<config>
<pods>
- Available in the
podspec
tag - Has no attributes
- Has a body consisting of
<source>
tag
- Available in the
podspec
tag - Has
use-frameworks
attribute, of which the default value is `` (empty). The valuetrue
means to use. - Has
inhibit-all-warnings
attribute, of which the default value is `` (empty). The valuetrue
means to use. - Has a body consisting of
<pod>
tag
- Available in the
config
tag - Has
url
attribute - Has no content in the body.
- Available in the
pods
tag - Avaialble attributes:
name
spec
tag
branch
commit
configurations
git
http
podspec
path
swift-version
options
The plugin.xml
fie contains:
<pod name="GoogleAnalytics" spec="~> 3.1" />
On prepare, the Podfile
file will become:
pod 'GoogleAnalytics', '~> 3.1'
The plugin.xml
fie contains:
<pod name="Alamofire" path="~/Documents/Alamofire" />
On prepare, the Podfile
file will become:
pod ‘Alamofire’, :path => ‘~/Documents/Alamofire’
The options
attribute value is written in a key-value pair system.
<pod name="Alamofire" options=":git => 'https://github.com/Alamofire/Alamofire.git', :tag => '3.1.1'" />
Because there are so many features that CocoaPods supplies, it would be difficult to keep track of all.
Some of them may also be less likely used over others for example:
- svn (
:svn
) and its head (:head
) - mercurial (
:hg
) - bazaar (
:bzr
).
Since the current pods.json
file only records each library spec, it must be extended to support the ability to manage the settings of each pod.
{
"SwiftMessages": {
"name": "SwiftMessages",
"type": "podspec",
"spec": "~> 4.1",
"count": 1
}
}
{
"declarations": {
"use_frameworks!" : {
"declaration": "use_frameworks!",
"count": 1
},
"inhibit_all_warnings!": {
"declaration": "inhibit_all_warnings!",
"count": 1
}
},
"sources": {
"https://github.com/CocoaPods/Specs.git": {
"source" : "https://github.com/CocoaPods/Specs.git",
"count" : 1
},
…
},
"libraries": {
"SwiftMessages": {
"name": "SwiftMessages",
"type": "podspec",
"spec": "~> 4.1",
"swift-version": “4.1",
"count": 1
}
}
}
To support the new ability, the pods.json
file will be broken into three primary sections.
Declarations Section
The section will contain the overall Cocoapods declarations. For example: use-framework
.
Sources Section The source section will contain a list of known sources where pods come from. In some situations, a user may have their own private registry which contains private pods.
Libraries Section This section is identical to the original file with the added properties.
- The
count
parameter in the newpods.json
file structure indicates the number of plugins having Podfile settings. Podfile
is modified according to thispods.json
file.- All the elements with the
count > 0
is added in Podfile. - If the same key with a different element is about to be added, only the count parameter is increased for the previous element with the same key and show warnings.
For example
pluginA has
<podspec>
<pods>
<pod name="Foobar1" spec="~> 2.0.0" />
<pods>
</podspec>
pluginB has
<podspec>
<pods>
<pod name="Foobar1" spec="~> 3.0.0" />
<pods>
</podspec>
If the developer adds pluginA and pluginB in this order, the resulting pods.json
becomes
{
"declarations": {
},
"sources": {
},
"libraries": {
"Foobar1": {
"name": "Foobar1",
"type": "podspec",
"spec": "~> 2.0.0",
"count": 2
}
}
}
-
If there is an old
pods.json
file in the project, the file should be automatically updated to the new pods.json. -
When the developer removes a plugin, the corresponding count parameter is decreased. If the count becomes zero, the element is removed.
-
This new feature works only in
plugin.xml
, not inconfig.xml
. This is for avoiding complexity. If we supportconfig.xml
we should detect all changes ofconfig.xml
every time when doingcordova prepare
and find differences with previousconfig.xml
settings to updatepods.json
. This process becomes very complex like a config_munge incordova-common
wherecount
does not seem to work well. Supporting onlyplugin.xml
is rather simple because we should checkplugin add
andplugin rm
only.
The framework
tag with type="podspec"
is still available for the compatibility.
<framework src="SwiftMessages" type="podspec" spec="~> 4.1" />
Combining new and old formula in plugin.xml
will update Podfile.
In a later release, we can official remove the old formula compeltely.