Skip to content
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

OSX Mojave warnings... #75

Closed
pknudsgaard opened this issue Nov 12, 2018 · 6 comments
Closed

OSX Mojave warnings... #75

pknudsgaard opened this issue Nov 12, 2018 · 6 comments

Comments

@pknudsgaard
Copy link

Upgraded my laptop to Mojave and I am getting the following warnings:

vendor/github.com/getlantern/systray

systray_darwin.m:67:15: warning: 'setImage:' is deprecated: first deprecated in macOS 10.14 - Use the receiver's button.image instead [-Wdeprecated-declarations]
/System/Library/Frameworks/AppKit.framework/Headers/NSStatusItem.h:85:39: note: property 'image' is declared deprecated here
/System/Library/Frameworks/AppKit.framework/Headers/NSStatusItem.h:85:39: note: 'setImage:' has been explicitly marked deprecated here
systray_darwin.m:71:15: warning: 'setTitle:' is deprecated: first deprecated in macOS 10.14 - Use the receiver's button.title instead [-Wdeprecated-declarations]
/System/Library/Frameworks/AppKit.framework/Headers/NSStatusItem.h:83:38: note: property 'title' is declared deprecated here
/System/Library/Frameworks/AppKit.framework/Headers/NSStatusItem.h:83:38: note: 'setTitle:' has been explicitly marked deprecated here
systray_darwin.m:75:15: warning: 'setToolTip:' is deprecated: first deprecated in macOS 10.14 - Use the receiver's button.toolTip instead [-Wdeprecated-declarations]
/System/Library/Frameworks/AppKit.framework/Headers/NSStatusItem.h:89:38: note: property 'toolTip' is declared deprecated here
/System/Library/Frameworks/AppKit.framework/Headers/NSStatusItem.h:89:38: note: 'setToolTip:' has been explicitly marked deprecated here
systray_darwin.m:105:24: warning: 'NSOnState' is deprecated: first deprecated in macOS 10.14 [-Wdeprecated-declarations]
/System/Library/Frameworks/AppKit.framework/Headers/NSCell.h:80:34: note: 'NSOnState' has been explicitly marked deprecated here
systray_darwin.m:107:24: warning: 'NSOffState' is deprecated: first deprecated in macOS 10.14 [-Wdeprecated-declarations]
/System/Library/Frameworks/AppKit.framework/Headers/NSCell.h:79:34: note: 'NSOffState' has been explicitly marked deprecated here

@zereraz
Copy link
Contributor

zereraz commented May 25, 2019

I'm getting the following warnings

# github.com/getlantern/systray
systray_darwin.m:128:22: warning: 'NSOnState' is deprecated: first deprecated in macOS 10.14 [-Wdeprecated-declarations]
systray_darwin.m:9:33: note: expanded from macro 'NSControlStateValueOn'
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSCell.h:80:34: note: 'NSOnState' has been explicitly marked deprecated here
systray_darwin.m:130:22: warning: 'NSOffState' is deprecated: first deprecated in macOS 10.14 [-Wdeprecated-declarations]
systray_darwin.m:5:34: note: expanded from macro 'NSControlStateValueOff'
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSCell.h:79:34: note: 'NSOffState' has been explicitly marked deprecated here

@artheus
Copy link

artheus commented Jun 2, 2019

I am getting the same warnings as @raunaqrox.
In addition to this, my app will panic whenever I use systray.Run(onReady, onExit), this is the panic error message:

