ITADN

Building against API 28+ without libandroid-spawn has different nullability for posix_spawn* types

#219Closedmarcprux 创建于 2025-04-30
M
marcpruxcommented
When building against an Android SDK that targets API level 28 and higher, we no longer need to include the termux `libandroid-spawn.so`. But now the `posix_spawn*` types have a different nullability, leading to errors like [this one](https://github.com/swift-everywhere/swift-package-builds/actions/runs/14753153132/job/41415071652#step:59:201): ``` /home/runner/work/swift-package-builds/swift-package-builds/swift-tools-support-core/Sources/TSCBasic/Process/Process.swift:736:50: error: value of optional type 'posix_spawn_file_actions_t?' (aka 'Optional<OpaquePointer>') must be unwrapped to a value of type 'posix_spawn_file_actions_t' (aka 'OpaquePointer') 734 | // If no redirect was requested, open the pipe for stderr. 735 | try open(pipe: &stderrPipe) 736 | posix_spawn_file_actions_adddup2(&fileActions, stderrPipe[1], 2) | |- error: value of optional type 'posix_spawn_file_actions_t?' (aka 'Optional<OpaquePointer>') must be unwrapped to a value of type 'posix_spawn_file_actions_t' (aka 'OpaquePointer') | `- note: force-unwrap using '!' to abort execution if the optional value contains 'nil' 737 | 738 | // Close the other ends of the pipe since they were dupped to 2. ``` The nullability difference is mentioned at https://github.com/finagolfin/swift-android-sdk/commit/52cb792ef679fcb548794c424ee3306fc935ef33. We can just update `swift-tools-support-core` and other packages that use `posix_spawn` to special-case Android's optionality, but is there any way that the code can support both the older 6.1 SDK and future 6.2+ SDKs with the differing nullability?
关闭于 2025-05-01 1 条评论