Skip to content

Instantly share code, notes, and snippets.

@erkanyildiz erkanyildiz/README.md Secret
Last active Jun 1, 2019

Embed
What would you like to do?
Script for re-branding Countly iOS SDK

Script for re-branding Countly iOS SDK

Usage

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

├── ExampleFolder
   ├── countly-ios-sdk
   └── rebrand-countly-ios-sdk.sh

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 rebrand-countly-ios-sdk.sh 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 count.ly 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
fi
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 README.md
echo "Deleting unneccessary files... done."
brandName="$1";
prefix="$2";
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 count.ly 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 count.ly 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."
else
echo "Cannot find countly-sdk-ios folder!"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.