Auto increment podspec version. I have a MyPodName.podspec file like this:
Pod::Spec.new do |s|
s.name = "MyPodName"
s.version = "1.0.32"
s.summary = "My pod summary"
s.description = <<-DESC
My Pod complete description
DESC
s.homepage = "https://my.homepage.com"
s.license = { :type => 'Apache License, Version 2.0' }
s.author = { "Alex Gotev" => "[email protected]" }
s.ios.deployment_target = '9.0'
s.requires_arc = true
s.source = { :git => "[email protected]:project/group/mypodrepo.git" }
s.source_files = "generated/*.swift", "generated/runtime/*.swift", "OtherFile.swift"
s.dependency 'CocoaMQTT'
endand I'm tired of editing it manually each time to publish a new pod version.
Create a new file called MyPodName.podtemplate and copy all the contents of MyPodName.podspec in it. Then replace 1.0.32 which is the version, with [[VERSION]]. You will have a file like this:
Pod::Spec.new do |s|
s.name = "MyPodName"
s.version = "[[VERSION]]"
s.summary = "My pod summary"
s.description = <<-DESC
My Pod complete description
DESC
s.homepage = "https://my.homepage.com"
s.license = { :type => 'Apache License, Version 2.0' }
s.author = { "Alex Gotev" => "[email protected]" }
s.ios.deployment_target = '9.0'
s.requires_arc = true
s.source = { :git => "[email protected]:project/group/mypodrepo.git" }
s.source_files = "generated/*.swift", "generated/runtime/*.swift", "OtherFile.swift"
s.dependency 'CocoaMQTT'
endFrom now on, you will edit only the MyPodName.podtemplate file!
Then create a file called build.properties and add the following:
BASE_VERSION=1.0
BUILD_VERSION=32
Create a file called increment_build and add the following in it:
#!/bin/bash
TEMPLATE_FILE_NAME="MyPodName.podtemplate"
OUT_FILE_NAME="MyPodName.podspec"
# Increment the build version and save it into build.properties
. build.properties
BUILD_VERSION=$((BUILD_VERSION+1))
echo "BASE_VERSION=${BASE_VERSION}" > build.properties
echo "BUILD_VERSION=${BUILD_VERSION}" >> build.properties
# Load the template podspec and replace version
TEMPLATE=$(cat "$TEMPLATE_FILE_NAME" | sed "s/\[\[VERSION\]\]/${BASE_VERSION}\.${BUILD_VERSION}/g")
echo "$TEMPLATE" > "$OUT_FILE_NAME"replace TEMPLATE_FILE_NAME and OUT_FILE_NAME accordingly to your pod and then make increment_build executable with sudo chmod +x increment_build.
Now, to increase the build of your podspec, you can simply execute:
./increment_build
Et voilà!