Alfonso Tesauro
Alfonso Tesauro

Reputation: 1792

Is it possible to run Webmin in a Cocoa Application written in Swift or Objective-C using a WKWebView?

I am trying to prepare a Cocoa Swift / Objective-C GUI around a binary executable on macOS, and this binary executable is shipped with a webmin module to edit its configuration file. Would it be possible to run this module into webmin in a WKWebView ? Thanks a lot for your attention and for any suggestion. I am not a skilled web developer so I really don't know how to convince :) WKWebView to render cgi and perl. I can put all the webmin and webmin module files into the application bundle in a separate folder and point to that folder with a NSURLRequest. Something like:

//  Mac WebMin
//
//  Created by Alfonso Maria Tesauro on 18/12/24.
//

#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>

@interface AppDelegate : NSObject <NSApplicationDelegate>

@property (assign) IBOutlet WKWebView *webMinWKWebView;


@end

//
//  AppDelegate.m
//  Mac WebMin
//
//  Created by Alfonso Maria Tesauro on 18/12/24.
//

#import "AppDelegate.h"

@interface AppDelegate ()

@property (strong) IBOutlet NSWindow *window;

@end

@implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {                                                                                      // Insert code here to initialize your application

    NSString *webminFolderPath = [[NSBundle mainBundle] pathForResource:@"webMinFiles" ofType:@""];

NSURL *webMinFilesURLInBundle = [NSURL fileURLWithPath:[webminFolderPath stringByAppendingPathComponent:@"index.cgi"]];

NSURLRequest *webMinRequest = [[NSURLRequest alloc] initWithURL:webMinFilesURLInBundle];

[self.webMinWKWebView loadRequest:webMinRequest];

}


- (void)applicationWillTerminate:(NSNotification *)aNotification             {
    // Insert code here to tear down your application
}


- (BOOL)applicationSupportsSecureRestorableState:(NSApplication     *)app {
    return YES;
}


@end

Upvotes: 0

Views: 56

Answers (0)

Related Questions