Skip to content

Commit

Permalink
Fix perception check in iOS 15. (#38)
Browse files Browse the repository at this point in the history
* Fix perception check in iOS 15.

* fix
  • Loading branch information
mbrandonw authored Mar 14, 2024
1 parent a5bb578 commit db08755
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
6 changes: 2 additions & 4 deletions Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
Expand Down Expand Up @@ -405,7 +405,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
Expand All @@ -430,7 +430,6 @@
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -459,7 +458,6 @@
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
22 changes: 16 additions & 6 deletions Example/Example/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,24 @@ struct ContentView: View {
}
}
.sheet(isPresented: $model.isPresentingSheet) {
WithPerceptionTracking {
Form {
Text(model.count.description)
Button("Decrement") { model.decrementButtonTapped() }
Button("Increment") { model.incrementButtonTapped() }
if #available(iOS 16.0, *) {
WithPerceptionTracking {
Form {
Text(model.count.description)
Button("Decrement") { model.decrementButtonTapped() }
Button("Increment") { model.incrementButtonTapped() }
}
.presentationDetents([.medium])
}
} else {
WithPerceptionTracking {
Form {
Text(model.count.description)
Button("Decrement") { model.decrementButtonTapped() }
Button("Increment") { model.incrementButtonTapped() }
}
}
}
.presentationDetents([.medium])
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/Perception/PerceptionRegistrar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,9 @@ extension PerceptionRegistrar: Hashable {
}
fileprivate var isActionClosure: Bool {
var view = self[...].utf8
guard
view.starts(with: "closure #".utf8) || view.starts(with: "implicit closure #".utf8)
else { return false }
view = view.drop(while: { $0 != .init(ascii: "#") })
view = view.dropFirst()
view = view.drop(while: { $0 >= .init(ascii: "0") && $0 <= .init(ascii: "9") })
view = view.drop(while: { $0 != .init(ascii: "-") })
return view.starts(with: "-> () in ".utf8)
}
Expand Down

0 comments on commit db08755

Please sign in to comment.