试图在Unity中使用Xamarin.iOS制作的库

问题描述 投票:1回答:1

我使用Xamarin.iOS和Visual Studio创建了库。 FoundationJavaScriptCore名称空间都在库中使用。

我想在Unity中使用这个库。当我将这个库放在Unity的Assets> Plugins / iOS文件夹中并编写代码来调用我创建的库时,会发生错误。它说没有Xamarin.iOS.dll,所以我添加了它,最后我可以编译它们。

但是当我尝试构建它时,还有另一个错误。错误信息如下;

IL2CPP error for method 'Foundation.NSObject ARKit.ARAnchor::Copy(Foundation.NSZone)' in assembly '/Users/MyName/Documents/JavaScriptRuntimeTest/Temp/StagingArea/Data/Managed/Xamarin.iOS.dll'
Additional information: Stack empty.


IL2CPP error for method 'Foundation.NSObject ARKit.ARAnchor::Copy(Foundation.NSZone)' in assembly '/Users/MyName/Documents/JavaScriptRuntimeTest/Temp/StagingArea/Data/Managed/Xamarin.iOS.dll'
Additional information: Stack empty.
il2cpp.exe didn't catch exception: System.InvalidOperationException: Stack empty.
   at System.Collections.Generic.Stack`1.Pop()
   at Unity.IL2CPP.StackAnalysis.StackStateBuilder.Build(IEnumerable`1 instructions)
   at Unity.IL2CPP.StackAnalysis.StackAnalysis.Analyze()
   at Unity.IL2CPP.MethodBodyWriter..ctor(IGeneratedMethodCodeWriter writer, MethodReference methodReference, TypeResolver typeResolver, IRuntimeMetadataAccess metadataAccess, VTableBuilder vTableBuilder, MethodBodyWriterDebugOptions options, ISourceAnnotationWriter sourceAnnotationWriter)
   at Unity.IL2CPP.MethodWriter.WriteMethodBody(MethodReference method, IGeneratedMethodCodeWriter methodBodyWriter, IRuntimeMetadataAccess metadataAccess, ISourceAnnotationWriter sourceAnnotationWriter, IIcallMappingService icallMapping, VTableBuilder vtableBuilder)
   at Unity.IL2CPP.CodeWriterExtensions.WriteMethodWithMetadataInitialization(IGeneratedMethodCodeWriter writer, String methodSignature, String methodFullName, Action`2 writeMethodBody, String uniqueIdentifier, MethodReference methodRef)
   at Unity.IL2CPP.MethodWriter.WriteMethodDefinition(IGeneratedMethodCodeWriter writer, MethodReference method, IMethodCollector methodCollector, IMethodVerifier methodVerifier, ISourceAnnotationWriter sourceAnnotationWriter, IIcallMappingService icallMapping, VTableBuilder vtableBuilder)
   at Unity.IL2CPP.SourceWriter.<>c__DisplayClass12_0.<WriteMethodSourceFiles>b__0(IGeneratedMethodCodeWriter writer, TypeReference type)
   at Unity.IL2CPP.SourceWriter.WriteEqualSizedChunks[T](NPath outputDir, IEnumerable`1 items, String fileName, Int64 chunkSize, Action`2 writeItemAction, SourceWritingContext sourceWritingContext)
   at Unity.IL2CPP.SourceWriter.WriteMethodSourceFiles(NPath outputDirectory, SourceWritingContext sourceWritingContext, String fileName, IEnumerable`1 typeList, IMethodCollector methodCollector, Boolean writeMarshalingDefinitions)
   at Unity.IL2CPP.SourceWriter.Write(NPath outputDir, SourceWritingContext sourceWritingContext, ReadOnlyCollection`1 assemblyDefinitions, IMethodCollector methodCollector, IInteropDataCollector interopDataCollector)
   at Unity.IL2CPP.AssemblyConverter.Apply()
   at Unity.IL2CPP.AssemblyConverter.ConvertAssemblies(IEnumerable`1 assemblyDirectories, IEnumerable`1 explicitAssemblies, NPath outputDir, NPath dataFolder, NPath symbolsFolder, NPath executableAssembiesFolder, NPath monoLibFolder, NPath monoEtcFolder, NPath[] searchDirectories, String entryAssemblyName, NPath[] extraTypesFiles)
   at il2cpp.Program.DoRun(String[] args)
   at il2cpp.Program.Run(String[] args)
   at il2cpp.Program.Main(String[] args)
stderr:

Unhandled Exception: System.InvalidOperationException: Stack empty.
   at System.Collections.Generic.Stack`1.Pop()
   at Unity.IL2CPP.StackAnalysis.StackStateBuilder.Build(IEnumerable`1 instructions)
   at Unity.IL2CPP.StackAnalysis.StackAnalysis.Analyze()
   at Unity.IL2CPP.MethodBodyWriter..ctor(IGeneratedMethodCodeWriter writer, MethodReference methodReference, TypeResolver typeResolver, IRuntimeMetadataAccess metadataAccess, VTableBuilder vTableBuilder, MethodBodyWriterDebugOptions options, ISourceAnnotationWriter sourceAnnotationWriter)
   at Unity.IL2CPP.MethodWriter.WriteMethodBody(MethodReference method, IGeneratedMethodCodeWriter methodBodyWriter, IRuntimeMetadataAccess metadataAccess, ISourceAnnotationWriter sourceAnnotationWriter, IIcallMappingService icallMapping, VTableBuilder vtableBuilder)
   at Unity.IL2CPP.CodeWriterExtensions.WriteMethodWithMetadataInitialization(IGeneratedMethodCodeWriter writer, String methodSignature, String methodFullName, Action`2 writeMethodBody, String uniqueIdentifier, MethodReference methodRef)
   at Unity.IL2CPP.MethodWriter.WriteMethodDefinition(IGeneratedMethodCodeWriter writer, MethodReference method, IMethodCollector methodCollector, IMethodVerifier methodVerifier, ISourceAnnotationWriter sourceAnnotationWriter, IIcallMappingService icallMapping, VTableBuilder vtableBuilder)
   at Unity.IL2CPP.SourceWriter.<>c__DisplayClass12_0.<WriteMethodSourceFiles>b__0(IGeneratedMethodCodeWriter writer, TypeReference type)
   at Unity.IL2CPP.SourceWriter.WriteEqualSizedChunks[T](NPath outputDir, IEnumerable`1 items, String fileName, Int64 chunkSize, Action`2 writeItemAction, SourceWritingContext sourceWritingContext)
   at Unity.IL2CPP.SourceWriter.WriteMethodSourceFiles(NPath outputDirectory, SourceWritingContext sourceWritingContext, String fileName, IEnumerable`1 typeList, IMethodCollector methodCollector, Boolean writeMarshalingDefinitions)
   at Unity.IL2CPP.SourceWriter.Write(NPath outputDir, SourceWritingContext sourceWritingContext, ReadOnlyCollection`1 assemblyDefinitions, IMethodCollector methodCollector, IInteropDataCollector interopDataCollector)
   at Unity.IL2CPP.AssemblyConverter.Apply()
   at Unity.IL2CPP.AssemblyConverter.ConvertAssemblies(IEnumerable`1 assemblyDirectories, IEnumerable`1 explicitAssemblies, NPath outputDir, NPath dataFolder, NPath symbolsFolder, NPath executableAssembiesFolder, NPath monoLibFolder, NPath monoEtcFolder, NPath[] searchDirectories, String entryAssemblyName, NPath[] extraTypesFiles)
   at il2cpp.Program.DoRun(String[] args)
   at il2cpp.Program.Run(String[] args)
   at il2cpp.Program.Main(String[] args)
   at Program.Main(String[] args)

UnityEngine.Debug:LogError(Object)
UnityEditorInternal.Runner:RunProgram(Program, String, String, String, CompilerOutputParserBase) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:128)
UnityEditorInternal.Runner:RunNetCoreProgram(String, String, String, CompilerOutputParserBase, Action`1) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildUtils.cs:79)
UnityEditorInternal.IL2CPPBuilder:RunIl2CppWithArguments(List`1, Action`1, String) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:366)
UnityEditorInternal.IL2CPPBuilder:ConvertPlayerDlltoCpp(String, String, String, Boolean) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs:349)
UnityEditorInternal.IL2CPPBuilder:Run() (at

是否有可能在Unity中使用Xamarin.iOS制作的库?谢谢,

环境

  • Unity 2018.3.12f1
  • PlayerSettings>其他设置 ScriptingRuntimeVersion = .NET 4.x. API级别= .NET标准2.0
c# ios unity3d xamarin
1个回答
1
投票

据我所知,目前还没有关于如何在Unity中使用Xamarin或在Xamarin中使用Unity的文档。两个运行时不一样。

Xamarin有自己的引擎:urhosharp