我使用Xamarin.iOS和Visual Studio创建了库。库中使用Foundation
和JavaScriptCore
命名空间。
我想在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制作的库? 谢谢,
环境
答案 0 :(得分:1)
据我所知,到目前为止,还没有关于如何在Unity中使用Xamarin或在Xamarin中使用Unity的文档。这两个运行时并不相同。
Xamarin具有自己的引擎:urhosharp