plus_plugins icon indicating copy to clipboard operation
plus_plugins copied to clipboard

[Bug]: Compilation issue on MacOS 10

Open fmatuszewski opened this issue 11 months ago • 3 comments

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

  • [X] I searched issues in this repository and couldn't find such bug/problem
  • [X] I Google'd a solution and I couldn't find it
  • [X] I searched on StackOverflow for a solution and I couldn't find it
  • [X] I read the README.md file of the plugin
  • [X] I'm using the latest version of the plugin
  • [X] All dependencies are up to date with flutter pub upgrade
  • [X] I did a flutter clean
  • [X] I tried running the example project

fmatuszewski avatar Mar 09 '24 09:03 fmatuszewski

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 avatar Mar 27 '24 06:03 miquelbeltran

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 avatar Mar 27 '24 07:03 miquelbeltran

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days

github-actions[bot] avatar Jun 26 '24 00:06 github-actions[bot]