Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to build a new Google Sign in dependencies that will work with Firebase
function extractBinaries() {
binary=$1
hackTmpDir=$2
arch=$3
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 ..."
hackTmpDir=$1
arch=$2
cd $hackTmpDir/$arch
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 "Starting hack ..."
root="$PWD"
binary=GoogleSignInDependencies
framework=$binary.framework
frameworkDir=./google_signin_sdk_4_1_2
hackedFrameworkDir=$frameworkDir-hacked
duplicateClasses=(GTMLogger GTMSessionFetcherService GTMSessionFetcher GTMSessionUploadFetcher GTMNSDictionary+URLArguments)
archs=(armv7 x86_64 arm64 i386)
echo "Hacking $frameworkDir/$framework to remove classes: $duplicateClasses"
echo "Cleaning $hackedFrameworkDir ..."
rm -fr $hackedFrameworkDir
cp -R $frameworkDir $hackedFrameworkDir
echo "Copying framework binary ..."
mkdir -p $hackedFrameworkDir/tmp
cp $hackedFrameworkDir/$framework/$binary $hackedFrameworkDir/tmp
echo "Extracting binary data from $hackedFrameworkDir/tmp/$binary ..."
binaryFiles=
for arch in ${archs[@]}
do
extractBinaries $binary $hackedFrameworkDir/tmp $arch
removeDuplicateClasses $hackedFrameworkDir/tmp $arch
buildNewBinary $hackedFrameworkDir/tmp $arch
binaryFiles+=" $hackedFrameworkDir/tmp/$arch.a"
done
echo "Building new framework file ..."
rm $hackedFrameworkDir/$framework/$binary
lipo -create $binaryFiles -output $hackedFrameworkDir/$framework/$binary
echo "Removing tmp files ..."
rm -fr $hackedFrameworkDir/tmp
echo "Please use framework $hackedFrameworkDir/$framework"
echo "Done."
@drekka

This comment has been minimized.

Show comment
Hide comment
@drekka

drekka 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.

Note that the list of duplicate classes may change depending on the versions of the frameworks. This script could also do with some options to define directories and other stuff so feel free to hack.

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.

Note that the list of duplicate classes may change depending on the versions of the frameworks. This script could also do with some options to define directories and other stuff so feel free to hack.

@ducmaxime

This comment has been minimized.

Show comment
Hide comment
@ducmaxime

ducmaxime Mar 5, 2018

I try your script duplicated error symbol is fixed

but

Undefined symbols for architecture x86_64:
"_kGTMSessionFetcherStatusDomain", referenced from:
-[GTMOAuth2SignIn authCodeObtained] in GoogleSignInDependencies(GTMOAuth2SignIn_5bfc657f526d8c0a0b202f74ea6b8446.o)
"OBJC_CLASS$_GTMSessionFetcherService", referenced from:
objc-class-ref in GoogleSignIn(GIDSignIn.o)
"OBJC_CLASS$_GTMSessionFetcher", referenced from:
objc-class-ref in GoogleSignInDependencies(GTMOAuth2Authentication_1ce8c6f89c07caddf41e7c0549106c71.o)
objc-class-ref in GoogleSignInDependencies(GTMOAuth2SignIn_5bfc657f526d8c0a0b202f74ea6b8446.o)
objc-class-ref in GoogleSignIn(GIDRuntimeConfigFetcher.o)
objc-class-ref in GoogleSignIn(GIDSignIn.o)
"_GTMSessionFetcherAssertValidSelector", referenced from:
-[GTMOAuth2Authentication authorizeRequest:delegate:didFinishSelector:] in GoogleSignInDependencies(GTMOAuth2Authentication_1ce8c6f89c07caddf41e7c0549106c71.o)
-[GTMOAuth2SignIn initWithAuthentication:authorizationURL:delegate:webRequestSelector:finishedSelector:] in GoogleSignInDependencies(GTMOAuth2SignIn_5bfc657f526d8c0a0b202f74ea6b8446.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

ducmaxime commented Mar 5, 2018

I try your script duplicated error symbol is fixed

but

Undefined symbols for architecture x86_64:
"_kGTMSessionFetcherStatusDomain", referenced from:
-[GTMOAuth2SignIn authCodeObtained] in GoogleSignInDependencies(GTMOAuth2SignIn_5bfc657f526d8c0a0b202f74ea6b8446.o)
"OBJC_CLASS$_GTMSessionFetcherService", referenced from:
objc-class-ref in GoogleSignIn(GIDSignIn.o)
"OBJC_CLASS$_GTMSessionFetcher", referenced from:
objc-class-ref in GoogleSignInDependencies(GTMOAuth2Authentication_1ce8c6f89c07caddf41e7c0549106c71.o)
objc-class-ref in GoogleSignInDependencies(GTMOAuth2SignIn_5bfc657f526d8c0a0b202f74ea6b8446.o)
objc-class-ref in GoogleSignIn(GIDRuntimeConfigFetcher.o)
objc-class-ref in GoogleSignIn(GIDSignIn.o)
"_GTMSessionFetcherAssertValidSelector", referenced from:
-[GTMOAuth2Authentication authorizeRequest:delegate:didFinishSelector:] in GoogleSignInDependencies(GTMOAuth2Authentication_1ce8c6f89c07caddf41e7c0549106c71.o)
-[GTMOAuth2SignIn initWithAuthentication:authorizationURL:delegate:webRequestSelector:finishedSelector:] in GoogleSignInDependencies(GTMOAuth2SignIn_5bfc657f526d8c0a0b202f74ea6b8446.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@Pash237

This comment has been minimized.

Show comment
Hide comment
@Pash237

Pash237 Mar 14, 2018

Thanks, worked like a charm!
Need to remove only two classes now:

duplicateClasses=(GTMLogger GTMNSDictionary+URLArguments)

Pash237 commented Mar 14, 2018

Thanks, worked like a charm!
Need to remove only two classes now:

duplicateClasses=(GTMLogger GTMNSDictionary+URLArguments)
@drekka

This comment has been minimized.

Show comment
Hide comment
@drekka

drekka Apr 11, 2018

Updated to work with Sign in 4.1.2 and Firebase 4.12.0. Still need to remove all the classes in the list.

Owner

drekka commented Apr 11, 2018

Updated to work with Sign in 4.1.2 and Firebase 4.12.0. Still need to remove all the classes in the list.

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