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_analytics_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_analytics_tvos/.pubignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pubspec_overrides.yaml
8 changes: 8 additions & 0 deletions packages/firebase_analytics_tvos/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## 0.0.1

- Initial tvOS (Apple TV) implementation of `firebase_analytics`, ported from
`firebase_analytics` 12.4.3 via `flutter-tvos plugin port` and finished by
hand (podspec `Firebase/Analytics` + `firebase_core_tvos` deps, tvOS 15.0
floor, `firebase_core_tvos` import, Dart re-export).
- Verified on the tvOS simulator and a physical Apple TV 4K (tvOS 26.2):
Firebase initializes and Analytics events reach the backend.
26 changes: 26 additions & 0 deletions packages/firebase_analytics_tvos/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Copyright 2017, the Chromium project 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.
85 changes: 85 additions & 0 deletions packages/firebase_analytics_tvos/PORTING_REPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# firebase_analytics_tvos — porting report

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

Source: `firebase_analytics` 12.4.3 (Swift). Base platform: ios.
Output: `./firebase_analytics_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**: no methods were stubbed (analytics has no tvOS-incompatible APIs).
- [x] Partial methods — **N/A**: none. Full API is available on tvOS.
- [x] Removed imports — **N/A**: none removed.
- [x] `flutter-tvos build tvos` compiles the generated registrant — **verified** (simulator + physical Apple TV 4K, tvOS 26.2).
- [x] Version set (`0.0.1`) and `CHANGELOG.md` updated.

---

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

---

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

The automated port compiles clean (analytics has no tvOS-incompatible APIs — no
stubs, no `#if !TARGET_OS_TV` disables). Manual work applied on top:

- **Podspec:** depend on `Firebase/Analytics '~> 12.15.0'` + `firebase_core_tvos`
(not upstream `firebase_core`, which declares no tvOS platform); bump
`s.platform` to tvOS 15.0 (Firebase 12.x floor); `static_framework = true`.
No Flutter-CocoaPod dependency (resolved via `FRAMEWORK_SEARCH_PATHS`).
- **`FirebaseAnalyticsPlugin.swift`:** `#if canImport(firebase_core) … #else
firebase_core_shared` repointed to a plain `import firebase_core_tvos`.
- **Swift package:** deleted the generated `tvos/Package.swift` (route via the
podspec, like `firebase_storage_tvos`; the SPM manifest lacks the Firebase +
`firebase_core_tvos` deps).
- **`lib/firebase_analytics_tvos.dart`:** one-line re-export of
`package:firebase_analytics/firebase_analytics.dart` (the Dart API is
method-channel-only, no per-platform override — duplicating it would create
incompatible types).

**Version alignment (important for consumers).** This package's native Pigeon
matches `firebase_analytics 12.4.3` on the **`firebase_core_platform_interface`
7.1.0** train (i.e. `firebase_core 4.11.x`). An app mixing `firebase_core_tvos`
(built on that train, 15-field `FirebaseOptions`) with an older/newer
`firebase_core` whose options list differs will crash in
`CoreFirebaseOptions.fromList` at launch when initializing via Dart `options:`.
Keep the whole Firebase stack on one consistent FlutterFire release.

**Verified.** `flutter-tvos build tvos` (simulator + physical **Apple TV 4K,
tvOS 26.2, arm64**); Firebase `initializeApp(options:)` succeeds, Analytics
`12.15.0` starts, collection enabled, and events reach the Firebase project
(confirmed as an active user in the Analytics overview). `Platform.operatingSystem
== "tvos"`, `Platform.isIOS == true`.
40 changes: 40 additions & 0 deletions packages/firebase_analytics_tvos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# firebase_analytics_tvos

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

> Ported with [`flutter-tvos plugin port`](https://github.com/fluttertv/flutter-tvos)
> from `firebase_analytics` 12.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_analytics` and target tvOS add:

```yaml
dependencies:
firebase_analytics: ^12.4.3
firebase_analytics_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). See `PORTING_REPORT.md`.

## Status

| Platform | Implemented | Verified |
| --------------------------------------- | ----------- | ----------------------------------------------------------------------------- |
| Apple TV (`appletvos`) | yes | ✅ physical Apple TV 4K, tvOS 26.2 — Firebase inits, events reach the backend |
| Apple TV simulator (`appletvsimulator`) | yes | ✅ builds + runs |

