Giter Club home page Giter Club logo

Comments (7)

chucker avatar chucker commented on July 17, 2024

I gave it a shot, but (as of preview 3) couldn't quite get it to work.

Setting the framework does pull in various Mac-specific dependencies, and I do get IntelliSense for the Foundation and AppKit namespaces.

However, at runtime, calling an AppKit method fails with:

// System.DllNotFoundException: Could not find the runtime library libxammac.dylib
NSApplication.Init();

And for Foundation:

// [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException:
// TypeInitialization_Type, Foundation.NSString
var str = new NSString("test");
var num = new NSNumber(123.45);

Haven't tried with a preview 4 build.

from maui-samples.

theimowski avatar theimowski commented on July 17, 2024

Thanks @chucker however seems that as of 6.0.100-preview.4.21255.9 it's still failing due to above issues

from maui-samples.

chucker avatar chucker commented on July 17, 2024

Probably related: xamarin/xamarin-macios#9800

from maui-samples.

chucker avatar chucker commented on July 17, 2024

Also related: xamarin/xamarin-macios#11094

If I add <SelfContained>true</SelfContained> and run the binary inside the bundle (which without that property doesn't get produced), it works for me, aside from a MonoTouch warning at the beginning.

MonoTouch: Could not install sigaction override, unexpected sigaction implementation.
xamarin_vm_initialize (3, 0x7ffeeb4a4f80, 0x7ffeeb4a4f60): rv: 0
Hello World!
str has string value test
num has float value 123.45

from maui-samples.

rolfbjarne avatar rolfbjarne commented on July 17, 2024

You can just start with our HelloMacOS sample: https://github.com/dotnet/maui-samples/tree/main/HelloMacOS

and then remove any UI:

You might also want to add an LSUIElement entry to your Info.plist (this will prevent an icon from showing up in the dock when you run your app):

<key>LSUIElement</key>
<string>1</string>

Then finally you can add your code after the call to NSApplication.Init here:

NSApplication.Init();

As @chucker mentions here, you have to execute the executable inside the app bundle (in the Contents/MacOS directory) directly. Don't try to use "dotnet path/to/.dll", that won't work.

from maui-samples.

theimowski avatar theimowski commented on July 17, 2024

Thanks - that indeed works 👍

I'm getting some warnings in runtime, but just ignoring them for now:

objc[23294]: Class AMSupportURLConnectionDelegate is implemented in both /System/Library/PrivateFrameworks/OSPersonalization.framework/Versions/A/OSPersonalization (0x7fff8d675250) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x105219ae0). One of the two will be used. Which one is undefined.
objc[23294]: Class AMSupportURLSession is implemented in both /System/Library/PrivateFrameworks/OSPersonalization.framework/Versions/A/OSPersonalization (0x7fff8d6752a0) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x105219b30). One of the two will be used. Which one is undefined.
MonoTouch: Could not install sigaction override, unexpected sigaction implementation.
xamarin_vm_initialize (3, 0x7ffeeb51c5e0, 0x7ffeeb51c5c0): rv: 0

from maui-samples.

rolfbjarne avatar rolfbjarne commented on July 17, 2024

Thanks - that indeed works 👍

I'm getting some warnings in runtime, but just ignoring them for now:

objc[23294]: Class AMSupportURLConnectionDelegate is implemented in both /System/Library/PrivateFrameworks/OSPersonalization.framework/Versions/A/OSPersonalization (0x7fff8d675250) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x105219ae0). One of the two will be used. Which one is undefined.
objc[23294]: Class AMSupportURLSession is implemented in both /System/Library/PrivateFrameworks/OSPersonalization.framework/Versions/A/OSPersonalization (0x7fff8d6752a0) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x105219b30). One of the two will be used. Which one is undefined.
MonoTouch: Could not install sigaction override, unexpected sigaction implementation.
xamarin_vm_initialize (3, 0x7ffeeb51c5e0, 0x7ffeeb51c5c0): rv: 0

The two first ones come from system code, and I don't think there's much we can do about them.

The two last ones come from our code, and will be fixed in a future preview.

from maui-samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.