Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Classes/FLEX.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#import "FLEXExplorerToolbar.h"
#import "FLEXExplorerToolbarItem.h"
#import "FLEXFileBrowserController.h"
#import "FLEXGlobalsEntry.h"

#import "FLEX-Core.h"
Expand Down
3 changes: 3 additions & 0 deletions Classes/Utility/FLEXMacros.h
Copy link
Collaborator

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()

Copy link
Author

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.

Copy link
Collaborator

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

Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ extern BOOL FLEXConstructorsShouldRun(void);
/// A macro to return from the current procedure if we don't want to run constructors
#define FLEX_EXIT_IF_NO_CTORS() if (!FLEXConstructorsShouldRun()) return;

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
/// Rounds down to the nearest "point" coordinate
NS_INLINE CGFloat FLEXFloor(CGFloat x) {
return floor(UIScreen.mainScreen.scale * (x)) / UIScreen.mainScreen.scale;
Expand All @@ -49,6 +51,7 @@ NS_INLINE CGFloat FLEXFloor(CGFloat x) {
NS_INLINE CGFloat FLEXPointsToPixels(CGFloat points) {
return points / UIScreen.mainScreen.scale;
}
#pragma clang diagnostic pop

/// Creates a CGRect with all members rounded down to the nearest "point" coordinate
NS_INLINE CGRect FLEXRectMake(CGFloat x, CGFloat y, CGFloat width, CGFloat height) {
Expand Down
4 changes: 2 additions & 2 deletions FLEX.xcodeproj/project.pbxproj
Copy link
Collaborator

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

Copy link
Author

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'

Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
3A4C95101B5B21410088C3F2 /* FLEXMethodCallingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A4C948B1B5B21410088C3F2 /* FLEXMethodCallingViewController.m */; };
3A4C95221B5B21410088C3F2 /* FLEXFileBrowserSearchOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 3A4C949F1B5B21410088C3F2 /* FLEXFileBrowserSearchOperation.h */; settings = {ATTRIBUTES = (Private, ); }; };
3A4C95231B5B21410088C3F2 /* FLEXFileBrowserSearchOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A4C94A01B5B21410088C3F2 /* FLEXFileBrowserSearchOperation.m */; };
3A4C95241B5B21410088C3F2 /* FLEXFileBrowserController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3A4C94A11B5B21410088C3F2 /* FLEXFileBrowserController.h */; settings = {ATTRIBUTES = (Private, ); }; };
3A4C95251B5B21410088C3F2 /* FLEXFileBrowserController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A4C94A21B5B21410088C3F2 /* FLEXFileBrowserController.m */; };
3A4C95261B5B21410088C3F2 /* FLEXGlobalsViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3A4C94A31B5B21410088C3F2 /* FLEXGlobalsViewController.h */; };
3A4C95271B5B21410088C3F2 /* FLEXGlobalsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A4C94A41B5B21410088C3F2 /* FLEXGlobalsViewController.m */; };
Expand Down Expand Up @@ -112,6 +111,7 @@
71E1C2192307FBB800F5032A /* FLEXKeychainQuery.m in Sources */ = {isa = PBXBuildFile; fileRef = 71E1C2112307FBB700F5032A /* FLEXKeychainQuery.m */; };
7349FD6A22B93CDF00051810 /* FLEXColor.h in Headers */ = {isa = PBXBuildFile; fileRef = 7349FD6822B93CDF00051810 /* FLEXColor.h */; };
7349FD6B22B93CDF00051810 /* FLEXColor.m in Sources */ = {isa = PBXBuildFile; fileRef = 7349FD6922B93CDF00051810 /* FLEXColor.m */; };
73902C712EB5691200B386D3 /* FLEXFileBrowserController.h in Headers */ = {isa = PBXBuildFile; fileRef = 3A4C94A11B5B21410088C3F2 /* FLEXFileBrowserController.h */; settings = {ATTRIBUTES = (Public, ); }; };
779B1ECE1C0C4D7C001F5E49 /* FLEXDatabaseManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 779B1EC01C0C4D7C001F5E49 /* FLEXDatabaseManager.h */; };
779B1ED01C0C4D7C001F5E49 /* FLEXMultiColumnTableView.h in Headers */ = {isa = PBXBuildFile; fileRef = 779B1EC21C0C4D7C001F5E49 /* FLEXMultiColumnTableView.h */; };
779B1ED11C0C4D7C001F5E49 /* FLEXMultiColumnTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 779B1EC31C0C4D7C001F5E49 /* FLEXMultiColumnTableView.m */; };
Expand Down Expand Up @@ -1527,6 +1527,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
73902C712EB5691200B386D3 /* FLEXFileBrowserController.h in Headers */,
779B1EDA1C0C4D7C001F5E49 /* FLEXTableListViewController.h in Headers */,
C3531BA523E88A2100A184AD /* FLEXNavigationController.h in Headers */,
3A4C94ED1B5B21410088C3F2 /* FLEXArgumentInputColorView.h in Headers */,
Expand Down Expand Up @@ -1692,7 +1693,6 @@
3A4C95401B5B21410088C3F2 /* FLEXNetworkTransactionCell.h in Headers */,
C30D2960261FAE9E00D89649 /* FLEXNSStringShortcuts.h in Headers */,
C398626523AD70F5007E6793 /* FLEXKBToolbarButton.h in Headers */,
3A4C95241B5B21410088C3F2 /* FLEXFileBrowserController.h in Headers */,
C31D93E423E38CBE005517BF /* FLEXBlockShortcuts.h in Headers */,
94AAF0381BAF2E1F00DE8760 /* FLEXKeyboardHelpViewController.h in Headers */,
71E1C2152307FBB800F5032A /* FLEXKeychainQuery.h in Headers */,
Expand Down