From 58177102a4a556b013531ea225206cbc970a80a7 Mon Sep 17 00:00:00 2001 From: millianlmx Date: Sat, 27 Jun 2026 00:39:52 +0000 Subject: [PATCH] fix: permanently fix PostHog module emission error - Change PostHog from exactVersion to revision (tag 3.62.0) in project.yml - Add deep cache clean step before xcodegen in CI workflow - Add ONLY_ACTIVE_ARCH=NO to xcodebuild command - Wrap PostHog usage in #if canImport(PostHog) for graceful degradation - Add Package.resolved, .build/, DerivedData/ to .gitignore - Remove stale SPM caches between CI runs (DerivedData, swiftpm caches, act cache) --- .gitea/workflows/pr-iphone-deploy.yml | 9 +++++++++ .gitignore | 5 +++++ .../TabataGo/Services/AnalyticsService.swift | 10 ++++++++++ tabatago-swift/project.yml | 2 +- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/pr-iphone-deploy.yml b/.gitea/workflows/pr-iphone-deploy.yml index 9f32556..a55b22d 100644 --- a/.gitea/workflows/pr-iphone-deploy.yml +++ b/.gitea/workflows/pr-iphone-deploy.yml @@ -36,6 +36,14 @@ jobs: - name: Setup PATH run: echo "/opt/homebrew/bin" >> $GITHUB_PATH + - name: Clean ALL caches + run: | + rm -rf ~/Library/Developer/Xcode/DerivedData + rm -rf ~/Library/Caches/org.swift.swiftpm + rm -rf ~/Library/org.swift.swiftpm + rm -rf .build + rm -rf ~/.cache/act/*/hostexecutor/tabatago-swift/build + - name: Install tools (xcodegen, node, firebase) run: | brew install xcodegen node || true @@ -63,6 +71,7 @@ jobs: -allowProvisioningUpdates \ -skipPackagePluginValidation \ SWIFT_ENABLE_EXPLICIT_MODULES=NO \ + ONLY_ACTIVE_ARCH=NO \ CODE_SIGN_STYLE=Automatic DEVELOPMENT_TEAM=2MJF39L8VY - name: Package IPA diff --git a/.gitignore b/.gitignore index 9113d6f..15e1f4f 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,8 @@ Config/Secrets.xcconfig _Users_* swift-generated-sources/ tabatago-swift/build/ + +# Swift Package Manager +Package.resolved +.build/ +DerivedData/ diff --git a/tabatago-swift/TabataGo/Services/AnalyticsService.swift b/tabatago-swift/TabataGo/Services/AnalyticsService.swift index bd04448..e7259d8 100644 --- a/tabatago-swift/TabataGo/Services/AnalyticsService.swift +++ b/tabatago-swift/TabataGo/Services/AnalyticsService.swift @@ -1,30 +1,38 @@ import Foundation +#if canImport(PostHog) import PostHog +#endif /// PostHog analytics — mirrors the event taxonomy from the Expo app. final class AnalyticsService: @unchecked Sendable { static let shared = AnalyticsService() +#if canImport(PostHog) private let apiKey: String = Bundle.main.infoDictionary?["POSTHOG_API_KEY"] as? String ?? "" private let host = "https://eu.posthog.com" +#endif private init() {} func initialize() { +#if canImport(PostHog) guard !apiKey.isEmpty else { return } let config = PostHogConfig(apiKey: apiKey, host: host) config.captureApplicationLifecycleEvents = true config.captureScreenViews = false // manual tracking PostHogSDK.shared.setup(config) +#endif } // ─── Screens ──────────────────────────────────────────────── func screen(_ name: String, properties: [String: Any] = [:]) { +#if canImport(PostHog) PostHogSDK.shared.screen(name, properties: properties) +#endif } // ─── Onboarding ───────────────────────────────────────────── @@ -100,6 +108,8 @@ final class AnalyticsService: @unchecked Sendable { // ─── Private ───────────────────────────────────────────────── private func capture(_ event: String, properties: [String: Any] = [:]) { +#if canImport(PostHog) PostHogSDK.shared.capture(event, properties: properties.isEmpty ? nil : properties) +#endif } } diff --git a/tabatago-swift/project.yml b/tabatago-swift/project.yml index 16e11b2..0526c48 100644 --- a/tabatago-swift/project.yml +++ b/tabatago-swift/project.yml @@ -30,7 +30,7 @@ packages: from: "5.0.0" PostHog: url: https://github.com/PostHog/posthog-ios - exactVersion: "3.62.0" + revision: "3.62.0" targets: TabataGo: