Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions packages/firebase_performance_tvos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Dart / Flutter
.dart_tool/
build/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub/

# CocoaPods
tvos/Pods/
tvos/Podfile.lock
tvos/.symlinks/
tvos/Flutter/Flutter.framework
tvos/Flutter/Flutter.podspec

# Xcode / SwiftPM (per-user, generated when tvos/Package.swift is opened)
**/.swiftpm/
**/xcuserdata/

# IDE
.idea/
.vscode/
*.iml

# macOS
.DS_Store
1 change: 1 addition & 0 deletions packages/firebase_performance_tvos/.pubignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pubspec_overrides.yaml
9 changes: 9 additions & 0 deletions packages/firebase_performance_tvos/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## 0.0.1

* Initial tvOS (Apple TV) implementation of `firebase_performance`, ported from
`firebase_performance` 0.11.4+3 via `flutter-tvos plugin port` and finished by
hand (podspec `Firebase/Performance` + `firebase_core_tvos` deps, tvOS 15.0
floor, `firebase_core_tvos` import, generated `Package.swift` removed, Dart
re-export).
* No tvOS feature disables — full Performance API (custom traces, HTTP metrics).
Compiles + links + registers on the tvOS simulator and device (arm64).
27 changes: 27 additions & 0 deletions packages/firebase_performance_tvos/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2018 The Chromium Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
83 changes: 83 additions & 0 deletions packages/firebase_performance_tvos/PORTING_REPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# firebase_performance_tvos — porting report

Generated by `flutter-tvos plugin port` on 2026-08-13.

Source: `firebase_performance` 0.11.4+3 (Swift). Base platform: ios.
Output: `./firebase_performance_tvos`

> ✅ No tvOS-incompatible APIs detected at type level — the generated package is expected to compile on tvOS (still review stubbed/partial items below).

## Summary

| Status | Count |
| ------------------------------- | ---------------------- |
| Methods ported as-is | 0 |
| Methods stubbed (iOS-only) | 0 |
| Native regions disabled on tvOS | 0 |
| tvOS build outlook | ✅ expected to compile |
| Manual review items | 0 |

## Methods

No `case "<method>":` handlers were detected in the source. Either the plugin dispatches method calls in a non-standard way (review `tvos/Classes/` by hand) or it has no method channel.

## Imports removed

None. Every `import` in the source compiles on tvOS.

## Cross-platform Dart pruned

None. The source ships no Dart files for non-Apple platforms — nothing had to be removed.

## Disabled on tvOS

None. No type-level tvOS-incompatible API was found; nothing had to be compiled out.

## Manual review items

None flagged automatically. You should still skim `tvos/Classes/` — regex-based porting is best-effort and cannot catch every obfuscated API use.

## Checklist

- [x] Stubbed methods — **N/A**: none (Performance has no tvOS-incompatible APIs).
- [x] Partial methods — **N/A**: none. Full API on tvOS.
- [x] Removed imports — **N/A**: none removed.
- [x] `flutter-tvos build tvos` compiles the generated registrant — **verified** (simulator, arm64).
- [x] Version set (`0.0.1`) and `CHANGELOG.md` updated.

---

Manual review complete (2026-08-13) — see the addendum below for the applied fixes and verification.

## Addendum: manual fixes + verification (2026-08-13)

The auto-port compiled clean (no tvOS-incompatible APIs; Performance is UI-free —
no UIKit/MetricKit; 0 stubs, 0 disables). Applied by hand:

- **Podspec:** depend on `Firebase/Performance '~> 12.15.0'` + `firebase_core_tvos`
(not upstream `firebase_core`); tvOS 15.0 floor; `static_framework`; no
Flutter-CocoaPod dependency (Flutter via `FRAMEWORK_SEARCH_PATHS`).
- **`FirebasePerformancePlugin.swift`:** `#if canImport(firebase_core) … #else
firebase_core_shared` repointed to a plain `import firebase_core_tvos`.
- **Deleted the generated `tvos/Package.swift`** (route via the podspec, like the
other Swift Firebase `_tvos` packages; the SPM manifest lacks the Firebase +
`firebase_core_tvos` deps).
- **`lib/firebase_performance_tvos.dart`:** one-line re-export of
`package:firebase_performance/firebase_performance.dart` (method-channel-only
Dart API — duplicating would create incompatible types). Copied Dart (`src/`)
removed.

