fluttercommunity / plus_plugins

Flutter Community Plus Plugins
BSD 3-Clause "New" or "Revised" License
1.52k stars 888 forks source link

[Bug]: Compilation issue on MacOS 10 #2664

Open fmatuszewski opened 3 months ago

fmatuszewski commented 3 months ago

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

miquelbeltran commented 3 months ago

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 commented 3 months ago

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.

github-actions[bot] commented 1 week ago

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