4

当我尝试将Google VR SDK ('GVRSDK') 添加为 Podfile 依赖项时,我在使用 React Native 时遇到了问题,而且它很容易复制。

脚步:

  1. 创建一个新的空白 React Native 项目。运行它react-native run-ios以确保它正常工作。
  2. cd ios
  3. pod init
  4. 添加pod 'GVRSDK'到 Podfile,执行pod update
  5. cd ..
  6. 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)
4

1 回答 1

2

您可以通过删除 libGVRSDK.a 中的重复符号来解决它。lipoar命令用于反汇编几种架构中的库文件并将它们重新归档到另一个文件中。

我制作的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 install 时调用此脚本,它会更有用。

播客文件

post_install do |installer|
    system(". ./pod_post_install.sh")
end

我相信它会有所帮助。

于 2017-12-07T09:44:48.433 回答