diff --git a/GDPerformanceView-Swift.podspec b/GDPerformanceView-Swift.podspec index 2980da5..9548c3a 100755 --- a/GDPerformanceView-Swift.podspec +++ b/GDPerformanceView-Swift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "GDPerformanceView-Swift" - s.version = "2.1.0" + s.version = "2.1.1" s.summary = "Shows FPS, CPU and memory usage, device model, app and iOS versions above the status bar and report FPS, CPU and memory usage via delegate." s.homepage = "https://github.com/dani-gavrilov/GDPerformanceView-Swift" s.license = { :type => "MIT", :file => "LICENSE" } diff --git a/GDPerformanceView-Swift.xcodeproj/project.pbxproj b/GDPerformanceView-Swift.xcodeproj/project.pbxproj index 63a2941..6eca7ab 100755 --- a/GDPerformanceView-Swift.xcodeproj/project.pbxproj +++ b/GDPerformanceView-Swift.xcodeproj/project.pbxproj @@ -21,7 +21,6 @@ 0C340AC321A348C600734F1C /* PerformanceMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C340AB621A348C600734F1C /* PerformanceMonitor.swift */; }; 0C340AC421A348C600734F1C /* PerformanceСalculator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C340AB721A348C600734F1C /* PerformanceСalculator.swift */; }; 0C340AC521A348C600734F1C /* PerformanceСalculator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C340AB721A348C600734F1C /* PerformanceСalculator.swift */; }; - 1B076A082518CB1A0086536C /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB46D87824F86404006F54B3 /* Extensions.swift */; }; 42AD06F31E1D18C400A5C840 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 42AD06E71E1D18C400A5C840 /* AppDelegate.swift */; }; 42AD06F41E1D18C400A5C840 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 42AD06E81E1D18C400A5C840 /* Assets.xcassets */; }; 42AD06F51E1D18C400A5C840 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 42AD06E91E1D18C400A5C840 /* LaunchScreen.storyboard */; }; @@ -29,7 +28,6 @@ 42C2CBE81E244D6300A96A93 /* GDPerformanceView-iOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 42C2CBE61E244D6300A96A93 /* GDPerformanceView-iOS.h */; settings = {ATTRIBUTES = (Public, ); }; }; 42C2CBEB1E244D6300A96A93 /* GDPerformanceView.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 42C2CBE41E244D6300A96A93 /* GDPerformanceView.framework */; }; 42C2CBEC1E244D6300A96A93 /* GDPerformanceView.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 42C2CBE41E244D6300A96A93 /* GDPerformanceView.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - EB46D87A24F864D4006F54B3 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB46D87824F86404006F54B3 /* Extensions.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -73,7 +71,6 @@ 42C2CBE41E244D6300A96A93 /* GDPerformanceView.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = GDPerformanceView.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 42C2CBE61E244D6300A96A93 /* GDPerformanceView-iOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "GDPerformanceView-iOS.h"; sourceTree = ""; }; 42C2CBE71E244D6300A96A93 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - EB46D87824F86404006F54B3 /* Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -136,7 +133,6 @@ 0C340AB121A348C600734F1C /* MarginLabel.swift */, 0C340AB321A348C600734F1C /* Protocols.swift */, 0C340AB421A348C600734F1C /* LinkedFramesList.swift */, - EB46D87824F86404006F54B3 /* Extensions.swift */, ); path = GDPerformanceMonitoring; sourceTree = ""; @@ -269,7 +265,6 @@ buildActionMask = 2147483647; files = ( 0C340ABE21A348C600734F1C /* LinkedFramesList.swift in Sources */, - 1B076A082518CB1A0086536C /* Extensions.swift in Sources */, 42AD06F31E1D18C400A5C840 /* AppDelegate.swift in Sources */, 0C340ABC21A348C600734F1C /* Protocols.swift in Sources */, 0C340AC221A348C600734F1C /* PerformanceMonitor.swift in Sources */, @@ -287,7 +282,6 @@ 0C340AC521A348C600734F1C /* PerformanceСalculator.swift in Sources */, 0C340AC121A348C600734F1C /* WindowViewController.swift in Sources */, 0C340AB921A348C600734F1C /* MarginLabel.swift in Sources */, - EB46D87A24F864D4006F54B3 /* Extensions.swift in Sources */, 0C340ABB21A348C600734F1C /* PerformanceView.swift in Sources */, 0C340ABF21A348C600734F1C /* LinkedFramesList.swift in Sources */, 0C340AC321A348C600734F1C /* PerformanceMonitor.swift in Sources */, @@ -447,7 +441,7 @@ INFOPLIST_FILE = "GDPerformanceView-Swift/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 2.1.0; + MARKETING_VERSION = 2.1.1; PRODUCT_BUNDLE_IDENTIFIER = "GD.GDPerformanceView-Swift"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -463,7 +457,7 @@ INFOPLIST_FILE = "GDPerformanceView-Swift/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 2.1.0; + MARKETING_VERSION = 2.1.1; PRODUCT_BUNDLE_IDENTIFIER = "GD.GDPerformanceView-Swift"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -484,7 +478,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MARKETING_VERSION = 2.1.0; + MARKETING_VERSION = 2.1.1; PRODUCT_BUNDLE_IDENTIFIER = "GD.GDPerformanceView-iOS"; PRODUCT_NAME = GDPerformanceView; SKIP_INSTALL = YES; @@ -509,7 +503,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MARKETING_VERSION = 2.1.0; + MARKETING_VERSION = 2.1.1; PRODUCT_BUNDLE_IDENTIFIER = "GD.GDPerformanceView-iOS"; PRODUCT_NAME = GDPerformanceView; SKIP_INSTALL = YES; diff --git a/GDPerformanceView-Swift/GDPerformanceMonitoring/Extensions.swift b/GDPerformanceView-Swift/GDPerformanceMonitoring/Extensions.swift deleted file mode 100644 index 6bfc789..0000000 --- a/GDPerformanceView-Swift/GDPerformanceMonitoring/Extensions.swift +++ /dev/null @@ -1,42 +0,0 @@ -// -// Copyright © 2020 Pimine -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -import UIKit - -extension UIApplication { - - var keyWindow: UIWindow? { - if #available(iOS 13, *) { - return UIApplication.shared.windows.first { $0.isKeyWindow } - } else { - return UIApplication.shared.keyWindow - } - } - - @available(iOS 13, *) - var keyWindowScene: UIWindowScene? { - UIApplication.shared - .connectedScenes - .filter { $0.activationState == .foregroundActive } - .first as? UIWindowScene - } -} diff --git a/GDPerformanceView-Swift/GDPerformanceMonitoring/PerformanceView.swift b/GDPerformanceView-Swift/GDPerformanceMonitoring/PerformanceView.swift index f2dd9ec..c686b3a 100644 --- a/GDPerformanceView-Swift/GDPerformanceMonitoring/PerformanceView.swift +++ b/GDPerformanceView-Swift/GDPerformanceMonitoring/PerformanceView.swift @@ -78,7 +78,7 @@ internal class PerformanceView: UIWindow, PerformanceViewConfigurator { required internal init() { super.init(frame: PerformanceView.windowFrame(withPrefferedHeight: Constants.prefferedHeight)) if #available(iOS 13, *) { - self.windowScene = UIApplication.shared.keyWindowScene + self.windowScene = PerformanceView.keyWindowScene() } self.configureWindow() @@ -329,7 +329,7 @@ private extension PerformanceView { } func canBeVisible() -> Bool { - if let window = UIApplication.shared.keyWindow, window.isKeyWindow, !window.isHidden { + if let window = PerformanceView.keyWindow(), window.isKeyWindow, !window.isHidden { return true } return false @@ -340,7 +340,7 @@ private extension PerformanceView { private extension PerformanceView { class func windowFrame(withPrefferedHeight height: CGFloat) -> CGRect { - guard let window = UIApplication.shared.keyWindow else { + guard let window = PerformanceView.keyWindow() else { return .zero } @@ -358,4 +358,19 @@ private extension PerformanceView { } return CGRect(x: 0.0, y: topInset, width: window.bounds.width, height: height) } + + class func keyWindow() -> UIWindow? { + if #available(iOS 13, *) { + return UIApplication.shared.windows.first(where: { $0.isKeyWindow }) + } else { + return UIApplication.shared.keyWindow + } + } + + @available(iOS 13, *) + class func keyWindowScene() -> UIWindowScene? { + return UIApplication.shared.connectedScenes + .filter { $0.activationState == .foregroundActive } + .first as? UIWindowScene + } } diff --git a/README.md b/README.md index e58528a..ca72015 100755 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Shows FPS, CPU and memory usage, device model, app and iOS versions above the status bar and report FPS, CPU and memory usage via delegate. [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-brightgreen.svg)](https://github.com/Carthage/Carthage) -[![Pod Version](https://img.shields.io/badge/Pod-2.1.0-6193DF.svg)](https://cocoapods.org/) +[![Pod Version](https://img.shields.io/badge/Pod-2.1.1-6193DF.svg)](https://cocoapods.org/) ![Swift Version](https://img.shields.io/badge/xCode-12.0+-blue.svg) ![Swift Version](https://img.shields.io/badge/iOS-9.0+-blue.svg) ![Swift Version](https://img.shields.io/badge/Swift-5.0+-orange.svg) @@ -21,7 +21,7 @@ Simply add GDPerformanceMonitoring folder with files to your project, or use Coc Create a `Cartfile` that lists the framework and run `carthage update`. Follow the [instructions](https://github.com/Carthage/Carthage#if-youre-building-for-ios) to add `$(SRCROOT)/Carthage/Build/iOS/GDPerformanceView.framework` to an iOS project. ```ruby -github "dani-gavrilov/GDPerformanceView-Swift" ~> 2.1.0 +github "dani-gavrilov/GDPerformanceView-Swift" ~> 2.1.1 ``` Don't forget to import GDPerformanceView by adding: @@ -37,7 +37,7 @@ platform :ios, '8.0' use_frameworks! target 'project_name' do - pod 'GDPerformanceView-Swift', '~> 2.1.0' + pod 'GDPerformanceView-Swift', '~> 2.1.1' end ``` Don't forget to import GDPerformanceView by adding: