c# - 铿锵错误 : Linker Command Failed for Unity in Native

标签 c# swift xcode unity3d

我的项目是 Native 集成中的 Unity,遇到了 clang 错误的问题:Build failed refer image。我已经通过堆栈溢出中的其他来源来清除 clang 错误。我试图删除我的 main.mm 文件,然后构建成功,但应用程序在调用统一屏幕时会崩溃。所以我必须同时保留 AppDelgate 和 main.mm 文件。无法解决这个....问题。如果有人可以请.. enter image description here

最佳答案

根据你的问题,希望它在快速原生集成中是统一的。

注意:此方案仅适用于案例:Unity in Native iOS

从您的屏幕截图可以看出,您在 Xcode 中使用了 2 个主要文件。有 2 个选项可以解决此问题。

选项 1) 您可以将这两个文件保存在 Build Phases --> Compile sources 中,但在您的 AppDelegate 中,命令 @UIApplicationMain

import UIKit
//@UIApplicationMain 
class AppDelegate: UIResponder, UIApplicationDelegate {
.......................................}

这将构建成功并在初始阶段出现统一 View 。

选项 2) 如果您想显示带按钮的统一 View ,请从 Build Phases --> Compile sources 中删除您的 main.mm 文件,这样应用就不会使用“共享窗口 appDelegate”在统一 View 中崩溃,并在您的 AppDelegate 中尝试此代码(取消命令@UIApplicationMain)

 func unityWindow() -> UIWindow? {
        return UnityGetMainWindow()
    }

    func showUnityWindow() {
        unityWindow()?.makeKeyAndVisible()
    }

    func hideUnityWindow() {
        window!.makeKeyAndVisible()
    }

然后,在你的 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()
                }
            }

关于c# - 铿锵错误 : Linker Command Failed for Unity in Native,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55136162/

相关文章:

c# - 如何对也在 Excel 中打开的文件执行 File.ReadAllLines?

c# - 在 View 代码中更改 razor View 的基类

xcode - 如何在 MKMapView Swift 中放大图钉

c# - 冗余 "using"是否会降低性能

c# - 组织 WinForm 控件代码

swift - 快速搜索带有圆角半径的栏

ios - 在 Swift 中通过 Storyboard Segue 传递自定义初始化参数

ios - 在显示和关闭 `UIAlertView` 或 `UIAlertController` 时确定应用程序状态

iOS Libcurl 代理 C++

ios - 编译 xcode 项目时 Alamofire 出现大量问题