picoe / Eto

Cross platform GUI framework for desktop and mobile applications in .NET
Other
3.55k stars 325 forks source link

ETO and Sparkle #640

Open tpitman opened 7 years ago

tpitman commented 7 years ago

I am using ETO in a cross platform app.

In my Mac version I would like to use Sparkle (https://sparkle-project.org/documentation/) as my app update method.

Sparkle requires adding an object to the MainMenu.nib file as part of setting it up. Since this is a Xamarin.Mac ETO project I don't have any nib files in it.

Can someone tell me how to get these 2 working together or if it is even possible? The above link contains the instructions.

There is another project that is called SparkleSharp that integrates Sparkle with Xamarin, but it also assumes a MainMenu.nib file because it just points the dev to the Sparkle site for the object and menu setup. That project is here: (https://github.com/rainycape/SparkleSharp)

cwensley commented 7 years ago

Adding the object to MainMenu.nib just creates an instance of the SUUpdater object afaik.. you may be able to just add it to your Program class of your Mac app like so:

class Program
{
    static SUUpdater updater;

    static void Main(string[] args)
    {
        var app = new Application();
        // this ensures SUUpdater is created after the bundle is initialized
        app.Initialized += (sender, e) => updater = new SUUpdater();
        app.Run(new MainForm());
    }
}

Note that SparkleSharp seems to be targeting Xamarin.Mac 2, so you need to use the XamMac2 platform for Eto.Forms (Mac or XamMac wouldn't work).

tpitman commented 7 years ago

Thank you for the reply.

I was hoping that adding it to a nib was just creating an instance, so I did something similar to what you suggested. I actually create the SUUpdater object inside of a UI invoked thread process when the user clicks on the ETO menu.

When I do this I get an exception when it tries to create the SUUpdate object.

Here is what it says:

System.Exception Could not create an native instance of the type 'Sparkle.SUUpdater': the native class hasn't been loaded. It is possible to ignore this condition by setting ObjCRuntime.Class.ThrowOnInitFailure to false.

Should I set that init failure ignore to false? doesn't seem like a good idea.

Just for fun I also tried doing it in Program.cs like you suggested and I get the same error.

cwensley commented 7 years ago

Did you include the Sparkle.framework inside your app bundle?

tpitman commented 7 years ago

I am using the SparkleSharp project which I believe includes that automatically. If I am wrong then they instructions don't say how to bring it in any other way that adding the reference.

tpitman commented 7 years ago

Thanks for helping me with this even though it isn't part of your project.

cwensley commented 7 years ago

You can double check if it's actually being put into the app bundle by right clicking the .app and then selecting "Show Package Contents". Otherwise, you might be able to find more information in the console.app, or, if you run your .app from command line by executing MyApp.app/Contents/MacOS/MyApp, it would show any .NET output

No worries about asking about this, it's good to have this kind of stuff figured out for everyone else as well and just helps the community in general.

One thing you can do is try to get it working in a 'pure' Xamarin.Mac application to see if you run into the same issues, as using Eto.Forms is almost identical to that as it is just an abstraction.

There may be some issues with how Eto.Forms gets around having a MainMenu.nib with how Sparkle detects the bundle, so you can possibly follow Sparkle's instructions for how to set it up for a non-app bundle

tpitman commented 7 years ago

Sparkle is inside the app bundle, so that is not it. To answer another question you asked I am using Xamarin.XamMac2.

I tried running the app from command line and it just gives the same error without any new information.

I will have to try making a regular app and see if that works.

I will have to play around with that and also the non-app bundle version, though this app should be a normal bundle since it is an app.

If anyone gets this working please let me know. I will do the same.