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

[Bug]: Compilation issue on MacOS 10 #2664

Open
8 tasks done
fmatuszewski opened this issue Mar 9, 2024 · 2 comments
Open
8 tasks done

[Bug]: Compilation issue on MacOS 10 #2664

fmatuszewski opened this issue Mar 9, 2024 · 2 comments
Labels

Comments

@fmatuszewski
Copy link

Platform

Mac os 10

Plugin

device_info_plus

Version

9.1.2

Flutter SDK

3.0.0

Steps to reproduce

For older systems kIOMainPortDefault is not available in scope during compile time and so it throws an error.
device_info_plus-9.1.2/macos/Classes/SystemUUID.swift:10:58: error: cannot find 'kIOMainPortDefault' in scope
            platformExpert = IOServiceGetMatchingService(kIOMainPortDefault, dev).
If fixed that by changing runtime check to compile time check.
To recreate:

  1. Try to compile package on older systems
    To fix:

in Class:
/plus_plugins/packages/device_info_plus/device_info_plus/macos/Classes/SystemUUID.swift

Code Sample

To fix this issue:
Replace:
Runtime check
        if #available(macOS 12, *) {
            platformExpert = IOServiceGetMatchingService(kIOMainPortDefault, dev)
        } else {
            platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, dev)
        }

With:
Compile Time check.
        #if MACOS12_OR_LATER
            print("Running on macOS 12 or newer")
            platformExpert = IOServiceGetMatchingService(kIOMainPortDefault, dev)
        #else
            print("Running on an older version of macOS")
            platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, dev)
        #endif

Logs

fix available above.

Flutter Doctor

fix available above.

Checklist before submitting a bug

  • I searched issues in this repository and couldn't find such bug/problem
  • I Google'd a solution and I couldn't find it
  • I searched on StackOverflow for a solution and I couldn't find it
  • I read the README.md file of the plugin
  • I'm using the latest version of the plugin
  • All dependencies are up to date with flutter pub upgrade
  • I did a flutter clean
  • I tried running the example project
@fmatuszewski fmatuszewski added bug Something isn't working triage labels Mar 9, 2024
@miquelbeltran miquelbeltran changed the title [Bug]: [Bug]: Compilation issue on MacOS 10 Mar 27, 2024
@miquelbeltran
Copy link
Member

Hello! Since the minimum supported target is 10.14, this should be addressed.

I'll try to reproduce the issue first using GitHub CI, and if I can reproduce the compilation issue, then I'll apply your patch suggestion.

@miquelbeltran miquelbeltran self-assigned this Mar 27, 2024
@miquelbeltran
Copy link
Member

I tried to compile the project using a macos-11 image (it is the lowest I could find) and the project compiled correctly: https://github.com/fluttercommunity/plus_plugins/actions/runs/8447836608/job/23138853477?pr=2758

So I could not reproduce the compilation issue.

@miquelbeltran miquelbeltran removed their assignment Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants