How to integrate Unity into a Swift 3 iOS project
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 Objective-C. Is there any popular framework or wrapper out there?
2 Solutions Collect From Internet About “How to integrate Unity into a Swift 3 iOS project”
in my opinion this guide is extremely helpful:
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:
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:
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.
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.
- Store a closure as a variable in Swift
- iOS SDK: MapKit MKPolyLine not showing
- UIButton title not displaying
- How to measure distance between two iphone devices using bluetooth?
- When to release an instance variable
- Detect if browser supports autoplay of embedded media – YouTube playVideo() and iOS
- -canOpenURL: failed for URL: “fbauth2:/” (OSStatus error -10814.)”
- Objective-C stack trace
- Custom Calendar View in IOS
- How to handle multiple network call in Alamofire
- How do I redirect all errors, including uncaught exceptions, NSLog calls, and other logs, to a log file on Mac OS X?
- Subclassing UIWindow
- XCode using GUID instead of iOS version number in Simulator Selection
- Init an object, then store it into an NSArray. Is this going to be a leak?
- drawing cocos2d v3 no longer has ccDraw* functions, how do I draw without making nodes?