Forum Cross Platform with Xamarin

Creating a cross platform library

nodoidnodoid GBMember, Beta ✭✭✭

For a particular project, I'm creating a cross platform library. Most of it is easy enough, but I'm also considering adding in RestSharp and JSON.NET. Both of these are available in the component store - but I'm guessing for a library I'll need to include a version that I've just built using mono itself. Will this work or am I likely to hit a problem as they're not the monodroid/monotouch versions? (I don't know the specifics of the internals, but am guessing that they're not going to be the same)

Posts

  • GuillermoGutierrezGuillermoGutierrez ESMember ✭✭✭

    RestSharp is not portable, so you'd need to add a wrapper interface and inject it in each interface project or use platform-specific core library and file linking.

    There are also other portable rest client alternatives, like PortableRest or a portable version of RestSharp.

    Personally I'm using a very simple portable REST Json client built on top of Microsoft's portable HttpClient library. This currently only works using versions from alpha channel, but I think it's worth it.

  • nodoidnodoid GBMember, Beta ✭✭✭

    Thanks for that. I'm trying to build the portable version of RestSharp but there are a few problems (possibly down to the current version of mono - I'm not sure). I'm unable to access the standard .NET libraries when I edit the references. I've manually imported them, but when I build I'm getting stupid errors…

        : error CS0518: The predefined type `System.Object' is not defined or imported
            : error CS0518: The predefined type `System.ValueType' is not defined or imported
            : error CS0518: The predefined type `System.Attribute' is not defined or imported
            : error CS0518: The predefined type `System.Int32' is not defined or imported
            : error CS0518: The predefined type `System.UInt32' is not defined or imported
            : error CS0518: The predefined type `System.Int64' is not defined or imported
            : error CS0518: The predefined type `System.UInt64' is not defined or imported
            : error CS0518: The predefined type `System.Single' is not defined or imported
            : error CS0518: The predefined type `System.Double' is not defined or imported
            : error CS0518: The predefined type `System.Char' is not defined or imported
            : error CS0518: The predefined type `System.Int16' is not defined or imported
            : error CS0518: The predefined type `System.Decimal' is not defined or imported
            : error CS0518: The predefined type `System.Boolean' is not defined or imported
            : error CS0518: The predefined type `System.SByte' is not defined or imported
            : error CS0518: The predefined type `System.Byte' is not defined or imported
            : error CS0518: The predefined type `System.UInt16' is not defined or imported
            : error CS0518: The predefined type `System.String' is not defined or imported
            : error CS0518: The predefined type `System.Enum' is not defined or imported
            : error CS0518: The predefined type `System.Delegate' is not defined or imported
            : error CS0518: The predefined type `System.MulticastDelegate' is not defined or imported
            : error CS0518: The predefined type `System.Void' is not defined or imported
            : error CS0518: The predefined type `System.Array' is not defined or imported
            : error CS0518: The predefined type `System.Type' is not defined or imported
            : error CS0518: The predefined type `System.Collections.IEnumerator' is not defined or imported
            : error CS0518: The predefined type `System.Collections.IEnumerable' is not defined or imported
            : error CS0518: The predefined type `System.IDisposable' is not defined or imported
            : error CS0518: The predefined type `System.IntPtr' is not defined or imported
            : error CS0518: The predefined type `System.UIntPtr' is not defined or imported
            : error CS0518: The predefined type `System.RuntimeFieldHandle' is not defined or imported
            : error CS0518: The predefined type `System.RuntimeTypeHandle' is not defined or imported
            : error CS0518: The predefined type `System.Exception' is not defined or imported
    

    How do I fix these sort of problems? It looks like something is locked somewhere and won't allow me to reference standard libraries

  • StefanSchoebStefanSchoeb CHBeta, University

    In case you are building in Xamarin Studio and you are using the latest alpha right click to PCL -> options -> Build-Options (or something like this..) and select the targets you need..

  • jb_tcjb_tc USMember ✭✭

    For all who have the problem too (Fixed it with visual studio for mac):
    I fixed it by this steps: PCL -> Options -> Build -> General -> Build Engine and select the Option "Use MSBuild build engine (...)"

Sign In or Register to comment.