**Version alignment:** matches `firebase_performance 0.11.4+3` on the
`firebase_core_platform_interface` **7.1.0** train (`firebase_core 4.11.x`) — the
same train as `firebase_core_tvos`. Keep the whole Firebase stack on one
consistent FlutterFire release.

**Verified (runtime):** on the tvOS simulator against a live Firebase project —
`[FirebasePerformance] 12.15.0 - Firebase Performance Monitoring is successfully
initialized!`, and a custom trace (`tvos_smoke_trace`) + an HTTP metric were
**captured and sent** (`Logging trace metric …` / `Logging network request
trace …`; uploaded via Firelog `firebaselogging-pa.googleapis.com`). Traces were
then **confirmed in the Firebase Performance dashboard** (Custom traces tab) from
**both** a tvOS **simulator** (`tvos_smoke_trace`, 206 ms) and a **physical Apple
TV 4K (release/AOT)** (`tvos_device_trace`, 207 ms).
`Platform.operatingSystem == "tvos"` / `Platform.isIOS == true`.
41 changes: 41 additions & 0 deletions packages/firebase_performance_tvos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# firebase_performance_tvos

The tvOS implementation of [`firebase_performance`](https://pub.dev/packages/firebase_performance).

> Ported with [`flutter-tvos plugin port`](https://github.com/fluttertv/flutter-tvos)
> from `firebase_performance` 0.11.4+3, then finished + verified by hand. See
> `PORTING_REPORT.md`.

## Usage

Federated plugin implementation — no imports needed from app code; it registers
automatically. Apps that already use `firebase_performance` and target tvOS add:

```yaml
dependencies:
firebase_performance: ^0.11.4+3
firebase_performance_tvos: ^0.0.1
firebase_core: ^4.11.0
firebase_core_tvos: ^0.0.1 # tvOS core (this package depends on it)
```

> **Version alignment matters.** This package's native code matches the
> `firebase_core_platform_interface` **7.1.0** train (`firebase_core 4.11.x`).
> Keep your whole Firebase stack on one consistent FlutterFire release, or Dart
> `initializeApp(options:)` can crash in `CoreFirebaseOptions.fromList` at launch
> (a `FirebaseOptions` field-count mismatch).

## Status

| Platform | Implemented | Verified |
| --------------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| Apple TV (`appletvos`) | yes | ✅ **verified on a physical Apple TV 4K (release/AOT)** — a custom trace was confirmed in the Performance dashboard (`tvos_device_trace`, 207 ms) |
| Apple TV simulator (`appletvsimulator`) | yes | ✅ verified — trace + HTTP metric confirmed in the Performance dashboard (`tvos_smoke_trace`, 206 ms) |

All `firebase_performance` APIs are available (no tvOS feature disables) —
custom traces + HTTP metrics. (Performance dashboard data is batched and can take
up to ~12h to appear; the console log confirms capture immediately.)

## License

fluttertv under a BSD-3-Clause license. See `LICENSE` for the full text.
7 changes: 7 additions & 0 deletions packages/firebase_performance_tvos/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include: package:flutter_lints/flutter.yaml

analyzer:
language:
strict-casts: true
strict-inference: true
strict-raw-types: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// PLACEHOLDER — replace by running `flutterfire configure` in this example dir.
//
// On tvOS, `defaultTargetPlatform == TargetPlatform.iOS`, so the `ios` entry
// below is what the Apple TV build uses — i.e. your existing iOS Firebase app's
// config is reused for tvOS.
//
// ignore_for_file: lines_longer_than_80_chars
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
import 'package:flutter/foundation.dart'
show defaultTargetPlatform, kIsWeb, TargetPlatform;

class DefaultFirebaseOptions {
static FirebaseOptions get currentPlatform {
if (kIsWeb) {
throw UnsupportedError('This example targets Apple TV (tvOS) only.');
}
switch (defaultTargetPlatform) {
case TargetPlatform.iOS: // tvOS reports iOS
return ios;
default:
throw UnsupportedError('This example targets Apple TV (tvOS) only.');
}
}

// Replace with your real values — run `flutterfire configure`, or copy them
// from your iOS app's GoogleService-Info.plist / Firebase console.
static const FirebaseOptions ios = FirebaseOptions(
apiKey: 'REPLACE_ME',
appId: 'REPLACE_ME', // GOOGLE_APP_ID
messagingSenderId: 'REPLACE_ME', // GCM_SENDER_ID
projectId: 'REPLACE_ME',
storageBucket: 'REPLACE_ME',
iosBundleId: 'com.example.firebasePerformanceExample',
);
}
114 changes: 114 additions & 0 deletions packages/firebase_performance_tvos/example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_performance/firebase_performance.dart';
import 'package:flutter/material.dart';

import 'firebase_options.dart';

Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
runApp(const PerformanceExampleApp());
}

class PerformanceExampleApp extends StatelessWidget {
const PerformanceExampleApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'firebase_performance tvOS example',
theme: ThemeData.dark(useMaterial3: true),
home: const PerformanceHomePage(),
);
}
}

