Iam beginner in iOS development. I would like to get help for Unity in Native iOS App sample. I went through few online course which is outdated also showing some error at the end. I would like to request if anyone could post a video tutorial or sample project to make Unity in Native iOS app .. here is sample link :- https://medium.com/@IronEqual/how-to-embed-a-unity-game-into-an-ios-native-swift-app-772a0b65c82 like so..
Asked
Active
Viewed 1,427 times
0
-
What is your error? – Rurouni Dec 28 '18 at 04:44
-
@ Rurouni, I tried more than 10 sample projects, it always shows some error like PrecompileSwiftBridgeHeader failed with a nonzero exit code error or Clang. If I clear those again comes up with another.. Its really hard. that y asked for any latest video or sample. – Aleesha Dec 28 '18 at 04:52
-
@Aleesha.... show the screen shot of the error – Wings Dec 28 '18 at 05:40
-
@wings, its really hard to find proper solution, only by building the sample u could find.. – Aleesha Dec 28 '18 at 05:59
-
Try updating all IDEs to latest versions – Martin Zikmund Dec 28 '18 at 05:59
-
https://stackoverflow.com/questions/24146677/swift-bridging-header-import-issue try all these solutions – Wings Dec 28 '18 at 06:50
1 Answers
2
As per your request I have uploaded a video tutorial for building Unity in Native iOS App with latest version of Xcode-10.1 and unity -2018.2.18f1.
Youtube link- https://www.youtube.com/watch?v=DLkeGz5vCzk
The source code for App Delegate is,
AppDelegate.h
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UIWindow *unityWindow;
@property (strong, nonatomic) UnityAppController *unityController;
- (void) showUnityWindow;
- (void) hideUnityWindow;
@end
AppDelegate.m
#import "AppDelegate.h"
#import "ViewController.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (UIWindow *)unityWindow {
return UnityGetMainWindow();
}
- (void) showUnityWindow {
[self.unityWindow makeKeyAndVisible];
}
- (void) hideUnityWindow{
[self.window makeKeyAndVisible];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame: [UIScreen mainScreen]. bounds];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
ViewController *mainVC = [storyboard instantiateViewControllerWithIdentifier:@"MainIdentity"];
UINavigationController *naVC = [[UINavigationController alloc] initWithRootViewController:mainVC];
self.window.rootViewController = naVC;
self.unityController = [[UnityAppController alloc] init];
[self.unityController application:application didFinishLaunchingWithOptions: launchOptions];
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];
}
@end
And View Controller.m
#import "ViewController.h"
#import "AppDelegate.h"
@interface ViewController ()
@property (nonatomic) BOOL isShowUnityWindow;
- (IBAction)showUnityTouched:(id)sender;
@property (weak, nonatomic) IBOutlet UIView *unityViewStart;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.isShowUnityWindow = NO;
}
- (IBAction)showUnityTouched:(id)sender {
self.isShowUnityWindow = !self.isShowUnityWindow;
AppDelegate *appDelegate = (AppDelegate *) [UIApplication sharedApplication].delegate;
if (self.isShowUnityWindow) {
[appDelegate.unityWindow setFrame:CGRectMake(40, 200, 500, 500)];
[appDelegate.unityWindow ]
[appDelegate showUnityWindow];
}
else {
[appDelegate hideUnityWindow];
}
}
@end

AzeTech
- 623
- 11
- 21