在没有完整 AOT 的 Xamarin.iOS 中使用 Protobuf-Net [英] Using Protobuf-Net In Xamarin.iOS without full AOT
问题描述
除了此方法之外,是否还有其他方法可以使用 protobuf-net 在 Xamarin.iOS (Monotouch) 中实现对象的序列化和反序列化:
Is there any alternative to achieving serialising and deserialising of objects in Xamarin.iOS (Monotouch) using protobuf-net other than this method:
阅读一些人声称他们已经做到了(没有提供证据),但我的理解是 [iOS JIT==NO] 所以不太合理.
Reading around some people claim they have managed it (without giving evidence), but my understanding is that [iOS JIT==NO] so does not quite make sense.
如果唯一可能的解决方案是对所有相关类进行完全 AOT,那么合适的构建前/构建后事件命令行是什么来自动为任何相关程序集执行此 AOT?
If the only possible solution is to fully AOT all relevant classes what might a suitable pre/post-build event command line be to perform this AOT for any relevant assemblies automatically?
推荐答案
我听说很多人通过这条途径取得了成功,但我也无法提供书面证据.
I've heard a good number of people have success via that route, but I too can't give documented evidence.
那个方法有点过时了——我已经简化了几个步骤;有一个独立的预编译工具应该可以工作:
That method is a bit out of date - I've simplified a few steps; there is a standalone pre-compile tool that should work:
- 为要序列化的 DTO 创建一个项目/程序集,以引用 protobuf-net 的适当版本;大概是 CoreOnly/ios,最好将该 dll 设置为复制到输出目录中(它只是让生活更轻松)
运行
- create a project/assembly for the DTOs that you want to serialize that references the appropriate version of protobuf-net; presumably CoreOnly/ios, ideally with that dll set to copy into the output directory (it just makes life easier)
run
precompile "SomePath/YourDto.dll" -t:MySerializer -o:MySerializer.dll
(可能在此之前使用 mono
来让 Mono 托管 exe)
(maybe with a mono
before that to get mono to host the exe)
这应该解析框架并编译您可以引用的 MySerializer.dll
,这涉及零 JIT(MySerializer.dll
将引用您的 dto dll 和您的 dto dll 引用的 protobuf-net)
this should resolve the framework and compile a MySerializer.dll
that you can reference, which involves zero JIT (MySerializer.dll
will reference your dto dll and the version of protobuf-net that your dto dll referenced)
我很乐意提供指导,但目前我没有 mac,所以我现在无法检查.如果您遇到任何问题,请告诉我.如果它不能解析框架,你可以添加-f:{path to the framework assembly}
给它一个线索.
I'll be happy to offer guidance, but currently I am mac-less, so I can't check right now. If you get any problems let me know. If it can't resolve the framework, you can add -f:{path to the framework assemblies}
to give it a clue.
这篇关于在没有完整 AOT 的 Xamarin.iOS 中使用 Protobuf-Net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!