All `firebase_analytics` APIs are available (no tvOS feature disables). Events
appear in Firebase **DebugView** when the app is launched with `-FIRDebugEnabled`.

## License

fluttertv under a BSD-3-Clause license. See `LICENSE` for the full text.
7 changes: 7 additions & 0 deletions packages/firebase_analytics_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
1 change: 1 addition & 0 deletions packages/firebase_analytics_tvos/example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GoogleService-Info.plist
68 changes: 68 additions & 0 deletions packages/firebase_analytics_tvos/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# firebase_analytics_tvos example (Apple TV)

Minimal app that logs Firebase Analytics events from tvOS, for verifying the
`firebase_analytics_tvos` federated plugin on the Simulator and a physical
Apple TV.

## 1. Connect it to Firebase

On tvOS, `defaultTargetPlatform == TargetPlatform.iOS`, so **the iOS Firebase
app config is what tvOS uses** — you do _not_ need a separate tvOS app in the
Firebase console (though you may register one with the bundle id
`com.example.firebaseAnalyticsExample` if you prefer a clean split).

Two ways to supply the config:

**A. FlutterFire CLI (recommended — regenerates `lib/firebase_options.dart`):**

```bash
cd packages/firebase_analytics_tvos/example
flutterfire configure # pick your project; select the iOS app
```

This overwrites the placeholder `lib/firebase_options.dart` with real values.
tvOS reads the `ios` entry automatically.

**B. Hand-fill:** copy `apiKey` / `appId` (GOOGLE_APP_ID) / `messagingSenderId`
(GCM_SENDER_ID) / `projectId` / `storageBucket` from your iOS app's
`GoogleService-Info.plist` (or Firebase console → Project settings) into the
`ios` block of `lib/firebase_options.dart`.

> **Optional — GoogleService-Info.plist:** the Dart options above are enough for
> Analytics. If you also want to drop the plist in, put your iOS app's
> `GoogleService-Info.plist` at `tvos/Runner/GoogleService-Info.plist` and add it
> to the Runner target in Xcode (drag it into the Runner group, tick
> "Copy items if needed" + the Runner target). Not required.

## 2. Run it

```bash
export PATH="/path/to/flutter-tvos/bin:$PATH"

# Simulator:
flutter-tvos pub get
open -a Simulator # boot a tvOS simulator
flutter-tvos run -d "Apple TV" # or: flutter-tvos build tvos --simulator --debug

# Physical Apple TV (must be paired to Xcode: Xcode ▸ Devices & Simulators):
flutter-tvos run -d <your-apple-tv-name>
```

## 3. See events in Firebase DebugView (near-real-time)

Analytics normally batches events for ~1 hour. **DebugView** shows them within
seconds. Enable debug mode by passing a launch argument:

- **From Xcode:** open `tvos/Runner.xcworkspace` → scheme **Runner** ▸ Edit
Scheme ▸ Run ▸ Arguments ▸ _Arguments Passed On Launch_ → add `-FIRDebugEnabled`.
Run the Runner scheme.
- (To stop: use `-FIRDebugDisabled` once.)

Then in the app press **"logEvent: test_event"** (or any button) with the Siri
Remote. In the Firebase console open **Analytics ▸ DebugView** and select your
debug device — you'll see `test_event`, `screen_view`, `login`, etc. stream in
with their parameters within a few seconds.

> Simulator note: Analytics runs on the Simulator, but for a true end-to-end
> check use a **physical Apple TV in profile/AOT** (`flutter-tvos run --profile`)
> — that's what confirms the plugin under release-mode compilation.
39 changes: 39 additions & 0 deletions packages/firebase_analytics_tvos/example/lib/firebase_options.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// 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. Running `flutterfire configure` regenerates this
// file with real values pulled from your Firebase project.
//
// 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.',
);
}
}

// Placeholders — run `flutterfire configure` (select your project's iOS app),
// or copy the values from your iOS app's GoogleService-Info.plist. tvOS reuses
// this iOS config because `defaultTargetPlatform == TargetPlatform.iOS`.
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.firebaseAnalyticsExample',
);
}
Loading