2019-06-02 10:44:41.745 ___go_build_main_go[22553:5250230] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /BuildRoot/Library/Caches/com.apple.xbs/Sources/Foundation/Foundation-1570.16/Foundation/Misc.subproj/NSUndoManager.m:361
2019-06-02 10:44:41.746 ___go_build_main_go[22553:5250230] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff2e1a8cf9 __exceptionPreprocess + 256
	1   libobjc.A.dylib                     0x00007fff58d38a17 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff2e1c3a16 +[NSException raise:format:arguments:] + 98
	3   Foundation                          0x00007fff30455e11 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 194
	4   Foundation                          0x00007fff30388e7c +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 473
	5   AppKit                              0x00007fff2b771f89 -[NSApplication run] + 916
	6   ___go_build_main_go                 0x0000000004280170 nativeLoop + 128
	7   ___go_build_main_go                 0x000000000427f67a _cgo_67d7e7d56c36_Cfunc_nativeLoop + 26
	8   ___go_build_main_go                 0x0000000004058e60 runtime.asmcgocall + 112
)
libc++abi.dylib: terminating with uncaught exception of type NSException
SIGABRT: abort
PC=0x7fff5a6a12c6 m=6 sigcode=0
signal arrived during cgo execution

goroutine 1 [syscall, locked to thread]:
runtime.cgocall(0x427f660, 0xc0000e9e88, 0xc000000101)
	/usr/local/Cellar/go/1.12.4/libexec/src/runtime/cgocall.go:128 +0x5b fp=0xc0000e9e58 sp=0xc0000e9e20 pc=0x40051bb
github.com/getlantern/systray._Cfunc_nativeLoop(0x0)
	_cgo_gotypes.go:107 +0x49 fp=0xc0000e9e88 sp=0xc0000e9e58 pc=0x427eab9
github.com/getlantern/systray.nativeLoop(...)
	/Users/artheus/go/pkg/mod/github.com/getlantern/[email protected]/systray_nonwindows.go:19
github.com/getlantern/systray.Run(0x4330db8, 0x4330db0)
	/Users/artheus/go/pkg/mod/github.com/getlantern/[email protected]/systray.go:81 +0x7f fp=0xc0000e9ec0 sp=0xc0000e9e88 pc=0x427e7ff
main.main()
	/Users/artheus/go/src/github.com/artheus/gopdate/main.go:16 +0x20d fp=0xc0000e9f98 sp=0xc0000e9ec0 pc=0x427f3bd
runtime.main()
	/usr/local/Cellar/go/1.12.4/libexec/src/runtime/proc.go:200 +0x20c fp=0xc0000e9fe0 sp=0xc0000e9f98 pc=0x402f29c
runtime.goexit()
	/usr/local/Cellar/go/1.12.4/libexec/src/runtime/asm_amd64.s:1337 +0x1 fp=0xc0000e9fe8 sp=0xc0000e9fe0 pc=0x40596c1

goroutine 20 [chan receive]:
github.com/getlantern/systray.Run.func2(0xc0000862a0, 0x4330db8)
	/Users/artheus/go/pkg/mod/github.com/getlantern/[email protected]/systray.go:66 +0x34
created by github.com/getlantern/systray.Run
	/Users/artheus/go/pkg/mod/github.com/getlantern/[email protected]/systray.go:65 +0xf1

rax    0x0
rbx    0x70000dc82000
rcx    0x70000dc80488
rdx    0x0
rdi    0xb03
rsi    0x6
rbp    0x70000dc804c0
rsp    0x70000dc80488
r8     0x70000dc80350
r9     0x70000dc80520
r10    0x0
r11    0x206
r12    0xb03
r13    0x3000000008
r14    0x6
r15    0x2d
rip    0x7fff5a6a12c6
rflags 0x206
cs     0x7
fs     0x0
gs     0x0

EDIT: I will add that I am using the latest master 26d5b92

@zereraz
Copy link
Contributor

zereraz commented Jun 18, 2019

@artheus Could you show your code, I had similar issue but that was due to me using nil values when onReady was not done. For reference I'm using systray here https://github.com/promignis/cwitch.

@scottgrobinson
Copy link

scottgrobinson commented Jun 18, 2019

@artheus I had the same issue which was resolved by adding
runtime.LockOSThread()

as per #20

@mikeschinkel
Copy link
Contributor

