how to use protobuf-net in the xamarin ios pcl - ios

I am trying to use protobuf-net with the new xamarin ios pcl, and it's nuget packet doesn't appear to support the framework. Is there a way to import protobuf-net into the pcl?
Update:
I just found recompiling the PCL with the new Xamarin PCL definitions allowed the resulting library to be references. Nice work! Let me know when a new version is posted to Nuget.

The NuGet package includes PCL drops, but it is unclear to me what change you would have me make to the NuGet package here, as there is no specific "Xamarin" target that I know of; the example targets are described here; protobuf-net currently includes a broad target of portable-sl4+net40+wp7+windows8. If you know of a target (or indeed a PCL build combination) that works for Xamarin for iOS, please let me know.
I should also note that the NuGet drop is the "Full" implementation, where meta-programming is performed at runtime. Because of the limitations in iOS, you may find you get better performance by using the "CoreOnly" implementation combined with the "precompile" tool, available from the google-code drop. This is described here.

I was able to use NuGet version of protobuf-net by manually editing the .csproj file for my portable library and setting the target framework profile to match protobuf-net:
<TargetFrameworkProfile>Profile136</TargetFrameworkProfile>
The resulting portable library worked well with Xamarin.Android. According to this list, it should work with Xamarin.iOS as well.

Related

Autofac Build() throws exception on latest Xamarin iOS when Linker configured to Link All

After upgrading to Visual Studio 16.3.0 (Visual Studio for Mac 8.3.1805) Autofac throwns an exeception when doing builder.Build() in a project that previously worked:
The type 'Autofac.Features.Indexed.KeyedServiceIndex'2' does not
implement the interface 'Autofac.Features.Indexed.IIndex'2'
With this release of Visual Studio (and maybe earlier versions too), iOS is compiled using Mono 6.4.0.198 and I suspected that this might be what is introducing the braking change. Alternatively the linker behaves differently with the latest tool-chain. All I can say is that this used to work and now it doesn't.
Following these guidelines is not sufficient: Cross-Platform and Native Applications
To work around the issue, first make sure that Autofac is installed both in the iOS project, Android and the .NET Standard shared project, then choose one of these two options:
Set the linker to Don't link or Link Framework SDK's Only
Or, you can; add --linkskip=Autofac (case sensitive!) to the Additional mtouch arguments in iOS Build found in the iOS project properties.
Or, you can; create a Custom Linker Configuration file, which I btw think is the best option if you need linking. It's a little bit more work, but when using a Linker Description file the compiler will give you usable feedback when you build, if you've made a mistake like misspelling an assembly etc. Also, the Linker Description file has an identical format across Android and iOS.
Note: Option 2 and 3 will only increase your app size a small amount, as it will ensure that all of the Autofac assembly is included in your app package, while all other assemblies not specified as part of 2 or 3 will continue to be linked.
I assume that the needs for one of these work-arounds is an indication that Autofac is currently not linker safe.

Using a modified PDFTron Tools Framework

I'm working on a iOS Framework (using CocoaPods) that, as of today, uses PDFNet.framework as its only dependency.
Everything works as expected when I use the resulting framework in another "top level" project.
Now I'm trying to make this same Framework use the Tools.framework, as I intend to use the annotations from the Tools library.
Is there a common approach in doing so?
I've tried building the Tools source code but it fails as the dependency isn't found.
Everything you need should be in the following guide.
https://blog.pdftron.com/2016/11/14/getting-started-with-pdfnet-for-ios/
If that guide does not help, then please answer my comment above.

How to use sharpziplib in Monotouch?

Hi I need to unzip a file in Monotouch for an iOS (and Andriod later) App and sharpziplib looks like a good choice (is it?). But how do I go about adding it in MonoDevelop (I have the latest version)?
I have downloaded ICSharpCode.SharpZipLib.dll, but how/where is it added to my project (solution)? Can anyone give me step-by-step instructions?
Also which .net version of the DLL should I be using? There are three: net-11, net-20, netcf-20 (i think it's the last one but would be good to have that confirmed).
You must create a MonoTouch class library project for ICSharpCode.SharpZipLib and add the corresponding source files to that project.
Then you can either reference the resulting assembly or the project itself in your solution.

Unable to use System.XML.Linq

I am working on a project using Mono for Android. After reading a cross-platform document with Xamarin. I had my data layer in a separate project and was going to move it to my Mono for Android project and then link those files to my Mono Touch project, and one day perhaps a Windows Phone 8 project.
When I moved the code, I am now unable to compile because of the System.Xml.Linq reference. The reference shows in the Mono for Android project, but I am unable to use it. I thought aiming for Froyo may be the problem, but upgrading the project to Gingerbread or Ice Cream Sandwich didn't help.
Does anybody know what I am doing wrong? I am a seasoned .NET developer and am well aware of how references work in project, but this one has me stumped.
The project the original code was working on was targeting the Mono/.NET 4 framework
Is your reference to System.Xml.Linq pointing to the .Net version or the Mono version? The one for Mono will have Version 2.0.5.0.
Also, is the reference to System.Xml.Linq in a Android Class Library/Application or in a regular .Net Class library. If it is a .Net Class library, I would try referencing the library in your Android application as a compiled (dll) reference and not a project reference. It is not a perfect solution, but I have found that this works when I needed to reference libraries that I use across multiple solutions. The reference will generally work out fine, but if there is anything that is not supported in the Mono version, then it can cause issues.
Assuming you have your code in a class library, your best bet may be to create a Mono specific version of your library project. You can import and use the same class files, but just add some Conditional compilation symbols to have it compile properly for Mono. If you are not familiar with this, take a look at how Json.Net or ServiceStack manages code for multiple platforms.

Is the AWS.net library compatible with MonoTouch?

I'm working on a new app using MonoTouch and I'd like to store data in AWS.
I saw there is an AWS.net library available from Amazon, but I don't know if I can use it with my MonoTouch app. Can I?
standard .NET binaries won't work, per FAQ: http://monotouch.net/FAQ (Can I use standard desktop Mono assemblies or .NET assemblies with MonoTouch?).
Edited: All you need to do is rebuild the source code with Mono's C# compiler
I think the better option is to use the AWS SDK for iOS and write bindings to the Obj-c library. There are examples out there of how to write bindings if you just do a search for it. It probably isn't the quick solution you were hoping for but you probably don't want to use the SDK for .NET anyway as it probably wasn't intended to be used on the iPhone.
If you do end up writing bindings for it, please post it on github for everyone else to use. Solve once for many, right? :)
For standard upload of files from monotouch to S3 I used this Library ,
recompiled in MonoDevelop using MonoTouch Library Template and done ( use System.Web.Services instead of System.Web ).
Recompile AWS for monotouch has to be really difficult because of the heavy use of System.Web and IOrderedDictionary ( ThirdParty Libraries ).
I just built the AWS SDK for Monotouch/Mono for Android. I had to modify some files and add some classes from the current Mono release.
GitHub repo is located here:
https://github.com/fr500/aws_sdk_monotouch_monodroid
It's my first attempt at this, and it's working but I don't know if my approach is correct. Any help will be appreciated

Resources