Integrate Unity 5 in a native iOS app with Xcode 7

Integrate Unity 5 in a native iOS app

A few months back I published a blog post about how to integrate Unity3D within a native iOS application.  This tutorial was written for Xcode 6 & Unity 4 and in the comments there were a lot of requests for a new tutorial.

Tonight I found the time to make the video tutorial on how to integrate Unity 5 in a native iOS app with Xcode 7, so I hope you enjoy it!

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.

Prerequisites

The version of Unity that I use is 5.2.2f1 and Xcode 7.1.

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

134 Responses

  1. This tutorial is amazing! We have tried it, integrating is success, but when we are a Vofuria Project, when we start the Unity, we just can see black screen, and we can’t find out the problem.Can u help?

      1. Hi, I faced your same problem. My problem was because when vuforia unity works before native integration, the “AppControllerClassName” is not “UnityAppController” but “VuforiaNativeRendererController”. So if we change “AppControllerClassName” to AppDelegate ,
        “-(void)shouldAttachRenderDelegate” in VuforiaNativeRendererController will not be called. Thats why my screen showed black. Check your Libraries>Plugins>ios. There is a file “VuforiaNativeRendererController.mm”. Comment “IMPL_APP_CONTROLLER_SUBCLASS(VuforiaNativeRendererController)”. Copy paste the “- (void)shouldAttachRenderDelegate” method to UnityAppController.mm. See whether it works.

        1. I’ve added another solution in the comment above, in your version you will have to re-add the `shouldAttachRenderDelegate` every time you rebuild from Unity which can be a pain in the ass 🙂

          1. Hi Frederik! your tutorial are awesome .Could you do some extra tutorial after this about how implement vuforia? So many people want to do this. Will be very useful. Thank you!!!

          2. I’ll see what I can do. At the moment I have a lot of other work which has priority right now.
            Maybe in the upcoming weeks I’ll try to make a Vuforia tutorial.

            Kind regards,
            Frederik

          3. Hi, Frederik!!
            Thanks, this was very helpfull for me and my teammates for an important project using Unity, Vuforia, Objective C and Swift.
            As you said it will be great to have an complete tutorial of that, but I have a crazy idea, we create a project demo using your tutorial and maybe we can help you sending a video with final little steps for connecting with Vuforia and Unity. This can help you (time trouble for making it) and help other people that have the same problem as we have it.

        2. Please I try to implement Vuforia, i have follow all steps of this video but i don´t know the steps to follow after this to makes vuforia works. Thank you babybet

      2. Yeah with vuforia you have to remove the following line of code in the file

        `Libraries/Plugins/iOS/VuforiaNativeRendererController.mm

        
        //IMPL_APP_CONTROLLER_SUBCLASS(VuforiaNativeRendererController)`
        

        Then you have to add de `renderDelegate` in your AppDelegate file.

        
        self.unityController = [[UnityAppController alloc] init];
        self.unityController.renderDelegate = [[VuforiaRenderDelegate alloc] init];
        UnityRegisterRenderingPlugin(NULL, &VuforiaRenderEvent);
        

        At the top of AppDelegate, you have to add the following line of code, right before the @implementation AppDelegate

        
        extern "C" void VuforiaRenderEvent(int marker);
        

        Kind regards,

        Frederik

        1. Dear Frederik,

          Using your and Babybet’s suggestions I’ve managed to get my camera working. Unfortunately, nothing happens when I point it at the marker. Perhaps I implemented the Event part wrong?

          I’ve tried both the way you described as well as a equivalent for Swift (my project is in Swift), neither seem to work.

          Any ideas? Thanks again for your time!

          1. I’ve implemented Vuforia and it detects the marker but the screen is black, i’ve also implemented shouldAttachRenderDelegate but it’s never called

            
            
            #import "AppDelegate.h"
            
            #import "VuforiaRenderDelegate.h"
            
            // Unity native rendering callback plugin mechanism is only supported
            
            // from version 4.5 onwards
            
            #if UNITY_VERSION>434
            
            // Exported methods for native rendering callback
            
            extern "C" void VuforiaRenderEvent(int marker);
            
            #endif
            
            @interface AppDelegate ()
            
            //Our navigation Controller for the Application
            
            @property (nonatomic, strong) UINavigationController *navVC;
            
            @end
            
            @implementation AppDelegate
            
            - (UIWindow *)unityWindow {
            
                return UnityGetMainWindow();
            
            }
            
            - (void)showUnityWindow {
            
                
            
                
            
                [self.unityWindow makeKeyAndVisible];
            
            }
            
            - (void)hideUnityWindow{
            
                
            
                [self.window makeKeyAndVisible];
            
                
            
            }
            
            - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
            
                self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
            
                self.window.backgroundColor = [UIColor redColor];
            
                
            
                ViewController *viewcontroller = [[ViewController alloc] initWithNibName:nil bundle:nil];
            
                
            
                self.navVC = [[UINavigationController alloc] initWithRootViewController:viewcontroller];
            
                
            
                self.window.rootViewController = self.navVC;
            
                
            
                self.unityController = [[UnityAppController alloc] init];
            
                [self.unityController application:application didFinishLaunchingWithOptions:launchOptions];
            
                    
            
                [self.window makeKeyAndVisible];
            
                
            
                return YES;
            
            }
            
            - (void)applicationWillResignActive:(UIApplication *)application {
            
                
            
                [self.unityController applicationWillResignActive:application];
            
            }
            
            - (void)applicationDidEnterBackground:(UIApplication *)application {
            
              
            
                [self.unityController applicationDidEnterBackground:application];
            
                
            
            }
            
            - (void)applicationWillEnterForeground:(UIApplication *)application {
            
             
            
                [self.unityController applicationWillEnterForeground:application];
            
                
            
            }
            
            - (void)applicationDidBecomeActive:(UIApplication *)application {
            
             
            
                [self.unityController applicationDidBecomeActive:application];
            
                
            
            }
            
            - (void)applicationWillTerminate:(UIApplication *)application {
            
                [self.unityController applicationWillTerminate:application];
            
                
            
            }
            
            - (void)shouldAttachRenderDelegate
            
            {
            
                self.unityController = [[UnityAppController alloc] init];
            
                self.unityController.renderDelegate = [[VuforiaRenderDelegate alloc] init];
            
                UnityRegisterRenderingPlugin(NULL, &VuforiaRenderEvent);
            
                
            
                
            
                // Unity native rendering callback plugin mechanism is only supported
            
                // from version 4.5 onwards
            
            #if UNITY_VERSION>434
            
                UnityRegisterRenderingPlugin(NULL, &VuforiaRenderEvent);
            
            #endif
            
            }
            
            @end
          2. Ok i fixed it, you should call shouldAttachRenderDelegate from “UnityAppController+Rendering.mm” in callbackGfxInited

            In Classes > UnityAppController+Rendering.mm > line 72 callBackGfxInited

            replace the method callbackGfxInited by this:

            
            
            #import "AppDelegate.h"
            
            - (void)callbackGfxInited
            
            {
            
            	InitRendering();
            
            	_renderingInited = true;
            
            	[self shouldAttachRenderDelegate];
            
                
            
               
            
                //(firetrap)
            
                AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
            
                [delegate shouldAttachRenderDelegate];
            
                
            
            	[_renderDelegate mainDisplayInited:_mainDisplay.surface];
            
            	[_unityView recreateGLESSurface];
            
            	_mainDisplay.surface->allowScreenshot = 1;
            
            }
            
            
          3. Thank you Fábio to your answers! But i have a problem with this line , could you know why happens this?

          4. Then You have to change something in AppDelegate.h and AppDelegate.mm? Your previous post with AppDelegate.h is correct?

          5. Add you added the “shouldAttachVuforiaRenderDelegate” to your AppDelegate.h?

          6. This is my AppDelegate.h:

            #import
            #import “ViewController.h”

            @interface AppDelegate : UIResponder

            @property (strong, nonatomic) UIWindow *window;
            @property (strong, nonatomic) UIWindow *unityWindow;
            @property (strong, nonatomic) UnityAppController *unityController;

            – (void)showUnityWindow;
            – (void)hideUnityWindow;
            – (void)shouldAttachVuforiaRenderDelegate;

            @end

            This is AppDelegate.mm:

            – (void)shouldAttachVuforiaRenderDelegate {

            self.unityController = [[UnityAppController alloc] init];

            self.unityController.renderDelegate = [[VuforiaRenderDelegate alloc] init];

            UnityRegisterRenderingPlugin(NULL, &VuforiaRenderEvent);

            //Unity native rendering callback plugin mechanism is only supported
            // from version 4.5 onwards

            #if UNITY_VERSION>434

            UnityRegisterRenderingPlugin(NULL, &VuforiaRenderEvent);

            #endif

            }

            And the UnitAppController.mm:

            #import “AppDelegate.h”

            – (void)shouldAttachRenderDelegate {

            AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;

            [delegate shouldAttachVuforiaRenderDelegate];

            }

            When te app runs and i touch “Show unity” log says:

            2015-11-20 14:59:55.999 Unity5Native[8398:3795519] [ViewController] Show unity button touched
            2015-11-20 15:00:02.639 Unity5Native[8398:3795519] [ViewController] Show unity button touched
            2015-11-20 15:00:03.269 Unity5Native[8398:3795519] [ViewController] Show unity button touched
            2015-11-20 15:00:03.771 Unity5Native[8398:3795519] [ViewController] Show unity button touched

            Thank you Fábio for your time!

          7. Iam not an objective c genius this is my first time Codding in ios but your first import it’s not with an error?

          8. Only first time that i have running the app it changed to UnityWindow. But only see black background

        2. Hi Frederik,
          thanks for this awesome tutorial. Helped me alot.
          I am now facing problems with integrating Vuforia, too.

          I did what you wrote here (you also have to rename the AppDelegate to .mm) and now I can perfectly see my camera image but tracking doesn’t work. nothing happens. no console log, nothing. do you have any idea?

          in my unity project my target is setup inside the imageTarget and the target is activated in my ARCamera as well.

          I’d love to see a Vuforia tutorial, too 🙂

          1. I got it to work now 🙂
            Just had to add the /Data/Raw/QCAR folder in Build Phases -> Copy Bundle Resources although I had it already in my Vendor/Unity/Data folder reference. So now I have my .dat and .xml of the image target twice, but hey it works

        3. Is there a way to fix the black screen issue without having to change the AppDelegate to .mm ? When i do that, the CGLConfiguration from my GoogleMaps pod says ‘Use of @import’ when modules are disabled but Enable Modules is set on YES. Im feeling stuck between a rock and a hard place.

  2. Woot! Thanks Frederik. It worked! This is a great starting point for people trying to launch their Unity games from native apps.

  3. Great tutorial, thanks.
    I see in the video that you hide the unity window with “[self.window makeKeyAndVisible]”. How can I call this method from Unity? Or is there another way to cancel the Unity scene and go back to the native screen?
    Thank you!

  4. i all ready have the existing code with storyboard. i like to add the button i home page which it will redirect me to unity game. how can i achieve this?. thanks in advance

  5. Hi people! I have follow all steps. I want to use Vuforia but when i compile get image error.
    Also i have commented line:

  6. Hi team. I have unity+vuforia same versions of this Tutorial. When i finish this tutorial i go to Library Search Paths (build settings tag) and i add folder where is libVuforia.a.

    Next step: I go to VuforiaNativeRendererController.mm and comment the line //IMPL_APP_CONTROLLER_SUBCLASS(VuforiaNativeRendererController)

    I don´t know what´s next step. I get allow permissions to Camera and when i tap to “ShowUnity Button” i get blackscreen.

    All help is welcome 🙂 Thank YOU!

  7. Hi people! I have an important project and i have so many problems to implement vuforia with this tutorial. Anyone get this? Could share the project will be very useful. Thank you!!

  8. Hrmm, I can’t get a build to run.. its always missing a header, every time i get “il2cpp-config.h” file not found

  9. Lot of run time errors followed this tutorial step by step. Using it in xcode 7.2 and unity 5.3.0f4 . Also Can we have this video in youtube? 🙂

  10. Lot of run time errors followed this tutorial step by step. Using it in xcode 7.2 and unity 5.3.0f4 . Also Can we have this video in youtube? :)1

  11. 1. Lot of run time errors followed this tutorial step by step. Using it in xcode 7.2 and unity 5.3.0f4 . Also Can we have this video in youtube? 🙂

  12. Thank you so much for this tutorial Frederik! I am having an issue trying to complete this tutorial with a Unity Project that’s using the Google Cardboard SDK. Specifically, I am getting Uncaught exception: NSInvalidArgumentException: -[CardboardAppController unityController]: unrecognized selector sent to instance 0x15f6c33b0.
    Xcode sees two AppControllers, the “CardboardAppController.mm” in the iOS/Plugins/ folder, and the “UnityAppController.mm” in the imported “Classes” folder… Any advice on how to merge or bridge the two?

  13. Hi Frederik !
    Great job, but do you managed to display Unity in a subview of the native window of an existing project ?
    For me, it works in a new “Hello World” project, but not in my real project, in this case the app crashes with EXC_BAD_ACCESS in UnityPreload 🙁

    1. I am having this exact same issue. It fails inside UnityAppController::UnityInitApplicationNoGraphics, something wrong with the MountHandler/FileSystem?

      1. Hi Andy, were you able to find the cause for crash? I am facing the same problem right now. Thanks in advance!

    2. Hi Sébastien, were you able to find the cause for crash? I am facing the same problem right now. Thanks in advance!

      1. Hi Jayesh,
        Unfortunately not, and as it was a POC we decided to drop this integration 🙁

  14. Hi Frederik, thank you for this great tutorial!

    All works well. I would to know how can I call my CSHARP class and relative methods or simply the “default” animations of the asset?

    My current error is:
    “Undefined symbols for architecture arm64:
    “_SpiderController__ctor_m6_0″, referenced from:”

    I’ve found this

    http://www.markuszancolo.at/2015/04/unity-5-with-il2cpp-into-ios/

    but I’m not able to integrate with your tutorial.

    Thanks!

    1. same issue while trying to add c sharp scripts to the unity code base and trying to build the xcode project. Could you please let me know incase if you find any solution for this.I am really facing a tough time to resolve this. Tried by chaning the scripting backend from il2cpp to mono2x and all other combinations in player settings. But none of them worked fine 🙁

    2. Hey Alessio. I fixed these issues in my project.The issue was not with the unity,We have to re import the native class cpp files from the unity generated xcode project to our project and it would have been created those files for you.

      1. Thank you ravoori for suggestions, actually I’m not working on the project of two month ago, but I remember I had fixed developing in mono2x

  15. Hi, Frederik. Great tutorial. You helped us a lot, really appreciate it.

    We could create a unityview window using unitygetmainwindow, and it worked fine.

    But unfortunately we failed to resize it or create a subview. We think we should use either UnityGetGLViewController or UnityGetGLView, however they never worked for us. We are Unity3d programmers, and quite new with IOS. Could you give us a hint?

    Thanks

  16. Hello Frederik! First, i’m amazed that people do all this work and then care to share it. Hope i can do the same some day!

    This said, i am having the same problem that prajeetshrestha submitted about 20 days ago. The errors he show (and that i show too) seem to be pointing all to the foundation framework. I work also with 7.2 and the latest ios9.

    Can you tell us something about it? Some clue, as to where to point, not only “some build setting”, because theres a lot of build settings you made us change 😀

    Thank you very much again!

  17. Hi! I’ve been following the tutorial but I’m having some issues when it comes to compile and show the blue view. The error I’m facing is the following: ‘Unknown type name ‘UnityViewControllerBase” on UnityAppController.h on line 24. I workarounded this by commenting the import of UnityAppController.h in prefixHeader.h and doing it on AppDelegate.h, but, when I try to create the AppDelegate in UnityAppController.h the build fails with the following error: Use of undeclared identifier ‘AppDelegate’. What can I do?

    1. Same problem here. I tried to move the #import into individual files but then I hit a problem when modifying the UnityAppController file to refer to my AppDelegate.h. I’ve triple-checked build settings and can’t figure out what’s different from the example. ARG!!

      Big thanks for the tutorial though, I’m so close!

      1. Hi, i managed to get it works.

        So, after i comment the #import “UnityAppController.h” line in PrefixHeader.pch and put the line #import “UnityAppController.h” in AppDelegate.h, I encounter the same problem (as stated above). I manage to solve it by using the method used in https://github.com/blitzagency/ios-unity5#adjust-the-getappcontroller-function-in-unityappcontrollerh. In summary (credit to blitzagency from the above url), I change the

        inline UnityAppController*GetAppController()
        {
        return (UnityAppController*)[UIApplication sharedApplication].delegate;
        }

        to

        NS_INLINE UnityAppController* GetAppController()
        {
        NSObject* delegate = [UIApplication sharedApplication].delegate;
        UnityAppController* currentUnityController = (UnityAppController *)[delegate valueForKey:@”unityController”];
        return currentUnityController;
        }

        That way, it will point to the correct unityController without triggering the “Use of undeclared identifier ‘AppDelegate'”.

        I hope it helps and thank you very much for the tutorial!

        1. Xcode Version: 7.3
          Unity runtime version:5.3.5f1
          —————

          I meet the same problem : “Unknown type name ‘UnityViewControllerBase’ blablabla…” too. And I follow your solution, it works, but we just need to do part of it.


          Step 1: Comment the #import “UnityAppController.h” line in PrefixHeader.pch

          Step 2: Put the line #import “UnityAppController.h” in AppDelegate.h

          then, I run the app, it works.

    2. I have the same problem: ‘Unknown type name ‘UnityViewControllerBase” on UnityAppController.h on line 24. So I also ave errors in UnityViewControllerBaseiOS.mm

      1. Cleaning project the errors in UnityViewControllerBaseiOS.mm disappeared. Still ‘Unknown type name ‘UnityViewControllerBase”. I tried William’s solution but it doesn’t work for me.

  18. Hi bro! Thank u so much for this tutorial and i learnt a lot by this tutorial. But i have another problem and here it is. I used vuforia for my unity app. when i run the app it gets the following erro “library not found for -lVuforia” can u please help me. I want to integrate ar to an existing iOS app

  19. Hi Frederik!
    Thanks a lot for this wonderful tutorial. But i’m having an issue to integrate a project which is using Vuforia for AR. So can u please add a new tutorial for Vuforia example.

  20. Hi! Thanks for the tutorial, it is really good and useful, however I am getting a problem at some point. After modifying appDelegate and trying to running first time I got an error link and I cant figure out how to fix it… error is the following:

    Undefined symbols for architecture arm64:
    “RegisterStaticallyLinkedModulesGranular()”, referenced from:
    RegisterStaticallyLinkedModules() in libiPhone-lib.a(RegisterStaticallyLinkedModules.o)
    “RegisterAllClasses()”, referenced from:
    InitializeEngineNoGraphics() in libiPhone-lib.a(SaveAndLoadHelper.o)
    ld: symbol(s) not found for architecture arm64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    Any idea?? I have already checked when I export in Unity to set architecture: Universal and scriptingBackend to il2cpp

    Thanks a million in advance! 🙂

    1. Hi Juan,
      i have similar error as yours. You can try the following solution, re-add/add these framework in your project build phrases (link Binary with Libraries) Security, System Configuration or the libiPhone Lib.a in your libraries folder. I did this to solve the following error:
      ld: symbol(s) not found for architecture arm64
      clang: error: linker command failed with exit code 1 (use -v to see invocation)

      (source from: http://answers.unity3d.com/questions/1110053/anyone-else-having-issues-with-53-and-xcode-72.html)

  21. I followed all of the steps and it works well. But my iPhone camera does not close while the app is running, and my phone is heating up because of camera. I don’t know how to stop or close the camera.

    CameraCapture.mm inside the Unity classes contains the following, but I have no idea how to call this method from my native ViewController:

    extern “C” void UnityPauseCameraCapture(void* capture) {

    [(__bridge CameraCaptureController*)capture pause];

    }

  22. Hi Frederik,

    Fantastic tut. And also thanks to all pre-posts.

    Now I can call Unity Vuforia Camera in native IOS but I have some issues to be fixed:

    1. When I launch iOS App, I found UnityWindow is shown in portrait by default without calling showUnityWindow() and native iOS window is shown in landscape (which should be portrait. Then I press the button to call showUnityWindow(), the natvie IOS window is gone.

    2. I integrate AR Vuforia as well, press button Camera view is ok but cannot track image target. I also tried /Data/Raw/QCAR folder in Build Phases -> Copy Bundle Resources. Also I am confused whether I need run script in latest version or not? Seems we directly copy Data to project so do not need it any more?

    3. Finnally when I test on my iphone via xcode, it always crashes at the beginning at point of extern “C” bool AllocateRenderBufferStorageFromEAGLLayer(void* eaglContext, void* eaglLayer)

    {

    return [(__bridge EAGLContext*)eaglContext renderbufferStorage:GL_RENDERBUFFER fromDrawable:(__bridge CAEAGLLayer*)eaglLayer];

    }

    The reason is showing as EXC_BAD_ACCESS, any idea?

    BR
    Caesar

  23. Hi Thanks for the tutorial. This is very much helpful to everyone like me, who is new to Unity.My only question is i already have an iOS app which has 10-11 views. And i want to present this unity view some where in the middle of the application for example in 5th screen. For instance user will be logging in and in the home screen i want to show a unity object in some part of it. please let me know how can i acheive this.

    1. Also could someone let me know, how should i communicate with the Unity Player, for example if i want to execute some unity scripts on unity player,how can i achieve this from my iOS app.

  24. Hi, thankyou for the useful guide but when I build the project Unity5Native, xcode shows me the error:

    Undefined symbols for architecture arm64:

    “RegisterStaticallyLinkedModulesGranular()”, referenced from:

    RegisterStaticallyLinkedModules() in libiPhone-lib.a(RegisterStaticallyLinkedModules.o)

    “RegisterAllStrippedInternalCalls()”, referenced from:

    RegisterAllInternalCalls() in libiPhone-lib.a(MonoICallRegistration.o)

    “RegisterAllClasses()”, referenced from:

    InitializeEngineNoGraphics() in libiPhone-lib.a(SaveAndLoadHelper.o)

    ld: symbol(s) not found for architecture arm64

    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    I use Xcode 7.2.1 unity 5.3.2f1
    Can you help me to resolve it? thanks!

    1. Man, i have the same issue. Than i change my Machine. And this error was solved. I don’t know what is this.
      Probably this thing was related to my version of OS. Because my old machine have Yosemite e my new is the Captain.

    1. In the project Build Settings > Apple LLVM 7.1 – Warnings – All languages, change “Mismatched return type” option from Yes to just Yes

    1. thanks for your tutorial, i am using unity 5.3.4 and vuforia 5.5.9 (for sample i am using vuforia best practices, Books) but when i integrating it, success, but the camera is blank, there is this message ini log:
      Could not find a UIView with CAEAGLLayer or CAMetalLayer layer class that responds to selector renderFrameVuforia

      1. well, I have the same unity and vuforia versions and used my tutorial a lot and everything works. Have you disabled Metal in unity project?

    2. Thank you so much to the original author, and to keyv for simplifying the process with a step by step guide. keyv, your guide worked great for me! Since you did so well on this, I’m wondering if you have a similar guide for Android + Unity + Vuforia?

    3. i have an issue in camera capture.mm file. the issue is ” Use of undeclared identifier ‘static_assert’; did you mean ‘static_cast’?”

      in the line

      static_assert(countof(presetW) == countof(preset), “preset and preset width arrrays have different elem count”);

      i made the tutorial many times.

    4. Hello keyv , i follow your tutorial and all works fine!!!! thanks a lot!!! you are my hero!!!! lol , but i have a little problem, every time i show the unity window, the memory of the app rise in 10mb !!!!!! , any idea whats happenning?

  25. hi Frederik

    this is an awesome tutorial.

    I am trying to build a framework for my app so that other developers can integrate my unity project in their native project.

    Can you help me in figuring out how to make that process easier for them and the best way to build the framework in this manner.

    Thanks and all the help is appreciated

  26. This article is awesome ,but there are some errors in unity 5.3.5f1 with xcode 7.3.1. But it is easy to fix.Thx nerd give us such amazing and useful article.

        1. check if you have it in AppDelegate.h

          and try to write in 2 lines:
          AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
          [delegate showUnityWindow];

          1. The isuue is in the line “[delegate showUnityWindow]; ” and i add “#import “AppDelegate.h” “

  27. Hi! I’ve been following the tutorial but I’m having some issue when it comes to compile.
    The error I am facing is the following: “clang: error: unknow argument: ‘weak-ISystem’.
    What can I do? Please help me resolve this issue. Thanks!

  28. i have the this issue and i re add all the frameworks, clean the projects . any other idea ?

  29. Works good on Unity 5.4.0f3 and Xcode 7.3.1. How to launch it on a subview without being full screen? Very good tutorial :). Tanks in advance for the help.

  30. I’ve followed this guide on point, 2 times in a row and I get the exact same linker issues.

    1. Were you able to fix this? I am having the same issues only when I try to generate the project using simulator as the target SDK. If I generate the project for a Device everything works well.

      1. We gave up on this approach and are now coding in Unity for the most part with the occasional iOS plugin, then we build for Xcode and test.

        1. Just curious, were you generating the Unity project for the simulator target and building your xcode project against the simulator? Because that is how I am getting that error. If I set the player setting target SDK to device in Unity and then build the Xcode project using a device as target everything works.

    2. Hi,
      I had this exact same issue.
      The solution is in the Build Settings in other linker flags (OTHER_LDFLAGS) add: -Wl,-undefined,dynamic_lookup

  31. Hi

    This tutorial clear many things. Thanks for this amazing demo.
    After following all things. I’m getting following errors regarding “libiPhone-lib.a” framework.

    ld: library not found for -liPhone-lib
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    Can you please help me to get rid on this?

  32. This is incredibly helpful.

    One question I’m sure a lot of people have (and that took me a couple of hours to figure out) is – how does one get back to the native view from inside of Unity?

    I’m sure you could figure this out in thirty seconds, but for the Obj C noobs who came looking for an easy integration–

    Create a .mm file and put it in Unity Project > Assets > Plugins > iOS

    Paste all this stuff

    #import
    #import “AppDelegate.h”

    @interface MyUnityPlugin:NSObject
    + (BOOL)hideUnityWindow;
    @end

    @implementation MyUnityPlugin

    + (BOOL)hideUnityWindow {

    AppDelegate *appDel = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    [appDel hideUnityWindow];

    return true;
    }
    @end

    //C-wrapper that Unity communicates with
    extern “C”
    {
    bool uHideUnity(){
    return [MyUnityPlugin hideUnityWindow];
    }

    }

    ___________

    Then make a C Sharp script called HideUnity, paste this code in and hook the hide function up to a button in UI 🙂

    using UnityEngine;
    using System.Collections;
    using System.Runtime.InteropServices;

    public class HideUnity : MonoBehaviour {

    [DllImport (“__Internal”)]
    private static extern bool uHideUnity ();

    public void hide(){
    Debug.Log (“Trying plugin…”);
    if (uHideUnity () == true) {
    Debug.Log (“Successfully returned data from external plugin”);
    }
    }

    }

  33. Hello, i do exactly same what is in the video. But i get error in files where include path is defined, it gives error if path is defined with folder name . and when i remove folder name it solved error . Does it have any setting to include files with folder name ? Because if i have to do changes in so many files 🙁

  34. Hi, Thank you so much for this awesome tutorial. But I encountered a problem with orientation. My Unity project supports only landscape left and my native iOS app supports only portrait. But in my native project I’ve set the settings to support all 4 orientations and locked some of my views to only support portrait. But when I try to show the Unity window, it also opens in Portrait mode. Does anyone has a solution to this issue?

  35. Hello!!!!
    I followed the tutorial and all works fine!!!! thanks a lot!!!
    But i have a little problem, when i show the unity window and then hide it, i have a memory leak of 10mb!!! so when i present the unity window like ten times , the app crash!!

    1. Hi Eduardo, did you figure out the fix for this crash? I am having the same problem right now. thanks in advance!

      1. Hi Jayesh!!!! , no!!! the issue continues! :(, fortunately the app doesn’t reach production environment yet…. lol

        If i find something, i will post it here!!!

  36. Fantastic ! exactly What i Was trying to Achieve !

    Just one question,

    What about it I want the Unity Scene to start only when display the unityWindow ?

    IS there anyway to achieve this ? I dont know much about Objective C unfortunately !

    Aswel, once the Unity Scene start, how to create a button to go back to the original window ?

    Thanks a lot for your time 🙂

  37. hi, i know it’s a bit old but i wonder if there are any swift (3?) version of this tutorial ?
    i’m currently facing the use of swift 3 library through Unity 5.5 and i’m completly lost
    =)

  38. Hello, whether the Unity of the project package into a framework of the form, integrated into the existing project

  39. Amazing guide, I do everything and remove all linker error. But now when I start Unity on my App, I get black blank screen and nothing more. Any idea ?
    I don’t use Vofuria.
    Thanks

  40. Can’t get it to work on Xcode 8. crashes when I add:
    [self.unityController application:application didFinishLaunchingWithOptions:launchOptions];

    with EXC_BAD_ACCESS

  41. Hii, it working fine for me, what my query is?
    before i tapping on the background unity is running. I dont want like that when i tap on the button theonly unity should work.any suggestions please help me.

  42. Someone has understand how to Close Unity when the controller with unityview disappear and restart Unity When the controller restart?

Leave a Reply

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

Related Posts