How to integrate Unity into an iOS Swift 3 project

I'm just wondering what could be the best strategy for implementing a Unity project in an existing iOS Swift 3 project. So far, I have only discovered code sample in Objective-C. Is there any popular structure or wrapper?

+5
source share
2 answers

in my opinion this guide is extremely useful:

https://github.com/blitzagency/ios-unity5

Please note that there are some pitfalls:

At first, I had several linker errors, but I didn’t take into account that the configuration of the Unity project was configured only for “real devices”. When I tried to build a project on a simulator, I had more than 100 compiler errors.

Then I tried to create it on my test device, but there were still some errors until I noticed that I needed to add some of these necessary frameworks, which are listed here:

https://github.com/blitzagency/ios-unity5/issues/36#issuecomment-303716827

AssetsLibrary, AudioToolbox, AVFoundation, CFNetwork, CoreGraphics, CoreLocation, CoreMedia, CoreMotion, CoreVideo, Foundation, iAd, libiconv.2.tdb, MediaPlayer, MediaToolBox (this was missing) OpenAL, OpenGLES, QuartzCore, Security, SystemConfiguration, UIKit, lib.a, libVuforia.a *, libVuforiaUnityPlayer.a *

* only if you use Vuforia in your scene

The last and most important step is to follow the tips listed in the following pull request, then it will work perfectly with Swift 3:

https://github.com/blitzagency/ios-unity5/pull/42

combined current evolutions from other forks (for example, support for fast 3), updated to work with Unity 5.5.2, Xcode 8.3.2 and Swift 3.1, removed some templates, such as main.swift, added the ability to suspend unity to fully use the reduced cylinder cycles and therefore battery consumption when the unit is down (active)

If you are using Cocoa Pods, it is best not to use the configuration file provided by this repo. In fact, I actually manipulated all the build settings manually, so there will be no conflicts with the pod configuration file.

I hope I help you a little.

Happy coding

+7
source

The tutorial mentioned in the accepted answer is a good step-by-step guide on integrating a Unity project into Swift.

However, there are a few changes to Swift 4 and Unity 2017.1. Here is a demo project in case someone needs it.

+6
source

Source: https://habr.com/ru/post/1269780/


All Articles