How to integrate Unity into a Swift 3 iOS project

后端 未结 2 971
余生分开走
余生分开走 2020-12-29 16:18

I was just wondering what might be the best strategy for implementing a Unity project into a already existing Swift 3 iOS project. So far I only discovered sample code in Ob

相关标签:
2条回答
  • 2020-12-29 17:07

    The tutorial mentioned in the accepted answer is a good step by step guide to integrate Unity to Swift project.

    However, there are couple of changes needed for Swift 4 and Unity 2017.1. Here is a demo project in case someone needs it.

    0 讨论(0)
  • 2020-12-29 17:09

    in my opinion this guide is extremely helpful:

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

    Please note that there are some pitfalls:

    First I had several linker errors, but I did not take into account that the Unity project configuration was set up for "real devices" only. When I tried to build the project on the simulator, I had more than 100 compiler errors.

    Then I tried to build it on my test device, but there were still some errors, until I noticed I had to add some of those necessary frameworks, which are listed right there:

    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 the missing one) OpenAL, OpenGLES, QuartzCore, Security, SystemConfiguration, UIKit, libiPhone-lib.a, libVuforia.a*, libVuforiaUnityPlayer.a*

    *only if you use Vuforia in your scene

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

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

    merged current evolutions from other forks (like swift 3 support), updated to work with Unity 5.5.2, Xcode 8.3.2 and Swift 3.1, removed some boilerplate like main.swift added possibility to pause unity to take full advantage of reduced cpu cylces and therefore battery consumption, when unity is not running (active)

    If you use Cocoa Pods, it's better not to use the config file provided by this repo. I actually ended up manipulating all build settings manually, so there will be no conflicts with the pod config file.

    I hope I could help you a little bit.

    Happy coding

    0 讨论(0)
提交回复
热议问题