Skip to content

Add macOS platform support to resolve dependency conflicts - #33

Merged
didiergarcia merged 2 commits into
mainfrom
fix/macos-platform-support
Feb 6, 2026
Merged

didiergarcia merged 2 commits into
mainfrom
fix/macos-platform-support

Conversation

@didiergarcia

Copy link
Copy Markdown
Contributor

Summary

Adds macOS 10.15+ platform support to resolve dependency conflicts when SegmentAmplitude and analytics-swift are used together in multi-platform projects.

Problem

When both Analytics Swift and the Segment Amplitude plugin are added to the same project as dependencies, the project fails to build due to a platform version mismatch:

The package product 'Segment' requires minimum platform version 10.15 for the macOS platform, 
but this target supports 10.13 (in target 'SegmentAmplitude' from project 'SegmentAmplitude')

This occurs because:

  • analytics-swift requires macOS 10.15+
  • SegmentAmplitude did not declare macOS support in Package.swift
  • Swift Package Manager defaults to an incompatible baseline version

Solution

Package.swift:

  • Added .macOS(.v10_15) to platforms array to match analytics-swift dependency requirement

AmplitudeSession.swift:

  • Made UIKit import conditional (#if !os(macOS))
  • Refactored lifecycle handling into platform-specific extensions:
    • iOS/tvOS: iOSLifecycle protocol with UIApplication? parameters
    • watchOS: watchOSLifecycle protocol with WKExtension parameters
    • macOS: macOSLifecycle protocol with no parameters (new!)

All platforms use the same session management logic (startNewSessionIfNecessary(), timeout handling, etc.) while respecting platform-specific lifecycle APIs.

Test Plan

  • Build succeeds for macOS target (swift build)
  • Build succeeds for iOS Simulator
  • Created test project with both analytics-swift and SegmentAmplitude dependencies - builds successfully
  • Runtime initialization works correctly on macOS
  • Verified no regression - existing iOS/tvOS/watchOS functionality preserved
  • Test in CI pipeline (GitHub Actions)
  • Manual testing of session tracking on macOS app (if available)

Changes

  • Package.swift: Added macOS 10.15+ to platforms array
  • Sources/SegmentAmplitude/AmplitudeSession.swift: Platform-specific lifecycle extensions

Files Changed: 2 files, +37 insertions, -17 deletions

Backward Compatibility

✅ Fully backward compatible - no breaking changes to existing iOS, tvOS, or watchOS functionality.

🤖 Generated with Claude Code

Fixes platform version mismatch when SegmentAmplitude and analytics-swift
are used together in multi-platform projects. Previously, projects would
fail to build because analytics-swift requires macOS 10.15+ but
SegmentAmplitude didn't declare macOS support.

Changes:
- Add .macOS(.v10_15) to Package.swift platforms array
- Make UIKit import conditional for macOS compatibility
- Refactor lifecycle handling into platform-specific extensions
- Add macOSLifecycle protocol support for session tracking on macOS

All platforms (iOS, tvOS, watchOS, macOS) now use consistent session
management logic while respecting platform-specific lifecycle APIs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update actions/checkout from v2 to v4 and actions/cache from v2 to v4
to resolve CI failures due to deprecated action versions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@didiergarcia
didiergarcia merged commit edade55 into main Feb 6, 2026
3 checks passed
@didiergarcia
didiergarcia deleted the fix/macos-platform-support branch February 6, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants