Compilation error encountered when running swift build on Ubuntu 24.04 with swift 5.10 Release
Steps to Reproduce
Set up the project environment on Ubuntu 24.04.
Run the command swift build.
Expected Results
The project should compile successfully without any errors.
Actual Results
The following error is thrown during the compilation:
In file : /ZIPFoundation/Sources/ZIPFoundation/Archive+MemoryFile.swift:45:20:
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>')
fseeko(result, 0, SEEK_END)
Small fix I have been using so far
I modified the MemoryFile() function slightly, just so the error does not get thrown during building.
class MemoryFile {
private(set) var data: Data
private var offset = 0
init(data: Data = Data()) {
self.data = data
}
func open(mode: String) -> FILEPointer? {
let cookie = Unmanaged.passRetained(self)
let writable = mode.count > 0 && (mode.first! != "r" || mode.last! == "+")
let append = mode.count > 0 && mode.first! == "a"
#if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS) || os(Android)
let result = writable
? funopen(cookie.toOpaque(), readStub, writeStub, seekStub, closeStub)
: funopen(cookie.toOpaque(), readStub, nil, seekStub, closeStub)
#else
let stubs = cookie_io_functions_t(read: readStub, write: writeStub, seek: seekStub, close: closeStub)
let result = fopencookie(cookie.toOpaque(), mode, stubs)
#endif
if append {
if let unwrappedResult = result {
fseeko(unwrappedResult, 0, SEEK_END)
} else {
// Handle the error if result is nil
print("Error: result is nil when attempting to open in append mode")
return nil
}
}
return result
}
}
Summary
Compilation error encountered when running
swift build
on Ubuntu 24.04 with swift 5.10 ReleaseSteps to Reproduce
swift build
.Expected Results
The project should compile successfully without any errors.
Actual Results
The following error is thrown during the compilation:
In file :
/ZIPFoundation/Sources/ZIPFoundation/Archive+MemoryFile.swift:45:20:
Small fix I have been using so far
I modified the MemoryFile() function slightly, just so the error does not get thrown during building.