Comments (7)
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.
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.
Probably related: xamarin/xamarin-macios#9800
from maui-samples.
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.
You can just start with our HelloMacOS sample: https://github.com/dotnet/maui-samples/tree/main/HelloMacOS
and then remove any UI:
- Remove AppDelegate.cs: https://github.com/dotnet/maui-samples/blob/main/HelloMacOS/AppDelegate.cs
- Remove Main.storyboard: https://github.com/dotnet/maui-samples/blob/main/HelloMacOS/Main.storyboard
- Remove ViewController.cs and ViewController.designer.cs: https://github.com/dotnet/maui-samples/blob/main/HelloMacOS/ViewController.cs
- Don't call NSApplication.Main: https://github.com/dotnet/maui-samples/blob/main/HelloMacOS/Main.cs#L10
- Remove NSPrincipalClass and NSMainStoryboardFile from the Info.plist:
maui-samples/HelloMacOS/Info.plist
Lines 25 to 28 in 4506777
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:
maui-samples/HelloMacOS/Main.cs
Line 9 in 4506777
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.
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.
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)
- why are all sample codes not running because of packages? HOT 3
- BugSweeper
- WebAuthenticator in PlatformIntegrationDemo ends (crashes?) App HOT 1
- Native embedding sample
- NativeEmbeddingDemo doesn't work. HOT 2
- DatePicker crashes app HOT 3
- Point of Sale will not even Compile... HOT 4
- WEATHER APP DOES NOT RUN!! HOT 2
- Update quest.config
- Share.RequestAsync() doesn't work on .Net MAUI HOT 1
- Update OIDC keys for the OSPO API
- All of the CollectionView samples need to be updated so the CV is inside a Grid not a StackLayout
- MAUI and OpenXR HOT 1
- ISSUE on Windows for any official .NET MAUI examples in the repo that uses TableView
- Update native embedding sample
- Application name in the Localization Sample does not work on iOS platform. HOT 2
- Command bindings are not re-established when navigating back and forth in UIInterface samples HOT 3
- CollectionView ScrollTo not working HOT 1
- Push notifications sample HOT 1
- PlatformIntegrationDemo WebAuthenticator problems on emulator?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from maui-samples.