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

Compile failure on MacOS 10.12 Sierra #2478

Closed
nullst opened this issue Sep 17, 2021 · 2 comments
Closed

Compile failure on MacOS 10.12 Sierra #2478

nullst opened this issue Sep 17, 2021 · 2 comments
Labels
blocker Items that would block a forthcoming release bug Something isn't working OS:macOS Tickets affecting only macOS

Comments

@nullst
Copy link
Contributor

nullst commented Sep 17, 2021

Describe the bug:

Not sure if this is a bug or a deliberate decision, but develop branch (UPD: or fyne version 2.1.0) currently cannot be built on Mac OS 10.12 Sierra since it uses some API introduced in Mac OS 10.14. The master branch (UPD: fyne version 2.0.4) works fine.

I've managed to make develop compile after the following modifications. Perhaps they can be applied conditionally during compile-time, but I don't know how to detect "Mac OS older than..." in .m files and in the cgo flags in .go files.

(A) NSControlStateValue vs NSCellStateValue

The file internal/driver/glfw/menu_darwin.m in develop contains the following fragment:

#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 
NSControlStateValue STATE_ON = NSControlStateValueOn; 
NSControlStateValue STATE_OFF = NSControlStateValueOff; 
#else
NSControlStateValue STATE_ON = NSOnState; 
NSControlStateValue STATE_OFF = NSOffState; 
#endif

On 10.12 not only the constant NSControlStateValueOn is unavailable, but also the type NSControlStateValue. Thus, the latter half of the code fragment should use the (deprecated) type NSCellStateValue instead.

(B) UserNotifications framework in code

The file app/app_darwin.m uses UserNotifications framework introduced in 10.14. This can be circumvented by only using the extern'ed function fallbackSend(), whatever it is. I haven't tested whether the notifications are sent or not, but at least fyne@develop compiles after I replace the entire file app/app_darwin.m with the following:

// +build !ci

#import <Foundation/Foundation.h>

static int notifyNum = 0;

extern void fallbackSend(char *cTitle, char *cBody);

bool isBundled() {
    return [[NSBundle mainBundle] bundleIdentifier] != nil;
}

void sendNotification(char *cTitle, char *cBody) {
    NSString *title = [NSString stringWithUTF8String:cTitle];
    NSString *body = [NSString stringWithUTF8String:cBody];
    fallbackSend((char *)[title UTF8String], (char *)[body UTF8String]);
}

(C) UserNotifications framework in cgo flags

Related to the previous item, the file app/app_darwin.go controls the build process for app/app_darwin.m. It needs to be modified to omit the inclusion of non-available framework UserNotifications by removing it from the flags:

:#cgo LDFLAGS: -framework Foundation

To Reproduce:

Steps to reproduce the behaviour:

  1. Have Mac OS 10.12 Sierra
  2. Try to compile any application with the develop branch of fyne.
  3. Get errors.

Device (please complete the following information):

  • OS: MacOS
  • Version: 10.12.6 Sierra
  • Go version: go1.15.3 darwin/amd64
  • Fyne version: develop branch
@nullst nullst added the unverified A bug that has been reported but not verified label Sep 17, 2021
@andydotxyz andydotxyz added bug Something isn't working and removed unverified A bug that has been reported but not verified labels Oct 7, 2021
@andydotxyz andydotxyz added this to the Fixes (v2.1.x) milestone Oct 7, 2021
@andydotxyz
Copy link
Member

Thanks. We also have to figure out how to set the right LDFLAGS in the #cgo block in app/app_darwin.go as well.
I'll check the docs later, but shout if you have an idea.

@Jacalz Jacalz changed the title The 'develop' branch does not build on Mac 10.12 Sierra Compile failure on MacOS 10.12 Sierra Oct 19, 2021
@Jacalz Jacalz added blocker Items that would block a forthcoming release OS:macOS Tickets affecting only macOS labels Oct 19, 2021
@andydotxyz
Copy link
Member

Fixed on release/v2.1.x branch ready for 2.1.2. Use "-tags legacy" to apply, we could not find a better way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker Items that would block a forthcoming release bug Something isn't working OS:macOS Tickets affecting only macOS
Projects
None yet
Development

No branches or pull requests

3 participants