Using Protobuf-Net In Xamarin.iOS without full AOT

情到浓时终转凉″ 提交于 2019-12-19 10:55:13

问题


Is there any alternative to achieving serialising and deserialising of objects in Xamarin.iOS (Monotouch) using protobuf-net other than this method:

http://www.frictionpointstudios.com/blog/2011/3/31/using-protobuf-net-serialization-in-unity-iphone.html

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.

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?


回答1:


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:

  • 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
    

    (maybe with a mono before that to get mono to host the exe)

    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)

  • now reference your dto dll, the serializer dll, and the protobuf-net dll, and it should all work just by using new MySerializer().Serialize(...)
  • when you compile your solution, the projects should all AOT nicely

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.



来源:https://stackoverflow.com/questions/15970459/using-protobuf-net-in-xamarin-ios-without-full-aot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!