Unity iOS build error: duplicate symbols when using Firebase Unity SDK + Google VR SDK for Unity

会有一股神秘感。 提交于 2019-12-04 15:59:57

问题


I'm working on an Unity project where I'm using the Google VR SDK for Unity and the FirebaseMessaging.unitypackage from the Firebase SDK for Unity.

This combination of Google SDK's throws a duplicate symbols error when I try to build for iOS.


Minimal, Complete, and Verifiable example to reproduce the error:

Requirements:

  • iOS device (version 7.0 or later)
  • Computer with macOS
  • Latest Unity version (5.5.2f1)
  • Latest Xcode version (8.2.1)

Steps:

  1. Download the Google VR SDK for Unity (v1.20).
  2. Download the Firebase SDK for Unity (v3.0.0).
  3. Unzip the Firebase SDK for Unity.
  4. Open Unity and create a new project.
  5. Go to File > Build Settings... , select iOS and click on Switch Platform.
  6. Open Player Settings... and set a Bundle Identifier.
  7. Go to Assets > Import Package > Custom package... , select the GoogleVRForUnity.unitypackage and import all except the Demos folder.
  8. A Pop-Up window will appear. Select I Made a Backup, Go Ahead!.
  9. Another Pop-Up window will appear. Select Import Package and Import all.
  10. Go to Assets > Import Package > Custom package... , select the unzipped FirebaseMessaging.unitypackage and import all of it.
  11. File > Save project
  12. Connect the iOS device to the computer.
  13. File > Build & Run
  14. The Xcode build will fail because the project needs a signing with a team. Set it in your Xcode project to a valid one.
  15. Press the Xcode play button to build & run the project on your connected iOS device.

The project build on Xcode will end with the following error:

25 duplicate symbols for architecture arm64

The architecture changes depending of the connected iOS device, but the error is the same.


  • Is there something that we can do?
  • Is it an error that must be resolved by Google?

回答1:


This is a bug in the GVR sdk. The problem is that GVR was released including the transitive dependencies, some of which other SDKs at google (or elsewhere) depend on as well, such as firebase. Since Unity doesn't have any package management for this, we've rolled our own:

https://github.com/googlesamples/unity-jar-resolver

However GVR sdk isn't yet using this to include its transitive dependencies and so we get the conflicts.

I'm working on a fix that makes the IOSResolver above, detect this in GVR and strip the objects that should not be included.

In the meantime, here's a work-around you can use to strip the redundant objects yourself:

  1. Locate: libgvrunity.a in Assets/Plugins/iOS/libgvrunity.a
  2. Create a shell script in the folder with the following contents:

    set -ex
    lipo libgvrunity.a -thin armv7 -output libgvrunity-armv7.a
    lipo libgvrunity.a -thin arm64 -output libgvrunity-arm64.a
    
    ar -t libgvrunity-armv7.a | grep 'GTMLogger\|GTMSession' | xargs ar -dv libgvrunity-armv7.a
    ar -t libgvrunity-arm64.a | grep 'GTMLogger\|GTMSession' | xargs ar -dv libgvrunity-arm64.a
    
    lipo libgvrunity.a -replace armv7 libgvrunity-armv7.a -replace arm64 libgvrunity-arm64.a -output libgvrunity-fat.a
    
    rm libgvrunity-armv7.a libgvrunity-arm64.a
    
    mkdir -p backup
    mv libgvrunity.a backup
    mv libgvrunity-fat.a libgvrunity.a
  3. Build and run from Unity again.




回答2:


Option 1 :Go to build Settings and search for "No Common Blocks" and set it no

Option 2:

  1. Go to Build Phases in Target settings.
  2. Go to “Link Binary With Libraries”.
  3. Check if any of the libraries exist twice.
  4. Build again.

Option 3:

  1. Removed -ObjC from Other linker flag.


来源:https://stackoverflow.com/questions/42516646/unity-ios-build-error-duplicate-symbols-when-using-firebase-unity-sdk-google

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!