当我尝试将Google VR SDK('GVRSDK')添加为Podfile依赖项时,我遇到了React Native的问题,并且它很容易复制。
步骤:
react-native run-ios
运行它以确保其有效。cd ios
pod init
pod 'GVRSDK'
添加到Podfile,执行pod update
cd ..
react-native run-ios
该项目因以下错误而崩溃:
duplicate symbol __ZN3fLI9FLAGS_novE in:
/foo/ios/Pods/GVRSDK/Libraries/libGVRSDK.a(vlog_is_on.o)
/foo/ios/build/Build/Products/Debug-iphonesimulator/libReact.a(vlog_is_on.o)
duplicate symbol __ZN3fLI7FLAGS_vE in:
/foo/ios/Pods/GVRSDK/Libraries/libGVRSDK.a(vlog_is_on.o)
/foo/ios/build/Build/Products/Debug-iphonesimulator/libReact.a(vlog_is_on.o)
duplicate symbol __ZN6google13RemoveLogSinkEPNS_7LogSinkE in:
/foo/ios/build/Build/Products/Debug-iphonesimulator/libReact.a(logging.o)
/foo/ios/Pods/GVRSDK/Libraries/libGVRSDK.a(logging.o)
duplicate symbol __ZN6google10AddLogSinkEPNS_7LogSinkE in:
/foo/ios/build/Build/Products/Debug-iphonesimulator/libReact.a(logging.o)
/foo/ios/Pods/GVRSDK/Libraries/libGVRSDK.a(logging.o)
ld: 4 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
** BUILD FAILED **
The following build commands failed:
Ld build/Build/Products/Debug-iphonesimulator/foo.app/foo normal x86_64
(1 failure)
答案 0 :(得分:2)
您可以通过删除libGVRSDK.a中的重复符号来解决此问题。 lipo 和 ar 命令用于反汇编多个体系结构中的库文件,并将它们重新归档到另一个文件中。
我按如下方式编写了shell脚本:
pod_post_install.sh
#!/bin/bash
cd ./Pods/GVRSDK/Libraries/
lipo -info libGVRSDK.a
# Divide to each platform
lipo -thin armv7 libGVRSDK.a -output libGVRSDK_armv7
lipo -thin i386 libGVRSDK.a -output libGVRSDK_i386
lipo -thin x86_64 libGVRSDK.a -output libGVRSDK_x86_64
lipo -thin arm64 libGVRSDK.a -output libGVRSDK_arm64
# Delete duplicate file
chmod 777 libGVRSDK_armv7
chmod 777 libGVRSDK_i386
chmod 777 libGVRSDK_x86_64
chmod 777 libGVRSDK_arm64
ar -dv libGVRSDK_armv7 vlog_is_on.o
ar -dv libGVRSDK_i386 vlog_is_on.o
ar -dv libGVRSDK_x86_64 vlog_is_on.o
ar -dv libGVRSDK_arm64 vlog_is_on.o
# rm libGVRSDK.a
lipo -create libGVRSDK_armv7 libGVRSDK_i386 libGVRSDK_x86_64 libGVRSDK_arm64 -output libGVRSDK.a
# Delete media
rm libGVRSDK_armv7
rm libGVRSDK_i386
rm libGVRSDK_x86_64
rm libGVRSDK_arm64
cd ../../../
如果在运行每个pod安装时调用此脚本,则会更有用。
Podfile
post_install do |installer|
system(". ./pod_post_install.sh")
end
我相信它会有所帮助。