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.
- Renaming umbrella header
- what would be a proper storyboard example of combining nav bars and tab bars in one app?
- How to filter data that has been fetched from Core Data?
- how to draw automatic line between two tap points in a view in iphone
- How to enumerate a slice using the original indices?
- Parse JSON Swift 3
- UIView Animation Inconsistent Result
- perform segue with identifier wont work in swift 2
- iPhone / iOS : Presenting HTML 5 Keyboard for Postal Codes
- Setting contentOffset programmatically triggers scrollViewDidScroll
- How to pin the Public key of a certificate on iOS
- Convert UIImage to CMSampleBufferRef
- Swift Initialization Rule Confusion
- how to present a view controller on iOS7 without the status bar overlapping
- How to code an UITableView with a Switch like the Alarm App iOS7?