-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Silence build warnings when used in Xcode 26 via SwiftPM #725
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we instead update this code to conditionally use UIScreen.screen when available? i.e.
NS_INLINE CGFloat FLEXGetScale() {
if (@available(iOS 13.0, *) {
return UIScreen.screen.scale;
} else {
return UIScreen.mainScreen.scale;
}
}
// And use FLEXGetScale() instead in FLEXFloor()There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maddeningly, wrapping in an @available check isn't sufficient to silence the deprecation warnings triggered via the SwiftPM import.
Something like this would work though, which at least keeps the diagnostic override contained to one spot:
NS_INLINE CGFloat FLEXGetScale(void) {
if (@available(iOS 13.0, *)) {
return UITraitCollection.currentTraitCollection.displayScale;
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
return UIScreen.mainScreen.scale;
#pragma clang diagnostic pop
}
}I'm not sure if using UITraitCollection.currentTraitCollection will work consistently for all uses of FLEXFloor etc. An alternative would be to pull it from the UIApplication singleton's connectedScenes, but that will be more cumbersome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maddeningly, wrapping in an @available check isn't sufficient to silence the deprecation warnings triggered via the SwiftPM import.
I don't want this to be true, but it would not surprise me. Lemme play around with this in an example project and see if I can reproduce it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These files don't control header visibility in SPM, as far as I know. Did this somehow silence the warnings for you? Wouldn't Package.swift need to change instead? (And the associated script that generates code for the Package.swift, generate-spm-headers.sh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key change needed to support SwiftPM was ensuring this header was imported by FLEX.h, since it's a public header. Adding to FLEX.h fixes the error FLEX.h:26:1: umbrella header for module 'FLEX' does not include header 'FLEXFileBrowserController.h'
However, once I added the header to FLEX.h, the normal Xcode project build (not SwiftPM) failed, because FLEXFileBrowserController.h wasn't marked public in the project, despite being imported in FLEX.h:
Include of non-modular header inside framework module 'FLEX': '/Users/apretzlav/FLEX/Classes/GlobalStateExplorers/FileBrowser/FLEXFileBrowserController.h'
Xcode 26 has started treating warnings in SPM headers as project-level warnings for users of the package. This causes issues for any project that has warnings as errors enabled and imports FLEX.
See similar discussions at
facebook/facebook-ios-sdk#2602 and RevenueCat/purchases-ios#5290
Fix two issues with FLEX that hit this change:
UIScreen.mainScreenin FLEXMacros.h inclang diagnostic ignored "-Wdeprecated-declarations"FLEXFileBrowserController.htoFLEX.hand mark as public in the Xcode project config. SinceFLEXFileBrowserController.his part of the SwiftPM public headers after being added in Make FLEXFileBrowserController public #702 , it must be declared in the umbrella header to avoidFLEX/Classes/Headers/FLEX.h:26:1 umbrella header for module 'FLEX' does not include header 'FLEXFileBrowserController.h'. Once added to the umbrella header, the Xcode project would not build because the header was not marked public in the project file.