Przeglądaj źródła

remove another obstacle to building on tvOS without patching the SDK

Kevin Bradley 5 lat temu
rodzic
commit
60938413c9

+ 3 - 2
Classes/GlobalStateExplorers/FileBrowser/FLEXFileBrowserController.m

@@ -462,11 +462,12 @@ typedef NS_ENUM(NSUInteger, FLEXFileBrowserSortAttribute) {
 }
 
 - (void)fileBrowserCopyPath:(UITableViewCell *)sender {
+#if !TARGET_OS_TV
     NSIndexPath *indexPath = [self.tableView indexPathForCell:sender];
     NSString *fullPath = [self filePathAtIndexPath:indexPath];
-    #if !TARGET_OS_TV
+    
     UIPasteboard.generalPasteboard.string = fullPath;
-    #endif
+#endif
 }
 
 - (void)fileBrowserShare:(UITableViewCell *)sender {

+ 18 - 17
Classes/Utility/FLEXColor.m

@@ -12,14 +12,12 @@
 
 /**
  
- A note about tvOS Support: i tried to briefly undefine the API_UNAVAILABLE macro in an attempt to avoid the need to patch the SDK to get this working, this properties are actually available
- on tvOS and if we don't use them the UI gets comlpetely out of whack.
+ tvOS notes: alot of these properties are marked as unavailable on tvOS, not only is that a bald faced lie, but without using these values the UI gets completely screwy!
+ i initially tried to do some creative macro undef/redef but that didnt work, so going to use good ole KVC, valueForKey: works on class methods as well! and this will work
+ perfectly without needing to patch another SDK file for this to build for tvOS
  
  */
 
-#undef API_UNAVAILABLE
-#define API_UNAVAILABLE(...) API_AVAILABLE(...)
-
 #if FLEX_AT_LEAST_IOS13_SDK
 #define FLEXDynamicColor(dynamic, static) ({ \
     UIColor *c; \
@@ -39,7 +37,7 @@
 #pragma mark - Background Colors
 
 + (UIColor *)primaryBackgroundColor {
-    return FLEXDynamicColor(systemBackgroundColor, whiteColor);
+    return FLEXDynamicColor(valueForKey:@"systemBackgroundColor", whiteColor);
 }
 
 + (UIColor *)primaryBackgroundColorWithAlpha:(CGFloat)alpha {
@@ -48,7 +46,7 @@
 
 + (UIColor *)secondaryBackgroundColor {
     return FLEXDynamicColor(
-        secondarySystemBackgroundColor,
+        valueForKey:@"secondarySystemBackgroundColor",
         colorWithHue:2.0/3.0 saturation:0.02 brightness:0.97 alpha:1
     );
 }
@@ -61,7 +59,7 @@
     // All the background/fill colors are varying shades
     // of white and black with really low alpha levels.
     // We use systemGray4Color instead to avoid alpha issues.
-    return FLEXDynamicColor(systemGray4Color, lightGrayColor);
+    return FLEXDynamicColor(valueForKey:@"systemGray4Color", lightGrayColor);
 }
 
 + (UIColor *)tertiaryBackgroundColorWithAlpha:(CGFloat)alpha {
@@ -70,7 +68,7 @@
 
 + (UIColor *)groupedBackgroundColor {
     return FLEXDynamicColor(
-        systemGroupedBackgroundColor,
+        valueForKey:@"systemGroupedBackgroundColor",
         colorWithHue:2.0/3.0 saturation:0.02 brightness:0.97 alpha:1
     );
 }
@@ -80,7 +78,7 @@
 }
 
 + (UIColor *)secondaryGroupedBackgroundColor {
-    return FLEXDynamicColor(secondarySystemGroupedBackgroundColor, whiteColor);
+    return FLEXDynamicColor(valueForKey:@"secondarySystemGroupedBackgroundColor", whiteColor);
 }
 
 + (UIColor *)secondaryGroupedBackgroundColorWithAlpha:(CGFloat)alpha {
@@ -94,7 +92,7 @@
 }
 
 + (UIColor *)deemphasizedTextColor {
-    return FLEXDynamicColor(secondaryLabelColor, lightGrayColor);
+    return FLEXDynamicColor(valueForKey:@"secondaryLabelColor", lightGrayColor);
 }
 
 #pragma mark - UI Element Colors
@@ -102,9 +100,12 @@
 + (UIColor *)tintColor {
     #if FLEX_AT_LEAST_IOS13_SDK
     if (@available(iOS 13.0, *)) {
-        return UIColor.systemBlueColor;
+        return [UIColor valueForKey:@"systemBlueColor"];
     } else {
+        #pragma clang diagnostic push
+        #pragma clang diagnostic ignored "-Wdeprecated-declarations"
         return UIApplication.sharedApplication.keyWindow.tintColor;
+        #pragma clang diagnostic pop
     }
     #else
     return UIApplication.sharedApplication.keyWindow.tintColor;
@@ -113,7 +114,7 @@
 
 + (UIColor *)scrollViewBackgroundColor {
     return FLEXDynamicColor(
-        systemGroupedBackgroundColor,
+        valueForKey:@"systemGroupedBackgroundColor",
         colorWithHue:2.0/3.0 saturation:0.02 brightness:0.95 alpha:1
     );
 }
@@ -128,24 +129,24 @@
 
 + (UIColor *)toolbarItemHighlightedColor {
     return FLEXDynamicColor(
-        quaternaryLabelColor,
+        valueForKey:@"quaternaryLabelColor",
         colorWithHue:2.0/3.0 saturation:0.1 brightness:0.25 alpha:0.6
     );
 }
 
 + (UIColor *)toolbarItemSelectedColor {
     return FLEXDynamicColor(
-        secondaryLabelColor,
+        valueForKey:@"secondaryLabelColor",
         colorWithHue:2.0/3.0 saturation:0.1 brightness:0.25 alpha:0.68
     );
 }
 
 + (UIColor *)hairlineColor {
-    return FLEXDynamicColor(systemGray3Color, colorWithWhite:0.75 alpha:1);
+    return FLEXDynamicColor(valueForKey:@"systemGray3Color", colorWithWhite:0.75 alpha:1);
 }
 
 + (UIColor *)destructiveColor {
-    return FLEXDynamicColor(systemRedColor, redColor);
+    return FLEXDynamicColor(valueForKey:@"systemRedColor", redColor);
 }
 
 @end

+ 2 - 0
FLEX.xcodeproj/project.pbxproj

@@ -388,6 +388,7 @@
 		325D7AE225953F8E00CC6B10 /* KBSelectableTextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KBSelectableTextView.h; sourceTree = "<group>"; };
 		325D7AE525955C3500CC6B10 /* FLEXFontListTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLEXFontListTableViewController.m; sourceTree = "<group>"; };
 		325D7AE625955C3500CC6B10 /* FLEXFontListTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLEXFontListTableViewController.h; sourceTree = "<group>"; };
+		325D7B0E25973F2E00CC6B10 /* postScript.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = postScript.sh; sourceTree = SOURCE_ROOT; };
 		32D4E15A259273E60027F238 /* fakes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = fakes.h; sourceTree = "<group>"; };
 		32D4E15C2592749D0027F238 /* fakes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = fakes.m; sourceTree = "<group>"; };
 		3A4C941F1B5B20570088C3F2 /* FLEX.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = FLEX.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -763,6 +764,7 @@
 		325D7AE025953F8D00CC6B10 /* tvOS */ = {
 			isa = PBXGroup;
 			children = (
+				325D7B0E25973F2E00CC6B10 /* postScript.sh */,
 				32D4E15A259273E60027F238 /* fakes.h */,
 				32D4E15C2592749D0027F238 /* fakes.m */,
 				325D7AE625955C3500CC6B10 /* FLEXFontListTableViewController.h */,

+ 2 - 7
README.md

@@ -5,12 +5,12 @@
 ### General notes / usage
 - If you don't want to build this yourself i keep the latest version synced in layout/Library/Frameworks
 - Best used with a jailbreak / FLEXInjected (avail from default repos now with 'com.nito.flexinjected')
-- Need to modify the SDK to build right now (will fix this later) - read patch notes after the bullets
+- You MIGHT Need to modify the SDK to build right now, working towards removing this necessity, getting closer!
 - After toggling via FLEXInjected it will take 10 seconds after launch for the toolbar to appear, if closed - triple tap play/pause to bring it back
 - When in select mode press the menu button will get you back to the tool bar
 - When in select mode play/pause will also work to click items and is more reliable than selection with the remote touch pad, tapping rather than clicking the touchpad is also more reliable.
 - Press and hold select to drill down to details in views hierarchy list view controller
-- When in selection mode double tap on play/pause will bring up an alert with useful options (show views, details and move view are available there)
+- When in selection mode double tap on play/pause OR press and hold select or play/pause to bring up an alert with useful options (view details, move view and show views are available there)
 
 ### Missing features - on support road map
 - anything with a slider variable will not work properly yet
@@ -22,16 +22,11 @@ There is an excessive amount of stubbing / macroing to get this building, at a c
 There may be additional classes this needs to be done with, these notes are imprecise but should give you an idea.
 
 ```
-## this line is 100% necessary
-sed -i -- "s|API_UNAVAILABLE(tvos, watchos)|API_UNAVAILABLE(watchos)|"  /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIInterface.h
-
 ## these lines might not be necessary, try avoiding them at first to see what happens
 
 sed -i -- "s|#define __TVOS_UNAVAILABLE                    __OS_AVAILABILITY(tvos,unavailable)|#define __TVOS_UNAVAILABLE_NOTQUITE                    __OS_AVAILABILITY(tvos,unavailable)|" /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/usr/include/Availability.h
 
 sed -i -- "s|#define __TVOS_PROHIBITED                     __OS_AVAILABILITY(tvos,unavailable)|#define __TVOS_PROHIBITED_NOTQUITE                     __OS_AVAILABILITY(tvos,unavailable)|" /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS.sdk/usr/include/Availability.h
-
-
 ```
 
 ![tvOS Demo](view_selection.gif "tvOS Selection")

BIN
layout/Library/Frameworks/FLEX.framework/FLEX