-
Notifications
You must be signed in to change notification settings - Fork 135
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
Compatibility: raspberry pi 5? swift 5.10 #140
Comments
I had this problem, too. You need to delete the existing lines 175 and 193 in SwiftyGPIO.swift and replace each with:: guard let fp else { return } Sadly, I suspect this won't get your code working though. See my issue here. I think there have been other changes in recent Ubuntu (or the kernel more likely) as well. |
Any thoughts on this? Does downgrading to Ubuntu 22.x make any difference? I'm running on Pi 4... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We're excited about using SwiftyGPIO in our new project which involves a Raspberry Pi. We currently have the following configuration:
We're hitting the following errors when adding the SwiftyGPIO package. I am wondering if it is because of Pi 5? Swift 5.1 or Ubuntu 24.04? On the main page, Pi 5 is not listed as compatible.
I can read that Swift 5.x is supported.
Here is our package.swift file:
The package update command run smoothly but once we build our empty main.swift file, we get the error:
philippe@oursler:~/Desktop/PIRSensorProject$ swift build Building for debugging... /home/philippe/Desktop/PIRSensorProject/.build/checkouts/SwiftyGPIO/Sources/SwiftyGPIO.swift:175:24: error: value of optional type 'UnsafeMutablePointer<FILE>?' (aka 'Optional<UnsafeMutablePointer<_IO_FILE>>') must be unwrapped to a value of type 'UnsafeMutablePointer<FILE>' (aka 'UnsafeMutablePointer<_IO_FILE>') defer { fclose(fp) } ^ /home/philippe/Desktop/PIRSensorProject/.build/checkouts/SwiftyGPIO/Sources/SwiftyGPIO.swift:175:24: note: coalesce using '??' to provide a default when the optional value contains 'nil' defer { fclose(fp) } ^ ?? <#default value#> /home/philippe/Desktop/PIRSensorProject/.build/checkouts/SwiftyGPIO/Sources/SwiftyGPIO.swift:175:24: note: force-unwrap using '!' to abort execution if the optional value contains 'nil' defer { fclose(fp) } ^ ! /home/philippe/Desktop/PIRSensorProject/.build/checkouts/SwiftyGPIO/Sources/SwiftyGPIO.swift:178:64: error: value of optional type 'UnsafeMutablePointer<FILE>?' (aka 'Optional<UnsafeMutablePointer<_IO_FILE>>') must be unwrapped to a value of type 'UnsafeMutablePointer<FILE>' (aka 'UnsafeMutablePointer<_IO_FILE>') return fwrite(buffer.baseAddress, buffer.count, 1, fp) - buffer.count ^ /home/philippe/Desktop/PIRSensorProject/.build/checkouts/SwiftyGPIO/Sources/SwiftyGPIO.swift:178:64: note: coalesce using '??' to provide a default when the optional value contains 'nil' return fwrite(buffer.baseAddress, buffer.count, 1, fp) - buffer.count ^ ?? <#default value#> /home/philippe/Desktop/PIRSensorProject/.build/checkouts/SwiftyGPIO/Sources/SwiftyGPIO.swift:178:64: note: force-unwrap using '!' to abort execution if the optional value contains 'nil' return fwrite(buffer.baseAddress, buffer.count, 1, fp) - buffer.count ^ ! /home/philippe/Desktop/PIRSensorProject/.build/checkouts/SwiftyGPIO/Sources/SwiftyGPIO.swift:181:23: error: value of optional type 'UnsafeMutablePointer<FILE>?' (aka 'Optional<UnsafeMutablePointer<_IO_FILE>>') must be unwrapped to a value of type 'UnsafeMutablePointer<FILE>' (aka 'UnsafeMutablePointer<_IO_FILE>') if ferror(fp) != 0 { ^ /home/philippe/Desktop/PIRSensorProject/.build/checkouts/SwiftyGPIO/Sources/SwiftyGPIO.swift:181:23: note: coalesce using '??' to provide a default when the optional value contains 'nil' if ferror(fp) != 0 { ^ ?? <#default value#> /home/philippe/Desktop/PIRSensorProject/.build/checkouts/SwiftyGPIO/Sources/SwiftyGPIO.swift:181:23: note: force-unwrap using '!' to abort execution if the optional value contains 'nil' if ferror(fp) != 0 { ^ ! /home/philippe/Desktop/PIRSensorProject/.build/checkouts/SwiftyGPIO/Sources/SwiftyGPIO.swift:193:24: error: value of optional type 'UnsafeMutablePointer<FILE>?' (aka 'Optional<UnsafeMutablePointer<_IO_FILE>>') must be unwrapped to a value of type 'UnsafeMutablePointer<FILE>' (aka 'UnsafeMutablePointer<_IO_FILE>') defer { fclose(fp) } ^ /home/philippe/Desktop/PIRSensorProject/.build/checkouts/SwiftyGPIO/Sources/SwiftyGPIO.swift:193:24: note: coalesce using '??' to provide a default when the optional value contains 'nil' defer { fclose(fp) } ^ ?? <#default value#> /home/philippe/Desktop/PIRSensorProject/.build/checkouts/SwiftyGPIO/Sources/SwiftyGPIO.swift:193:24: note: force-unwrap using '!' to abort execution if the optional value contains 'nil' defer { fclose(fp) } ^ ! /home/philippe/Desktop/PIRSensorProject/.build/checkouts/SwiftyGPIO/Sources/SwiftyGPIO.swift:198:60: error: value of optional type 'UnsafeMutablePointer<FILE>?' (aka 'Optional<UnsafeMutablePointer<_IO_FILE>>') must be unwrapped to a value of type 'UnsafeMutablePointer<FILE>' (aka 'UnsafeMutablePointer<_IO_FILE>') let len = fread(buffer.baseAddress, MAXLEN, 1, fp) ^ /home/philippe/Desktop/PIRSensorProject/.build/checkouts/SwiftyGPIO/Sources/SwiftyGPIO.swift:198:60: note: coalesce using '??' to provide a default when the optional value contains 'nil' let len = fread(buffer.baseAddress, MAXLEN, 1, fp) ^ ?? <#default value#> /home/philippe/Desktop/PIRSensorProject/.build/checkouts/SwiftyGPIO/Sources/SwiftyGPIO.swift:198:60: note: force-unwrap using '!' to abort execution if the optional value contains 'nil' let len = fread(buffer.baseAddress, MAXLEN, 1, fp) ^ ! /home/philippe/Desktop/PIRSensorProject/.build/checkouts/SwiftyGPIO/Sources/SwiftyGPIO.swift:198:60: error: value of optional type 'UnsafeMutablePointer<FILE>?' (aka 'Optional<UnsafeMutablePointer<_IO_FILE>>') must be unwrapped to a value of type 'UnsafeMutablePointer<FILE>' (aka 'UnsafeMutablePointer<_IO_FILE>') let len = fread(buffer.baseAddress, MAXLEN, 1, fp) ^ /home/philippe/Desktop/PIRSensorProject/.build/checkouts/SwiftyGPIO/Sources/SwiftyGPIO.swift:198:60: note: coalesce using '??' to provide a default when the optional value contains 'nil' let len = fread(buffer.baseAddress, MAXLEN, 1, fp) ^ ?? <#default value#> /home/philippe/Desktop/PIRSensorProject/.build/checkouts/SwiftyGPIO/Sources/SwiftyGPIO.swift:198:60: note: force-unwrap using '!' to abort execution if the optional value contains 'nil' let len = fread(buffer.baseAddress, MAXLEN, 1, fp) ^ ! error: fatalError
We're trying to identify the problem, if it is hardware, we'll order a new Pi 5. Or if it is because of Ubuntu, we'll downgrade..
Thank you very much, we look forward to being able to use the package.
The text was updated successfully, but these errors were encountered: