Skip to content

Commit c21c6c0

Browse files
committed
fix(ios): compile native capture plugin on Flutter 3.35
Look up registrar.viewController at runtime and fall back to the key window so hosted 0.8.x still builds on Flutter 3.35. Bump tugboat and tugboat_dio to 0.8.16.
1 parent 49ff8a2 commit c21c6c0

14 files changed

Lines changed: 68 additions & 19 deletions

File tree

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ gates, canaries) are not listed below.
5858

5959
## Current compatibility
6060

61-
- package version: `0.8.15` (`0.8.x` patch; Android plugin uses Maven Central
61+
- package version: `0.8.16` (`0.8.x` patch; Android plugin uses Maven Central
6262
`capture-runtime` `0.1.0`; iOS plugin uses CocoaPods `TugboatCaptureRuntime`
6363
`0.1.0` and requires iOS 15);
6464
- native runtime: `capture-runtime` `0.1.0` on Maven Central;

docs/releases/compatibility.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
| Adapter | Adapter version | Native runtime |
44
| --- | --- | --- |
5+
| Flutter `tugboat` | 0.8.16 | Same hosted runtimes as 0.8.15. iOS plugin looks up `registrar.viewController` at runtime so Flutter 3.35 hosts compile. |
56
| Flutter `tugboat` | 0.8.15 | Android `com.gettugboat.sdk:capture-runtime:0.1.0` from Maven Central. Apple `TugboatCaptureRuntime` `0.1.0` from CocoaPods trunk. Plugin iOS floor 15. |
67
| Flutter `tugboat` | 0.8.14 | Android `com.gettugboat.sdk:capture-runtime:0.1.0` from Maven Central. Apple `TugboatCaptureRuntime` 0.1.x compiled from monorepo sources (unpublished CocoaPod is not required). Plugin iOS floor 12; native capture still reports unsupported below iOS 15. |
78
| Flutter `tugboat` | 0.8.13 | Android `capture-runtime` 0.1.x compiled from monorepo sources (hosted Maven is not required). Apple `TugboatCaptureRuntime` 0.1.x compiled from monorepo sources (unpublished CocoaPod is not required). Plugin iOS floor 12; native capture still reports unsupported below iOS 15. |
@@ -10,8 +11,9 @@
1011
| Apple `TugboatCaptureRuntime` | 0.1.0 | CocoaPods trunk / SwiftPM git tag; iOS 15 live Flutter-layer CPU path |
1112
| `@tugboat/react-native` || not started |
1213

13-
Flutter `0.8.15` consumes Android `capture-runtime` `0.1.0` from Maven Central
14-
and Apple `TugboatCaptureRuntime` `0.1.0` from CocoaPods. Native capture stays
14+
Flutter `0.8.16` compiles on Flutter 3.35 and consumes Android
15+
`capture-runtime` `0.1.0` from Maven Central and Apple
16+
`TugboatCaptureRuntime` `0.1.0` from CocoaPods. Native capture stays
1517
opt-in. The first native-default adapter is still planned as Flutter `0.9.0`.
1618

1719
CI requires this table to change whenever Flutter adapter source or the

sdks/flutter/packages/tugboat/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 0.8.16
2+
3+
### Fixed
4+
5+
- The iOS plugin compiles on Flutter 3.35. `registrar.viewController` is a
6+
Flutter 3.38 API, so look it up at runtime and fall back to the key window
7+
when resolving the live Flutter view for opt-in native CPU capture.
8+
19
## 0.8.15
210

311
The iOS plugin depends on CocoaPods `TugboatCaptureRuntime` `0.1.0` and

sdks/flutter/packages/tugboat/README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,18 @@ checkpoints around meaningful interactions, compact structural anchors, route
55
transitions, scrolling evidence, and optional viewport semantic maps. Capture
66
can be sent to the local exploration WebSocket, the HTTP collector, or both.
77

8-
The current package version is `0.8.15`. Session JSON writers and readers use
8+
The current package version is `0.8.16`. Session JSON writers and readers use
99
schema version `10` only. Structural fingerprints use fingerprint schema
1010
version `6`.
1111

12+
## 0.8.16
13+
14+
The iOS plugin compiles on Flutter 3.35. Native CPU capture still loads
15+
CocoaPods `TugboatCaptureRuntime` `0.1.0` and Maven Central
16+
`com.gettugboat.sdk:capture-runtime:0.1.0`. Native capture stays opt-in
17+
(`nativeCpuExperimental`). Keep
18+
`TugboatScreenshotCaptureBackend.flutterRepaintBoundary` in production.
19+
1220
## 0.8.15
1321

1422
iOS native CPU capture loads CocoaPods `TugboatCaptureRuntime` `0.1.0` and
@@ -123,7 +131,7 @@ events.
123131

124132
```yaml
125133
dependencies:
126-
tugboat: ^0.8.15
134+
tugboat: ^0.8.16
127135
```
128136
129137
Then import the public barrel:
@@ -139,8 +147,8 @@ Install from pub.dev; a GitHub checkout is not required.
139147

140148
```yaml
141149
dependencies:
142-
tugboat: ^0.8.15
143-
tugboat_dio: ^0.8.15
150+
tugboat: ^0.8.16
151+
tugboat_dio: ^0.8.16
144152
```
145153
146154
See the [`tugboat_dio`](https://pub.dev/packages/tugboat_dio) package.

sdks/flutter/packages/tugboat/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group = "com.tugboat.flutter"
2-
version = "0.8.15"
2+
version = "0.8.16"
33

44
buildscript {
55
ext.kotlin_version = "2.2.20"

sdks/flutter/packages/tugboat/example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ resolution: workspace
3232
dependencies:
3333
flutter:
3434
sdk: flutter
35-
tugboat: ^0.8.15
35+
tugboat: ^0.8.16
3636

3737
# The following adds the Cupertino Icons font to your application.
3838
# Use with the CupertinoIcons class for iOS style icons.

sdks/flutter/packages/tugboat/ios/Classes/TugboatPlugin.swift

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,36 @@ public class TugboatPlugin: NSObject, FlutterPlugin, NativeCaptureHostApi {
5252
}
5353

5454
private func flutterView() -> UIView? {
55-
guard let controller = registrar?.viewController else {
55+
guard let controller = hostViewController() else {
5656
return nil
5757
}
5858
return findFlutterView(controller.view) ?? controller.view
5959
}
6060

61+
/// Flutter 3.38+ exposes `registrar.viewController`. The package floor is
62+
/// Flutter 3.35, which does not declare that property, so look it up at
63+
/// runtime and fall back to the key window.
64+
private func hostViewController() -> UIViewController? {
65+
if let registrar {
66+
let selector = NSSelectorFromString("viewController")
67+
if registrar.responds(to: selector),
68+
let controller = registrar.perform(selector)?.takeUnretainedValue()
69+
as? UIViewController
70+
{
71+
return controller
72+
}
73+
}
74+
return keyWindowRootViewController()
75+
}
76+
77+
private func keyWindowRootViewController() -> UIViewController? {
78+
let windows = UIApplication.shared.connectedScenes
79+
.compactMap { $0 as? UIWindowScene }
80+
.flatMap(\.windows)
81+
let keyWindow = windows.first(where: \.isKeyWindow) ?? windows.first
82+
return keyWindow?.rootViewController
83+
}
84+
6185
private func findFlutterView(_ view: UIView) -> UIView? {
6286
let name = NSStringFromClass(type(of: view))
6387
if name == "FlutterView" || name.hasSuffix(".FlutterView") {

sdks/flutter/packages/tugboat/ios/tugboat.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
Pod::Spec.new do |s|
66
s.name = 'tugboat'
7-
s.version = '0.8.15'
7+
s.version = '0.8.16'
88
s.summary = 'Screenshot-based session replay with compact interaction anchors for Tugboat.'
99
s.description = <<-DESC
1010
Flutter adapter for Tugboat session replay. Native CPU capture is experimental
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// Keep this in sync with this package's pubspec.yaml. The SDK version test
22
// reads pubspec.yaml directly so release bumps fail fast if this drifts.
3-
const tugboatSdkVersion = '0.8.15';
3+
const tugboatSdkVersion = '0.8.16';

sdks/flutter/packages/tugboat/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: tugboat
22
description: >-
33
Screenshot-based session replay with compact interaction anchors for Tugboat.
4-
version: 0.8.15
4+
version: 0.8.16
55
repository: https://github.com/blendto/tugboat-flutter
66
issue_tracker: https://github.com/blendto/tugboat-flutter/issues
77
homepage: https://github.com/blendto/tugboat-flutter

0 commit comments

Comments
 (0)