class PerformanceHomePage extends StatefulWidget {
const PerformanceHomePage({super.key});

@override
State<PerformanceHomePage> createState() => _PerformanceHomePageState();
}

class _PerformanceHomePageState extends State<PerformanceHomePage> {
final _perf = FirebasePerformance.instance;
String _status = 'Ready. Traces/metrics upload to the Performance dashboard.';

Future<void> _run(String label, Future<void> Function() action) async {
try {
await action();
setState(() => _status = '✅ $label — sent.');
} catch (e) {
setState(() => _status = '❌ $label — $e');
}
}

@override
void initState() {
super.initState();
_perf.setPerformanceCollectionEnabled(true);
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('firebase_performance · tvOS')),
body: Padding(
padding: const EdgeInsets.all(48),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(_status, style: const TextStyle(fontSize: 28)),
const SizedBox(height: 32),
Wrap(
spacing: 24,
runSpacing: 24,
children: [
ElevatedButton(
autofocus: true,
onPressed: () => _run('custom trace', () async {
final trace = _perf.newTrace('tvos_test_trace');
await trace.start();
trace.putAttribute('source', 'apple_tv');
trace.incrementMetric('items', 3);
await Future<void>.delayed(
const Duration(milliseconds: 200));
await trace.stop();
}),
child: const Text('run custom trace'),
),
ElevatedButton(
onPressed: () => _run('http metric', () async {
final metric = _perf.newHttpMetric(
'https://firebase.google.com',
HttpMethod.Get,
);
await metric.start();
metric.httpResponseCode = 200;
metric.responsePayloadSize = 1024;
await metric.stop();
}),
child: const Text('record HTTP metric'),
),
ElevatedButton(
onPressed: () => _run('toggle collection', () async {
final on = await _perf.isPerformanceCollectionEnabled();
await _perf.setPerformanceCollectionEnabled(!on);
setState(() => _status = 'collection enabled = ${!on}');
}),
child: const Text('toggle collection'),
),
],
),
],
),
),
);
}
}
28 changes: 28 additions & 0 deletions packages/firebase_performance_tvos/example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: firebase_performance_example
description: Demonstrates how to use the firebase_performance plugin on tvOS.
publish_to: none

environment:
sdk: '^3.6.0'
flutter: '>=3.27.0'

dependencies:
# Pinned to the train the published _tvos packages ship on (firebase_core
# 4.11.x -> firebase_core_platform_interface 7.1.0). Keeps the native Pigeon
# ABI in sync with firebase_core_tvos.
firebase_core: 4.11.0
firebase_performance: 0.11.4+3
firebase_performance_tvos:
path: ../
firebase_core_tvos:
path: ../../firebase_core_tvos
flutter:
sdk: flutter

dev_dependencies:
flutter_lints: ^4.0.0
flutter_test:
sdk: flutter

flutter:
uses-material-design: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Local development override for the example app. Forces firebase_core_tvos
# to the sibling package so the example resolves against the plugin's hosted
# `^0.0.1` constraint before that package is published. Gitignored; examples
# are not published. Remove once firebase_core_tvos 0.0.1 is on pub.dev.
dependency_overrides:
firebase_core_tvos:
path: ../../firebase_core_tvos
Loading