Skip to content

Commit

Permalink
fix iOS 12 crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniil Gavrilov committed Sep 22, 2020
1 parent f59e1dd commit 171a656
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 59 deletions.
2 changes: 1 addition & 1 deletion GDPerformanceView-Swift.podspec
Original file line number Diff line number Diff line change
@@ -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" }
Expand Down
14 changes: 4 additions & 10 deletions GDPerformanceView-Swift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@
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 */; };
42AD06F61E1D18C400A5C840 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 42AD06EB1E1D18C400A5C840 /* Main.storyboard */; };
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 */
Expand Down Expand Up @@ -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 = "<group>"; };
42C2CBE71E244D6300A96A93 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
EB46D87824F86404006F54B3 /* Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -136,7 +133,6 @@
0C340AB121A348C600734F1C /* MarginLabel.swift */,
0C340AB321A348C600734F1C /* Protocols.swift */,
0C340AB421A348C600734F1C /* LinkedFramesList.swift */,
EB46D87824F86404006F54B3 /* Extensions.swift */,
);
path = GDPerformanceMonitoring;
sourceTree = "<group>";
Expand Down Expand Up @@ -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 */,
Expand All @@ -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 */,
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
42 changes: 0 additions & 42 deletions GDPerformanceView-Swift/GDPerformanceMonitoring/Extensions.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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
}

Expand All @@ -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
}
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:

Expand All @@ -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:
Expand Down

0 comments on commit 171a656

Please sign in to comment.