ReactiveX / RxSwift

Reactive Programming in Swift
MIT License
24.37k stars 4.17k forks source link

Missing imports warn 'this is an error in Swift 6' #2554

Closed drewster99 closed 6 months ago

drewster99 commented 11 months ago

Short description of the issue:

Release builds of RxSwift (and other targets) emit many warnings that various references to Foundation types, such as Foundation.Date and Dispatch.DispatchTimeInterval, cannot be used because their definition was never imported, and that this warning will be a hard error in Swift 6.

Example from Timeout.swift:

'RxTimeInterval' aliases 'Dispatch.DispatchTimeInterval' and cannot be used here because 'Dispatch' was not imported by this file; this is an error in Swift 6

Example in screenshot: image

Expected outcome:

Warnings against using types which have not been imported by the current file should not appear during Xcode archive build.

What actually happens:

Such warnings do appear.

Self contained code example that reproduces the issue:

The easiest way to reproduce is to:

  1. Clone the repo
  2. Open Xcode
  3. Open Rx.xcworkspace
  4. Select the RxSwift scheme
  5. Select an iOS simulator
  6. Choose Product -> Build For -> Profiling -- or hit Command-Shift-I (that's "eye" not "el")

You'll see a bunch of warnings like the ones described above.

RxSwift/RxCocoa/RxBlocking/RxTest version/commit

Confirmed with 6.6.0 tag as well as the current tip of main branch, which is 214f7ffced20dc780bf38f192a26a890c1b9045e.

Platform/Environment

How easy is to reproduce? (chances of successful reproduce after running the self contained code)

Xcode version:

15.0.1

Installation method:

I have multiple versions of Xcode installed: (so we can know if this is a potential cause of your issue)

Level of RxSwift knowledge: (this is so we can understand your level of knowledge and formulate the response in an appropriate manner)

I'm building under macOS Sonoma 14.1.1 on a 2021 M1 Max macbook pro, with Xcode 15.0.1.

These warnings can be resolved by adding "import Foundation" (or similar) to most of the files in question.