Skip to content

Commit 812f9b9

Browse files
authored
Fix disableKeyboardAvoidance for iOS 26 (#178)
* Fix disableKeyboardAvoidance for iOS 26 * Fix tvOS check * Newer Xcode versions Update simulator Try 15.4 * Only test on Xcode 16.2 for now
1 parent 1f9b206 commit 812f9b9

File tree

3 files changed

+18
-17
lines changed

3 files changed

+18
-17
lines changed

.github/workflows/main.yml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ on:
88

99
jobs:
1010
build-package:
11-
runs-on: macos-latest
11+
runs-on: macos-15
1212
strategy:
1313
matrix:
1414
xcode:
15-
- '14.3.1' # Swift 5.8 (lowest)
16-
- '15.4' # Swift 5.10 (highest)
15+
- '16.2' # Swift 6.0.3 (highest)
1716
steps:
1817
- uses: actions/checkout@v2
1918
- uses: ./.github/actions/setup
@@ -23,11 +22,11 @@ jobs:
2322
run: bundle exec rake build:package
2423

2524
build-epoxy-core:
26-
runs-on: macos-latest
25+
runs-on: macos-15
2726
strategy:
2827
matrix:
2928
xcode:
30-
- '15.4' # Swift 5.10 (highest)
29+
- '16.2' # Swift 6.0.3 (highest)
3130
steps:
3231
- uses: actions/checkout@v2
3332
- uses: ./.github/actions/setup
@@ -37,12 +36,11 @@ jobs:
3736
run: bundle exec rake build:EpoxyCore
3837

3938
build-example:
40-
runs-on: macos-latest
39+
runs-on: macos-15
4140
strategy:
4241
matrix:
4342
xcode:
44-
- '14.3.1' # Swift 5.8 (lowest)
45-
- '15.4' # Swift 5.10 (highest)
43+
- '16.2' # Swift 6.0.3 (highest)
4644
steps:
4745
- uses: actions/checkout@v2
4846
- uses: ./.github/actions/setup
@@ -52,12 +50,11 @@ jobs:
5250
run: bundle exec rake build:example
5351

5452
test-package:
55-
runs-on: macos-latest
53+
runs-on: macos-15
5654
strategy:
5755
matrix:
5856
xcode:
59-
- '14.3.1' # Swift 5.8 (lowest)
60-
- '15.4' # Swift 5.10 (highest)
57+
- '16.2' # Swift 6.0.3 (highest)
6158
steps:
6259
- uses: actions/checkout@v2
6360
- uses: ./.github/actions/setup
@@ -67,7 +64,7 @@ jobs:
6764
run: bundle exec rake test:package
6865

6966
lint-swift:
70-
runs-on: macos-latest
67+
runs-on: macos-15
7168
steps:
7269
- uses: actions/checkout@v2
7370
- uses: ./.github/actions/setup

Rakefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace :build do
1313

1414
desc 'Builds the EpoxyExample app'
1515
task :example do
16-
xcodebuild 'build -scheme EpoxyExample -destination "platform=iOS Simulator,name=iPhone 14"'
16+
xcodebuild 'build -scheme EpoxyExample -destination "platform=iOS Simulator,name=iPhone 16"'
1717
end
1818
end
1919

@@ -23,12 +23,12 @@ namespace :test do
2323

2424
desc 'Runs unit tests'
2525
task :unit do
26-
xcodebuild 'test -scheme EpoxyTests -destination "platform=iOS Simulator,name=iPhone 14"'
26+
xcodebuild 'test -scheme EpoxyTests -destination "platform=iOS Simulator,name=iPhone 16"'
2727
end
2828

2929
desc 'Runs performance tests'
3030
task :performance do
31-
xcodebuild 'test -scheme PerformanceTests -destination "platform=iOS Simulator,name=iPhone 14"'
31+
xcodebuild 'test -scheme PerformanceTests -destination "platform=iOS Simulator,name=iPhone 16"'
3232
end
3333
end
3434

Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingController.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,14 @@ open class EpoxySwiftUIHostingController<Content: View>: UIHostingController<Con
5050

5151
/// Creates a dynamic subclass of this hosting controller's view that disables its keyboard
5252
/// avoidance behavior.
53-
/// Setting `safeAreaRegions` to `.container` also works but cannot be used since it's
54-
/// supported on 16.4+ and we need to support older versions.
53+
/// Setting `safeAreaRegions` to `.container` is preferred on iOS 16.4+, as this approach breaks on iOS 26.
5554
/// See [here](https://steipete.com/posts/disabling-keyboard-avoidance-in-swiftui-uihostingcontroller/) for more info.
5655
private func disableKeyboardAvoidance() {
56+
if #available(iOS 16.4, tvOS 16.4, *) {
57+
self.safeAreaRegions = .container
58+
return
59+
}
60+
5761
guard let viewClass = object_getClass(view) else {
5862
EpoxyLogger.shared.assertionFailure("Unable to determine class of \(String(describing: view))")
5963
return

0 commit comments

Comments
 (0)