Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Script to build a new Google Sign in dependencies that will work with Firebase
root=$PWD
binary=GoogleSignInDependencies
signInFrameworkDir=./google_signin_sdk_4_0_1
archs=(armv7 x86_64 arm64 i386)
duplicateClasses=(GTMLogger GTMNSDictionary+URLArguments GTMSessionFetcher GTMSessionFetcherService GTMSessionUploadFetcher)
hackDir=hack
framework=$binary.framework
originalFramework=$signInFrameworkDir/$framework
hackTmpDir=$hackDir/tmp
function extractBinaries() {
hackTmpDir=$1
arch=$2
archDir=$hackTmpDir/$arch
mkdir $archDir
echo "Extracting classes from $archDir/$arch.a ..."
lipo -thin $arch $hackTmpDir/$binary -output $archDir/$arch.a
cd $archDir
ar -x $arch.a
cd $root
}
function removeDuplicateClasses() {
echo "Removing duplicated classes ..."
cd $1/$2
wildcard="_*.o"
for prefix in ${duplicateClasses[@]}
do
echo "Removing $prefix$wildcard ..."
rm -fr $prefix$wildcard
done
cd $root
}
function buildNewBinary() {
hackTmpDir=$1
arch=$2
echo "Building new binary for $arch ..."
libtool -static $hackTmpDir/$arch/*.o -o $hackTmpDir/$arch.a
}
echo "Cleaning $hack ..."
rm -fr $hackDir
mkdir -p $hackTmpDir
cp $originalFramework/$binary $hackTmpDir
echo "Extracting binary data from $originalFramework ..."
binaryFiles=
for arch in ${archs[@]}
do
extractBinaries $hackTmpDir $arch
removeDuplicateClasses $hackTmpDir $arch
buildNewBinary $hackTmpDir $arch
binaryFiles+=" $hackTmpDir/$arch.a"
done
echo "Building new framework file ..."
cp -R $originalFramework $hackDir
lipo -create $binaryFiles -output $hackDir/$framework/$binary
echo "Removing tmp files ..."
rm -fr $hackTmpDir
echo "Moving old framework out of the way ..."
mkdir $signInFrameworkDir/old
mv $originalFramework $signInFrameworkDir/old
echo "Done."
Owner

drekka commented Jul 14, 2017

No guarantees. This is an initial script that so far is working for me with Firebase 4.0.3 and Google Sign In 4.0.1.

The problem it solves is that combining these two frameworks results in Xcode failing to build, logging lots of duplicate symbols errors. This script takes the Google Sign In dependencies framework apart and removes the classes which are duplicated in Firebase.

To use it, simple add Google Sign as instructed, remove the GoogleSignInDependecies.framework from you project and replace it with the one created here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment