Repository: beeware/toga

Issue:
macOS 10.12.6 (py3.9.7) : briefcase dev fails, appkit.py, line 70 fails dlsym(NSAboutPanelOptionApplicationIcon): symbol not found
Just trying to get through the tutorial steps on Sierra 10.12.6:

(venv) ~/Documents/org.python/beeware-test/bongo$ briefcase dev

Starting in dev mode...
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/gen/Documents/org.python/beeware-test/bongo/src/bongo/__main__.py", line 4, in <module>
    main().main_loop()
  File "/Users/gen/Documents/org.python/beeware-test/bongo/src/bongo/app.py", line 27, in main
    return Bongo()
  File "/Users/gen/Documents/org.python/beeware-test/venv/lib/python3.9/site-packages/toga/app.py", line 272, in __init__
    self.factory = get_platform_factory(factory)
  File "/Users/gen/Documents/org.python/beeware-test/venv/lib/python3.9/site-packages/toga/platform.py", line 35, in get_platform_factory
    from toga_cocoa import factory
  File "/Users/gen/Documents/org.python/beeware-test/venv/lib/python3.9/site-packages/toga_cocoa/factory.py", line 1, in <module>
    from .app import App, DocumentApp, MainWindow
  File "/Users/gen/Documents/org.python/beeware-test/venv/lib/python3.9/site-packages/toga_cocoa/app.py", line 12, in <module>
    from .keys import cocoa_key
  File "/Users/gen/Documents/org.python/beeware-test/venv/lib/python3.9/site-packages/toga_cocoa/keys.py", line 2, in <module>
    from toga_cocoa.libs import (
  File "/Users/gen/Documents/org.python/beeware-test/venv/lib/python3.9/site-packages/toga_cocoa/libs/__init__.py", line 22, in <module>
    from .appkit import *  # noqa: F401, F403
  File "/Users/gen/Documents/org.python/beeware-test/venv/lib/python3.9/site-packages/toga_cocoa/libs/appkit.py", line 70, in <module>
    NSAboutPanelOptionApplicationIcon = NSString(c_void_p.in_dll(appkit, "NSAboutPanelOptionApplicationIcon"))
ValueError: dlsym(0x7ff5c87264a0, NSAboutPanelOptionApplicationIcon): symbol not found



Discussion:
Thanks for the report. This is a compatibility issue with macOS Sierra; the symbol being reported was added in macOS High Sierra (10.13).

From the look of it, there's no "pre-10.13" option here; the keys weren't available in Sierra and earlier. From the look of it, if we were to catch the ValueError exception and set the constants to `None`, this should make apps run under Sierra. 




Would like to pick this up :)

Resolving patch:
diff --git a/src/cocoa/toga_cocoa/libs/appkit.py b/src/cocoa/toga_cocoa/libs/appkit.py
--- a/src/cocoa/toga_cocoa/libs/appkit.py
+++ b/src/cocoa/toga_cocoa/libs/appkit.py
@@ -67,11 +67,19 @@ class NSAlertStyle(Enum):
 NSApplicationDidHideNotification = c_void_p.in_dll(appkit, 'NSApplicationDidHideNotification')
 NSApplicationDidUnhideNotification = c_void_p.in_dll(appkit, 'NSApplicationDidUnhideNotification')
 
-NSAboutPanelOptionApplicationIcon = NSString(c_void_p.in_dll(appkit, "NSAboutPanelOptionApplicationIcon"))
-NSAboutPanelOptionApplicationName = NSString(c_void_p.in_dll(appkit, "NSAboutPanelOptionApplicationName"))
-NSAboutPanelOptionApplicationVersion = NSString(c_void_p.in_dll(appkit, "NSAboutPanelOptionApplicationVersion"))
-NSAboutPanelOptionCredits = NSString(c_void_p.in_dll(appkit, "NSAboutPanelOptionCredits"))
-NSAboutPanelOptionVersion = NSString(c_void_p.in_dll(appkit, "NSAboutPanelOptionVersion"))
+# NSAboutPanelOption* keys are available only 10.13+
+try:
+    NSAboutPanelOptionApplicationIcon = NSString(c_void_p.in_dll(appkit, "NSAboutPanelOptionApplicationIcon"))
+    NSAboutPanelOptionApplicationName = NSString(c_void_p.in_dll(appkit, "NSAboutPanelOptionApplicationName"))
+    NSAboutPanelOptionApplicationVersion = NSString(c_void_p.in_dll(appkit, "NSAboutPanelOptionApplicationVersion"))
+    NSAboutPanelOptionCredits = NSString(c_void_p.in_dll(appkit, "NSAboutPanelOptionCredits"))
+    NSAboutPanelOptionVersion = NSString(c_void_p.in_dll(appkit, "NSAboutPanelOptionVersion"))
+except ValueError:
+    NSAboutPanelOptionApplicationIcon = None
+    NSAboutPanelOptionApplicationName = None
+    NSAboutPanelOptionApplicationVersion = None
+    NSAboutPanelOptionCredits = None
+    NSAboutPanelOptionVersion = None
 
 ######################################################################
 # NSAttributedString.h


Test patch: