jiulongw / swift-unity

Sample code that integrate Unity (2017.1+) scene into iOS (Swift 4.0, Xcode 9+) project.
391 stars 100 forks source link

How To Upgrade to Vuforia 7.2 + Unity 2018.1.6f + Xcode 9.4 #89

Open setoelkahfi opened 6 years ago

setoelkahfi commented 6 years ago

Vuforia Engine 7.2 introduced a new way of linking Vuforia Engine library files in iOS. Apps should use the dynamically-linked Vuforia.framework instead of the traditional static library (libVuforia.a) & headers.

Just follow the official instruction from Vuforia, with little tweaks:

  1. Find your project build folder, then copy Vuforia.framework from Unity-generated Xcode project in it. screen shot 2018-07-12 at 12 23 01
  2. Remove reference to libVuforia.a and possibly more files with red color inside Unity folder. In my case it's Bulk_Generics_8.cpp.
  3. In the General tab, “Embedded Binaries” section: Press “+” and navigate to & select Vuforia.framework from the 1 step. Make sure "Copy item if need it" checked. (Note – it should then show up both in this list, and the list of linked frameworks below – you shouldn’t need to add it to both)
  4. In the Build Settings tab:
    • Remove the old header file location from "Header search paths"
    • Remove the old static library location from "Library search paths"
    • Verify that "Runpath search paths" contains the string "@executable_path/Frameworks" (it should have been added automatically when you added the framework to the embedded binaries). Without this the app will crash very early in startup, before entering main.
  5. Now you should safely arrange the Vuforia.framework inside your Xcode project.

Tested on Vuforia 7.2 + Unity 2018.1.6f1 + Xcode 9.4.1. Let me know if you face issues.

melvinrudolph commented 6 years ago

Could you post your solution? Would be so awesome !!

setoelkahfi commented 6 years ago

Sure. Maybe a PR for this repository so we can discuss the best practice.

melvinrudolph commented 6 years ago

Okay so most of the errors are gone now but it's still not entirely working. What im left with now is:

Undefined symbols for architecture arm64: "Vuforia::TextTracker::getClassType()", referenced from: _textTrackerSetRegionOfInterest in libVuforiaWrapper.a(TextTracker.o) _textTrackerGetRegionOfInterest in libVuforiaWrapper.a(TextTracker.o) _trackerManagerInitTracker in libVuforiaWrapper.a(TrackerManager.o) _trackerManagerDeinitTracker in libVuforiaWrapper.a(TrackerManager.o) _wordListLoadWordList in libVuforiaWrapper.a(WordList.o) _wordListAddWordsFromFile in libVuforiaWrapper.a(WordList.o) _wordListAddWordU in libVuforiaWrapper.a(WordList.o) ... "Vuforia::Word::getClassType()", referenced from: TypeMapping::getType(int) in libVuforiaWrapper.a(TypeMapping.o) TypeMapping::getTypeID(Vuforia::Type) in libVuforiaWrapper.a(TypeMapping.o) "Vuforia::WordResult::getClassType()", referenced from: _updateQCAR in libVuforiaWrapper.a(Tracker.o) _determineNewWords in libVuforiaWrapper.a(Tracker.o) _wordGetLetterMask in libVuforiaWrapper.a(Tracker.o) _wordGetLetterBoundingBoxes in libVuforiaWrapper.a(Tracker.o) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Do you have any idea how to fix that ? Couldn't find any working solution for this arm64 error

setoelkahfi commented 6 years ago

That's something I encountered before moving the Vuforia.framework first to my xcode build folder.

Maybe try to clean, restart Xcode, restart your Mac? You know, Xcode :D

melvinrudolph commented 6 years ago

Yeah i also had about 200 of these error messages before i tried your solution. These are all gone now, thanks to you, except the ones i mentioned :D maybe i'll find a way

ericqqqqq commented 6 years ago

Hi setoelkahfi, I successfully built demo project, however, I get errors in run time and fails at launch screen

the error is attached.

screen shot 2018-08-01 at 4 12 19 pm

My unity is: UNITY_RUNTIME_VERSION = 2018.2.1f1; Xcode is: Version 9.4.1 (9F2000)

setoelkahfi commented 6 years ago

Oh, I forgot my PR that should fix the issue.

@ericqqqqq that's because Unity detect there's a launcher storyboard (which is in your project), but failed to load its launcher (because we don't copy it to our project).

In SplashScreen.mm, the line bool hasStoryboard = [[NSBundle mainBundle] pathForResource: @"LaunchScreen" ofType: @"storyboardc"] != nullptr; will find your default LaunchScreen.storyboard and try to load Unity launch screen, thus the error. The Xcodepostbuild.cs from this project will overwrite these lines for you.

Quick solution is rename your launcher storyboard to something else. Don't remove your launch screen, your app will rejected by AppStore.

Meanwhile I'll update my PR.

ericqqqqq commented 6 years ago

@setoelkahfi thank you very much! I got it!

capnmidnight commented 6 years ago

Would it be possible to get these instructions added to the README?

setoelkahfi commented 6 years ago

@capnmidnight I think it's not a problem. You can make the pr based on this.