mikeschinkel commented Jun 19, 2019

We are getting the same issues as @raunaqrox where 'NSOnState' is deprecated:

I was able to get it to work on Mojave by forking, and commenting out lines 5 and 9 in systray_darwin.m but I doubt that will run on macOS prior to Mojave so we probably need a better solution and me not being a ObjectiveC developer, I am not sure I can solve it.

@mikeschinkel
Copy link
Contributor

I may have solved this with the following wrapper code to replace lines 4-10 of systray_darwin.m.

#if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_14
    #ifndef NSControlStateValueOff
      #define NSControlStateValueOff NSOffState
    #endif
    #ifndef NSControlStateValueOn
      #define NSControlStateValueOn NSOnState
    #endif
#endif

I will be submit a pull request with this code.

@joesis joesis closed this as completed in 0a29fdd Jun 26, 2019
joesis added a commit that referenced this issue Jun 26, 2019
teddywing added a commit to teddywing/systray that referenced this issue Jul 26, 2019
I was getting this error building on Mac OS X 10.12:

    $ pwd
    <$GOPATH>/src/github.com/getlantern/systray/example
    $ go run .
    # github.com/getlantern/systray
    systray_darwin.m:132:22: error: use of undeclared identifier 'NSControlStateValueOn'
    systray_darwin.m:134:22: error: use of undeclared identifier 'NSControlStateValueOff'

The `NSControlStateValueOn` and `NSControlStateValueOff` were not
defined because Mac OS versions prior to 10.14 don't define
`__MAC_10_14`.

From `/usr/include/Availability.h`:

> It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one
> source base that can be compiled to target a range of OS versions.  It is best
> to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values.
> That is because you might get compiled on an old OS that does not define a later
> OS version macro, and in the C preprocessor undefined values evaluate to zero
> in expresssions, which could cause the #if expression to evaluate in an unexpected
> way.
>
>     #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
>         // code only compiled when targeting Mac OS X and not iPhone
>         // note use of 1050 instead of __MAC_10_5
>         #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050
>             // code in here might run on pre-Leopard OS
>         #else
>             // code here can assume Leopard or later
>         #endif
>     #endif

See getlantern#75, getlantern#92.
@getlantern getlantern deleted a comment from joesis Mar 1, 2021
@getlantern getlantern deleted a comment from pknudsgaard Mar 1, 2021
ropog3ovomou pushed a commit to ropog3ovomou/systray that referenced this issue Jul 13, 2022
ropog3ovomou pushed a commit to ropog3ovomou/systray that referenced this issue Jul 13, 2022
ropog3ovomou pushed a commit to ropog3ovomou/systray that referenced this issue Jul 13, 2022
I was getting this error building on Mac OS X 10.12:

    $ pwd
    <$GOPATH>/src/github.com/getlantern/systray/example
    $ go run .
    # github.com/getlantern/systray
    systray_darwin.m:132:22: error: use of undeclared identifier 'NSControlStateValueOn'
    systray_darwin.m:134:22: error: use of undeclared identifier 'NSControlStateValueOff'

The `NSControlStateValueOn` and `NSControlStateValueOff` were not
defined because Mac OS versions prior to 10.14 don't define
`__MAC_10_14`.

From `/usr/include/Availability.h`:

> It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one
> source base that can be compiled to target a range of OS versions.  It is best
> to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values.
> That is because you might get compiled on an old OS that does not define a later
> OS version macro, and in the C preprocessor undefined values evaluate to zero
> in expresssions, which could cause the #if expression to evaluate in an unexpected
> way.
>
>     #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED
>         // code only compiled when targeting Mac OS X and not iPhone
>         // note use of 1050 instead of __MAC_10_5
>         #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050
>             // code in here might run on pre-Leopard OS
>         #else
>             // code here can assume Leopard or later
>         #endif
>     #endif

See getlantern#75, getlantern#92.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants