A better way to integrate Unity3D within a native iOS app

Update: I’ve created a new tutorial for Xcode 7 & Unity 5.

Last year I published a blog post about how to integrate Unity3D within a native iOS application.

Last week I found a better way to integrate Unity3D within a native iOS app, which also eliminates some issues with my previous version.  Because it’s quite a long explanation to do and I noticed in my previous blog post that not everything was crystal clear, I’ve made a video tutorial how you can achieve this.

I hope this can help some of you guys out, because integrating Unity3D within a native iOS app isn’t that easy, but I’m really happy with the setup that I have right now.


The version of Unity that I use is 4.6.7f1 and Xcode 6.4.

Video tutorial: integrate Unity3D within a native iOS app

You can check out the video on Vimeo – Add Unity3D in native iOS application. If you have any questions, just put them in the comments, or contact me via Twitter. I hope you know understand how to integrate Unity3D within a native iOS app.

Share this post

79 Responses

  1. Thanks for this!

    FWIW, I found that I also needed to include il2cpp_output in my enclosing project in order to avoid linker errors with the methods referenced by RegisterMonoModules.cpp. (RegisterAllClasses, RegisterAllClassesIPhone, RegisterAllStrippedInternalCalls). I was using Unity 4.6.8f1 and XCode 6.4.

      1. oops my bad!!!

        i was using ‘I’ for India instead of ‘l’ for london

        in ‘-weak-ISystem’

        it is fixed for good now…

        Thanx a ton… Frederick

    1. The correct flags for ‘other linker flags’ are:
      -weak_framework CoreMotion -weak-lSystem

      If that doesn’t work, it could be you have not linked another library correctly.

      1. oops my bad!!!

        i was using ‘I’ for India instead of ‘l’ for london

        in ‘-weak-ISystem’

        it is fixed for good now…

        Thanx a ton… Frederick..

    2. Hi, just wanted to know if you were able to resolve this ‘Unkown Argument’ error?

  2. Hi! it work well with my iPhone5, but when I change the platform to iPhone6 plus, there are lots of link error 🙁 any idea?

    1. I only need to integrate Unity within iPad apps, so I’m afraid I won’t be able to help you out. Although it would be weird that there is a difference between an iPhone 5 & iPhone 6 plus (apart from it’s screen size).

    2. Oops, I just figured out it’s not about the iPhone 5 or 6.
      It’s about real machine or virtual machine. I was testing iPhone6 plus with virtual simulator.
      I did more test and found my real iPhone 5 works well, but the virtual iPhone 5 got link error too, Weird o_O

  3. Thanks very much for your great tutorials. I have a vuforia project which I want to import in my other ios project. I tried your tutorial , but in the end I get errors on POPVector.h, POPAnimationRuntime.h, POPAnimationInternal.h , POPPropertyAnimation.h
    There are 19 errors in the project. for example in POPVector.h I’m getting below errors:
    -Lexical or Preprocessor Issue: Too many arguments provided to function-like macro invocation
    -Semantic Issue: No type named ‘shared_ptr’ in namespace ‘std’
    -Parse Issue : Expected unqualified-id
    -Semantic Issue : No type named ‘shared_ptr’ in namespace ‘std’
    -Parse Issue : Expected unqualified-id

    there must be something wrong which gives all these errors in these POP… files.
    I’ll appreciate if you can help me with this.
    Thanks very much for your help

  4. I have follow you by doing this ,it can built successed! but it broke at :
    UIApplicationMain(argc, argv, nil, [NSString stringWithUTF8String:AppControllerClassName]);

    if i can’t do it right now , i could lost my job..

  5. Thanks very much for your great tutorials. I have a vuforia project which I wanted to add to an existing ios project. I followed the tutorial and fixed many errors and it is built successfully. but when I run it on the device it throws an exception on UnityAppController.mm and tells that “createViewHierarchyImpl is deprecated and will not be called. Override willStartWithViewConroller.” As I searched it seemed it is because some of the updates in new versions of ios.
    I’m using unity5.1.2f and Xcode 6.4 running it on an ios 8.4.1 device.
    I’ll appreciate if you can help me with this.
    Thanks very much

  6. Hi!
    First of all i have to thank for the Above Video
    I have tried with the video in Build Phase->Runscript i had include the following script,

    rm -rf “$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Data”

    cp -Rf “$PROJECT_DIR/../../Heart3Ds_NoAR/Data” “$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Data”

    I have an build error:

    Cp: “/Users/user/Desktop/Heart3Ds_NoAR/Data”: No such file or directory

    what seems to be wrong.

  7. Hi @thenerd_be:disqus, thanks for the tutorials on this subject, I’ve found them very educational! Have you tried doing this in XCode 7? I’m getting a “Thread 1: signal SIGABRT” error after removing the storyboards from the native xcode project.


    1. You probably have forgotten to delete the key `Main storyboard file base name` in your Info.plist. If Xcode sees this key in that file, it will try to load that Storyboard. Just delete it and you should be fine.


      1. I just tried to build the sample arkit project – vbut just get a black screen after tyeh unity logo – please see screen grab of Xcode .Please give me step by step how to build settings,camera settings.thanks in advance.

    2. hey, anosognosia, did you manage to find out why you did get the error?
      im facing same kind of issues :s

  8. Hi! Thanks for the tutorial. I have an issue. Whatever I do, this error persists
    “ld: library not found for -liPhone-lib
    clang: error: linker command failed with exit code 1 (use -v to see invocation)”.
    I am not able to solve it. I’m using unity 5 and xcode 7.

    1. Hi,

      I haven’t had the chance to test it with Unity 5 yet. As far as I know, we’ll stick to Unity 4 for a little while longer.

      Sorry I won’t be able to help you with Unity 5!

          1. Well, I’m planning to try with unity 4. I don’t know whether it is the problem with the new version of xcode or unity.

          2. I integrated my entire native project files into the unity imported to xcode project and followed the second half of the tutorial. It works fine now.

        1. Good news, I’ve just downloaded Unity 5 and got it working with Xcode 7.1.

          I’ll try to create a new video tutorial this weekend showing you the process.



          1. Hi thanks. I have some doubts. In my project I am using vuforia in unity as one window and rest of native files in the second. I wanted to pass the name of the recognised reference from vuforia to objective c for some further purposes. I can get the name in unity but how will I access that in objective c? Is it possible that I can access the database values from native in unity?

      1. Hi, the error persists “ld: library not found for -liPhone-lib
        clang: error: linker command failed with exit code 1 (use -v to see invocation)”. i am using unity 4.6.7f1 and xcode 7.0.1.

  9. Hi! Thanks a lot for this tutorial, it’s been extremely useful being one of the few (if not THE only one) that shows the full process of integration and with mostly updated versions of Xcode and Unity.

    However, I’m experiencing the same error as ‘Babybet’, whatever I do I always get the “ld: library not found for -liPhone-libclang: error: linker command failed with exit code 1 (use -v to see invocation)” when using Xcode 7 and Unity 5.

    I’ve cleaned the project, cleaned derived data folder, I’ve deleted and readded libiphone as you do in the tutorial but still no luck.

    Any idea on this one? I’ve noticed that the library being added is called “libiPhone-whatever” but the missing one is called “liPhone-whatever”…
    Any help would be really appreciated!
    Thanks for your time 🙂

      1. Thanks for the tutorial Frederik. Im really looking forward to the Unity 5 tutorial as I am also getting stuck with undefined symbols.

    1. Removing libiPhone-whatever from xcode, renaming the file to liPhone-whatever and adding it back again to xcode worked for me

  10. Hi ,
    Its very helpful article and very well done but I am not able to find out how it will work for storyboard as our entire app is build in storyboards and it difficult to change this stage .I got impression that you are deleting the existing storyboards and then not adding again.

  11. Hello everybody,

    Thanks frederik for this very helpful tutorial.

    At the 23d minute, when compiling I have an issue saying that library not found for -lVuforia
    error: linker command failed with exit code 1 (use -v to see invocation)

    I have tried to work on the library search paths and header search paths and also delete libvuforia.a from “link binary with libraries”
    Do you have any idea or any help for me, that would be amazing ?
    Thanks in advance

    1. Do you think it is normal that in my Build Phases “Link with binary libraries” I have 22 items instead of you getting 19.
      I have libVuforia.a and libQCARUnityPlayer.a, and my problems are coming from those two. But if I erase them, it get worse in terms errors, I am a little bit lost

  12. I’m trying to complete this walkthrough with Xcode 6 and Unity 5.

    I’m getting errors (nearly a thousand) at the 26th minute of the video, lots and lots of Undefined symbols for architecture armv7, all are cv:: and std:: missing methods.

    I put back the C++ Standard library to ‘libc++ (LLVM C++ sdt lib with C++11 support)’, and all the std:: error were gone.

    In Unity 5, opencv is embed as a framework, so I have to drag it manually from the Unity project export into my linked frameworks list.

    Now my project compiles, but I have a crash at launch on the Unity DisplayManager. Looking for clues why it happens.

    1. I had the same issue with the blank camera feed. The issue was that I wasn’t using VuforiaNativeRendererController, it was just using UnityAppController. Try throwing down a breakpoint to check that the Vuforia code is getting executed.

      1. This solution didn’t fit my needs so I prefered make the project exclusively with the new Unity GUI system. Thanks anyway for the help.

  13. I’m getting errors in all c++ try catch blocks. It’s says the e.ex is undeclared.
    catch(IL2CppExceptionWrapper& e){
    __last_unhandled_exception = (Exception_t229 *)e.ex;
    goto FINALLY_001a;

  14. Dear Frederik,

    Do you have any idea when you might be able to upload a new video in which you show how to do this with Unity 5? Thanks a lot for your time!

    1. I would love that as well. Your tutorial is really good, but doesn’t work for Unity5.
      I would pay for that 🙂

  15. Hi, How to kill or quit or unload the unity from iOS App when I clicks a button from native. When I click quit it should quit only unity and not the iOS App. Can you give your views how to achieve it?

  16. Hi, Its good to go till displaying the Unity view. but when i try to add “UnityAppController.h” in pch file then it does not give me the Classess suggestions. Can you please let me know if i have missed something?


  17. hey.. Can you help me creating a plugin for ios native. My question is : How can I pass a uiview from unity to xcode..?

    Actually I want to show ad to an unity view from xcode.. So for that I need to take a view from unity.

  18. hello. I made the tutorial again and i have this issue .
    CameraCapture.mm:116:2: Use of undeclared identifier ‘static_assert’; did you mean ‘static_cast’?

  19. Hi.. After many attempts to compile, I get an error: library not found for -lVuforia. Any idea on how I could be able to fix this?

  20. Great tutorial! I’m wondering if this can be integrated with the imessage extension (ios10)
    I couldn’t get it to load because there’s no appdelegate file. do you have any suggestions how I can tackle that?

  21. Hi! thanks for Tutorial.

    I have the Unity- iOS integration and is working. I was wondering if it is possible when I click a button in my Native Swift iOS app get the score label of a game object “MasterScore” that have .js file as script in Unity.

    This is the .js script in Unity
    static var gsocre: int = 0;

    function OnGUI() {

    GUI.Label (10, 10, 100, 20), “Score: ” + gscore;


    The question is how can I do in my swift project to get the gscore

    var myScore = “”

    myScore = “The gscore value fromUnity thats is inside the object “MasterScore””

    Thanks , I hope you can tell me a solution for that question.

  22. Hi

    i’m getting error while setup unity 5.6.2f1 project in swift native code. I’m using Xcode 8.3.3

    error : ld: library not found for -lzbar

  23. hi! thanks for an amazing article!!!

    I am following your video on xcode 9 and Unity 2017.2.0f3. But I get a weird bug. can you have a look: …/Unity/Classes/Native/Bulk_mscorlib_7.cpp:18669:100: No member named ‘BufferToBSTR’ in ‘il2cpp::icalls::mscorlib::System::Runtime::InteropServices::Marshal’. Any idea?

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts