Skip to content

Instantly share code, notes, and snippets.

Last active Feb 7, 2020
What would you like to do?
Script for re-branding Countly iOS SDK

Script for re-branding Countly iOS SDK


Copy the script '' next to 'countly-ios-sdk' folder like below:

├── ExampleFolder
   ├── countly-ios-sdk

And open a shell to ExampleFolder and use the script with a brand name to replace Countly and a class prefix to replace CLY in all the file names and contents, as shown below:

bash AnExampleCompany AEC

If there is a problem with path or arguments you will get a warning. Otherwise, if everything is fine, you will be seeing these logs:

Deleting unneccessary files... done.
Renaming files... done.
Replacing file contents... done.
Replacing prefixes... done.
Deleting URLs... done.
Deleting licence... done.
Renaming folder... done.
All done.

After that, you can use re-branded Countly iOS SDK in your project.

NOTE: Reserved event names ([CLY]_apm , [CLY]_view etc.) will also be replaced with the given prefix. This requires changes on Countly Server code too.

if [ "$#" -ne 2 ]; then
echo "Provide brand name and class prefix.."
exit 1
if cd "countly-sdk-ios"; then
echo -ne "Deleting unneccessary files..."\\r
rm -rf Countly.podspec
rm -rf .git
rm -rf .gitattributes
rm -rf LICENSE
rm -rf
echo "Deleting unneccessary files... done."
echo -ne "Renaming files..."\\r
find . -name '*Countly*' -print0 | xargs -0 -n1 bash -c 'mv "$0" "${0/Countly/'$brandName'}"'
echo "Renaming files... done."
echo -ne "Replacing file contents..."\\r
grep -rl Countly . | xargs perl -pi -e 's/Countly/'$brandName'/g'
grep -rl COUNTLY . | xargs perl -pi -e 's/COUNTLY/'$brandName'/g'
grep -rl countly . | xargs perl -pi -e 's/countly/'$brandName'/g'
echo "Replacing file contents... done."
echo -ne "Replacing prefixes..."\\r
grep -rl CLY . | xargs perl -pi -e 's/CLY/'$prefix'/g'
grep -rl cly . | xargs perl -pi -e 's/cly/'$prefix'/g'
echo "Replacing prefixes... done."
echo -ne "Deleting URLs..."\\r
grep -rl '// Please visit www\.count\.ly for more information\.' . | xargs perl -pi -e 's/\/\/ Please visit www\.count\.ly for more information\./ /g'
echo "Deleting URLs... done."
echo -ne "Deleting licence..."\\r
grep -rl '// This code is provided under the MIT License\.' . | xargs perl -pi -e 's/\/\/ This code is provided under the MIT License\./ /g'
echo "Deleting licence... done."
echo -ne "Renaming folder..."\\r
mv "../countly-sdk-ios" "../$brandName-sdk-ios"
echo "Renaming folder... done."
echo "All done."
echo "Cannot find countly-sdk-ios folder!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment