正如上面 Alex M 所建议的那样,Burstly 支持建议删除 libTestFlight.a,但这让我感到紧张,因为我感觉到 Burstly 将更多资源用于维护 TestFlight SDK 而不是 SkyRocket SDK。诚然,这种直觉可能是我的想象,但我无法摆脱它。
所以,我写了这个脚本。它从 libBurstly.a 中去除重复的符号并输出一个 libBurstly-noTestFlight.a,它可以无冲突地链接。对于我当前的项目,路径是硬编码的,所以如果你想使用它,你必须为你自己的项目调整脚本。
#!/bin/bash
# I install this script as $(SRCROOT)/scripts/strip_tf_duplicate_symbols, and
# run it from $(SRCROOT).
# It looks for libBurstly.a under $(SRCROOT)/Vendors/BurstlySDK.
# Sorry about the hard-coded paths. I didn't design this to be used in other projects.
if [ -d ./Vendors/BurstlySDK ]
then
echo "Preparing to strip duplicate symbols from libBurstly.a..."
else
echo "Creates Vendors/BurstlySDK/libBurstly-noTestFlight.a with duplicate symbols removed."
echo "Usage: run ./scripts/strip_tf_duplicate_symbols from the Xcode project root"
exit
fi
cd Vendors/BurstlySDK
echo "Breaking fat libBurstly.a into separate armv7 and i386 libraries..."
xcrun -sdk iphoneos lipo -thin armv7 libBurstly.a -output libBurstly-armv7.a
xcrun -sdk iphoneos lipo -thin armv7s libBurstly.a -output libBurstly-armv7s.a
xcrun -sdk iphoneos lipo -thin i386 libBurstly.a -output libBurstly-i386.a
echo "Extracting .o files into architecture-specific subdirectories..."
mkdir -p libBurstly-armv7 libBurstly-armv7s libBurstly-i386
cd libBurstly-i386
ar -x ../libBurstly-i386.a
cd ..
cd libBurstly-armv7
ar -x ../libBurstly-armv7.a
cd ..
cd libBurstly-armv7s
ar -x ../libBurstly-armv7s.a
cd ..
echo "Removing .o files with duplicate symbols..."
rm */TF_OpenUDID.o
rm */TFMessagePack.o
rm */TestFlight.o
rm */TFReachability.o
rm */TFNetworkManager.o
rm */TFMemoryMonitor.o
rm */TFDeviceInfo.o
rm */TFCrypto.o
rm */TFApplicationInformation.o
echo "Repacking architecture-specific .a files..."
cd libBurstly-i386
xcrun -sdk iphoneos libtool -static -o ../libBurstly-i386.a *.o
cd ..
cd libBurstly-armv7
xcrun -sdk iphoneos libtool -static -o ../libBurstly-armv7.a *.o
cd ..
cd libBurstly-armv7s
xcrun -sdk iphoneos libtool -static -o ../libBurstly-armv7s.a *.o
cd ..
echo "Recombining thin files into libBurstly-noTestFlight.a"
xcrun -sdk iphoneos lipo -create libBurstly-i386.a libBurstly-armv7.a libBurstly-armv7s.a -output libBurstly-noTestFlight.a
echo "Cleaning up..."
rm -rf libBurstly-armv7 libBurstly-armv7s libBurstly-i386
ls -1 libBurstly-noTestFlight.a
echo "Done"