如何将Unity iOS项目集成到本地iOS Swift项目中?

3
我已经尝试了大部分在线资源,包括这个链接,以将我的Unity项目集成到swift 4本地项目中,但不幸的是直到现在都没有帮助。当我执行Linked修复时,我遇到了下面的c++文件错误:
No member named 'GetHostByAddr40' in 'il2cpp::icalls::System::System::Net::Dns'; did you mean 'GetHostByAddr'?

顺便说一下,我正在做一个增强现实项目,其中包含一些本地iOS设计。因此,我使用了swift 4和Xcode 9.2来完成这些部分。本地部分包含项目的起始和结束部分。在这之间,有一个增强现实部分,它是通过使用unity 2018.2.0f2个人版和vofuria 7.2.23完成的。

最终,现在我有一个iOS本地项目和unity项目。我想把unity部分集成到iOS本地中!


试试这个...https://github.com/jiulongw/swift-unity。我在搜索时发现了这个和你的帖子。 - sirvon
1个回答

1
经过长时间搜索,我解决了这个错误。在使用this提到的解决方案进行修复后,我最终遇到了Bulk_Mono.Security_1.cpp文件找不到的问题。所以我开始寻找它。然后我发现了问题所在。问题出在.Net的4.0脚本运行时版本上。我使用4.0制作项目是因为使用LitJson需要至少4.0版本。4.0没有为iOS生成Bulk_Mono.Security_1.cpp文件。然后我从项目中删除了LitJson并将项目运行时版本降级到3.x等效版本,随后对以下两个文件进行了更改,项目就开始正常工作了。
请注意,只需像通常一样将生成的objective-c项目集成为框架,然后进行以下更改和运行即可。
  1. made the change following on DisplayManager.mm generated file which is located in classes/unity. The auto-generated not contains the last line of return deviceUnknown;. So we have to write manually.

    elif PLATFORM_TVOS
         if (!strncmp(model, "AppleTV5,", 9))
       return deviceAppleTV1Gen;
     else if (!strncmp(model, "AppleTV6,", 9))
       return deviceAppleTV2Gen;
     else
        return deviceUnknown;
    endif
      return deviceUnknown
    
  2. Do the following change on SplashScreen.mm which is located in generated project's classes/ui. Change the bool hasStoryboard = [[NSBundle mainBundle] pathForResource: @"LaunchScreen" ofType: @"storyboardc"] != nullptr; to bool hasStoryboard = [[NSBundle mainBundle] pathForResource: @"LaunchScreen_1" ofType: @"storyboardc"] != nullptr;. The complete method below.

        void ShowSplashScreen(UIWindow* window)
        {
           bool hasStoryboard = [[NSBundle mainBundle] pathForResource: @"LaunchScreen_1" ofType: @"storyboardc"] != nullptr;
    
           if (hasStoryboard)
           {
              UIStoryboard *storyboard = [UIStoryboard storyboardWithName: 
              @"LaunchScreen" bundle: [NSBundle mainBundle]];
              _controller = [storyboard 
              instantiateViewControllerWithIdentifier: @"unitySplashStoryboard"];
            }
            else
               _controller = [[SplashScreenController alloc] init];
    
            [_controller create: window];
            [window makeKeyAndVisible];
        }
    

这就是我整合的全部内容。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接