My project is Unity in Native integration, had problem with clang error: Build failed refer image. I had gone through other sources in stack overflow to clear with clang error. I tried to remove my main.mm file, then build get succeeded but app will crash when calling unity screen. So I have to keep both files AppDelgate and main.mm file. Couldn't fix this....issue. if anyone could please..
Asked
Active
Viewed 492 times
1
-
See if there is one or more missing files. – El Tomato Mar 13 '19 at 07:07
-
try this https://stackoverflow.com/a/43801476/10150796 – Nikunj Kumbhani Mar 13 '19 at 07:09
-
1Have you tried **disabling the bit code** in build settings? what are all the **plugins** you are using in your project? – Karthi Mar 20 '19 at 08:40
-
@Karthi I have disable bitcode in my build settings,, and its fine with other build settings. If I remove main.mm file build get succeeds but unity view doesn't appear. I found the solution from below answer... – Mar 20 '19 at 09:08
1 Answers
0
Based on your question, hope that it's unity in swift native integration.
NOTE: This solution is only for case: Unity in Native iOS
From your screen shot it show that you are using 2 main files in Xcode. There are 2 options to fix this out.
Option 1) you may keep both files in Build Phases --> Compile sources , but in your AppDelegate, command @UIApplicationMain
import UIKit
//@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
.......................................}
This will build succeeded and unity view appears at initial stage.
Option 2) If you want to show unity view with button, Remove your main.mm file from Build Phases --> Compile sources, so app won't crash in unity view by using 'shared window appDelegate' and try this code in your AppDelegate (uncommand @UIApplicationMain)
func unityWindow() -> UIWindow? {
return UnityGetMainWindow()
}
func showUnityWindow() {
unityWindow()?.makeKeyAndVisible()
}
func hideUnityWindow() {
window!.makeKeyAndVisible()
}
then, in your View Controller
private var isShowUnityWindow = false
override func viewDidLoad()
{
super.viewDidLoad()
isShowUnityWindow = false
}
@IBAction func startUnityandHide(_ sender: UIButton)
{
isShowUnityWindow = !isShowUnityWindow
var appDelegate = UIApplication.shared.delegate as? AppDelegate
if isShowUnityWindow {
appDelegate?.unityWindow()!.frame = CGRect(x: 40, y: 200, width: 300, height: 300)
appDelegate?.showUnityWindow()
} else {
appDelegate?.hideUnityWindow()
}
}

AzeTech
- 623
- 11
- 21
-
1Finally u made it, solved my issue after 10 days!!!>>>..........Cheers buddy ........Your solution works in both options.... – Mar 20 '19 at 09:10