-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wx: Add WX_MACOS_NON_GUI_APP
#6113
Conversation
CT Test Results 2 files 17 suites 3m 47s ⏱️ Results for commit 2df4e29. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts// Erlang/OTP Github Action Bot |
We cannot depend on `is_packaged_app()` check because it is not a perfect way of checking if app is bundled. It would return true when the app is bundled with a launcher like this: ```swift import AppKit let task = Process() task.launchPath = "/Users/wojtek/src/otp/bin/erl" task.arguments = ["-noshell", "-eval", "wx:new(), timer:sleep(5000), halt()"] try task.run() task.waitUntilExit() ``` It would return false for this launcher, however: ```swift import AppKit class AppDelegate: NSObject, NSApplicationDelegate { func applicationDidFinishLaunching(_ aNotification: Notification) { let task = Process() task.launchPath = "/Users/wojtek/src/otp/bin/erl" task.arguments = ["-noshell", "-eval", "wx:new(), timer:sleep(5000), halt()"] try! task.run() } } let app = NSApplication.shared let delegate = AppDelegate() app.delegate = delegate app.run() ``` Btw, there has recently been a fix in wx [1] and we'd only be able to take advantage of it when `OSXIsGUIApplication` returns true (and when wx recognizes our app as properly bundled, see [2]). And so I believe to support variety of scenarios, we need precise control. [1] https://github.com/wxWidgets/wxWidgets #22508 [2] https://github.com/erlang/otp #6070
b52c6f9
to
2df4e29
Compare
This is PR is really only useful for the 2nd approach I mentioned in the PR description, the AppDelegate one, but there are some caveats with that which I have learned since so let's hold off on this change for a moment. |
Yeah, as noted in the PR description there is a variety of scenarios for using wx so I believe more precise control is really useful here. We'd appreciate if we could land this PR so we (Livebook Desktop) could stop using our fork. :) |
Can this be done without an env variable, i.e. in some cleaner way? Or is this such a special case that I should just accept it as it is? |
I unfortunately couldn't think of a better way of solving this issue, I think we need to override Would controlling this with |
@dgud fyi, for Livebook we are also exploring an altogether different way of building Mac apps with OTP described in #6070 (comment) and for that we wouldn't need this patch. I still think the patch is useful though as there are so many different ways of running OTP and wx and so I think it is very helpful to have some flexibility. |
We cannot depend on
is_packaged_app()
check because it is not a perfect way of checking if app is bundled.It would return true when the app is bundled with a launcher like this:
It would return false for this launcher, however:
Btw, there has recently been a fix in wx [1] and we'd only be able to take advantage of it when
OSXIsGUIApplication
returns true (and when wx recognizes our app as properly bundled, see [2]). And so I believe to support variety of scenarios, we need precise control.[1] wxWidgets/wxWidgets#22508
[2] #6070 (comment)