从 Google Cardboard 升级到 Google VR 的项目在 Unity 中运行,但在为 iOS(XCode 或 Unity Cloud Build)构建时失败

Project upgraded from Google Cardboard to Google VR runs in Unity but fails when building for iOS (XCode or Unity Cloud Build)

我使用 Google Cardboard 开始了我的项目,然后我导入了新的 GoogleVR 包来替换它。当我在 Unity 中点击播放时,我的项目工作正常,但是当我尝试为 iOS 构建它时,我在 Xcode 项目和 Unity Cloud 构建项目上都遇到了错误。

在 Xcode:

ld: warning: arm64 function not 4-byte aligned: ltmp0 from /Users/gamedev/Desktop/VR1-iOS/Libraries/libiPhone-lib.a(unwind_test_arm64.o)
 ld: warning: arm64 function not 4-byte aligned: _unwind_tester from /Users/gamedev/Desktop/VR1-iOS/Libraries/libiPhone-lib.a(unwind_test_arm64.o)
 Undefined symbols for architecture arm64:
   "_endSettingsDialog", referenced from:
       -[DismissDialogViewController viewDidAppear:] in libvrunity.a(unity.o)
 ld: symbol(s) not found for architecture arm64
 clang: error: linker command failed with exit code 1 (use -v to see invocation)

在 Unity 云构建上:

[xcode] Undefined symbols for architecture armv7:
 9352:        [xcode]   "_endSettingsDialog", referenced from:
 9353:        [xcode]       -[DismissDialogViewController viewDidAppear:] in libvrunity.a(unity.o)
 9354:        [xcode]   "_isOpenGLAPI", referenced from:
 9355:        [xcode]       RegisterMonoModules() in RegisterMonoModules.o
 9356:        [xcode] ld: symbol(s) not found for architecture armv7
 9357:        [xcode] clang: error: linker command failed with exit code 1 (use -v to see invocation)
 9358:        [xcode] Showing first 200 warnings only
 9359:        [xcode] ** ARCHIVE FAILED **
 9360:        [xcode] The following build commands failed:
 9361:        [xcode]     Ld /BUILD_PATH/Library/Developer/Xcode/DerivedData/Unity-iPhone-gccgnjkpqhormzcosgksevxlzeea/Build/Intermediates/ArchiveIntermediates/Unity-iPhone/InstallationBuildProductsLocation/APPLICATION_PATH/vr1.app/vr1 normal armv7
 9362:        [xcode] (1 failure)

我注意到这类问题的大部分答案都提到了SourceTree(我正在使用的)在推送源代码时忽略了.dll文件。目前我的工作目录中没有任何 .gitignore 文件。

更新 我已经升级到 Unity 5.6 并且错误发生了一些变化:

"_endSettingsDialog", referenced from:
-[DismissDialogViewController viewDidAppear:] in libvrunity.a(unity.o)

Undefined symbols for architecture arm64:
  "_isOpenGLAPI", referenced from:
      _iOSDevice_isOpenGLAPI_m3529398287 in Bulk_Assembly-CSharp_0.o
     (maybe you meant: _iOSDevice_isOpenGLAPI_m3529398287)
ld: symbol(s) not found for architecture arm64

在链接的库之间检查时(在构建设置中)我注意到我有 libvrunity.alibgvrunity.a 所以我删除了第一个并且错误消失了,但我仍然有第二个关于OpenGL。奇怪的是,这个项目在统一中完美无缺。

您似乎缺少文件或一些旧文件未删除:我建议删除所有 iOS 插件并重新导入正确的插件。

显然都是关于 Google VR SDK 的。当前版本 1.30 不支持 Unity 5.6 中的原生 iOS。

他们唯一的解决方法是:

  • 正在删除我的项目中的 GoogleVR 插件(以及所有对它的引用)
  • 用简单的光线投射替换 GazeVR 视图跟踪,以便在用户正在查看的对象上激活特定方法
  • 导出到 iOS
  • 时在 "Building Setting" 中激活虚拟模式
  • 正在从 XCode 项目中删除 libvrunity.alibgvrunity.a
  • 确保位码支持设置为否
  • 导入 GoogleVR 作为 cocoapod。

不幸的是,这个过程阻止我在 Unity 编辑器中显示立体视图。

我们需要等待 1.40 更新。我已经开了一个issue on GoogleVR GitHub repository