Swiftpack.co - Package - segmentio/analytics-ios


Circle CI Version License codecov Carthage compatible SwiftPM Compatible

analytics-ios is an iOS client for Segment.

Special thanks to Tony Xiao, Lee Hasiuk and Cristian Bica for their contributions to the library!

Analytics helps you measure your users, product, and business. It unlocks insights into your app's funnel, core business metrics, and whether you have product-market fit.

How to get started

  1. Collect analytics data from your app(s).
    • The top 200 Segment companies collect data from 5+ source types (web, mobile, server, CRM, etc.).
  2. Send the data to analytics tools (for example, Google Analytics, Amplitude, Mixpanel).
    • Over 250+ Segment companies send data to eight categories of destinations such as analytics tools, warehouses, email marketing and remarketing systems, session recording, and more.
  3. Explore your data by creating metrics (for example, new signups, retention cohorts, and revenue generation).
    • The best Segment companies use retention cohorts to measure product market fit. Netflix has 70% paid retention after 12 months, 30% after 7 years.

Segment collects analytics data and allows you to send it to more than 250 apps (such as Google Analytics, Mixpanel, Optimizely, Facebook Ads, Slack, Sentry) just by flipping a switch. You only need one Segment code snippet, and you can turn integrations on and off at will, with no additional code. Sign up with Segment today.


  1. Power all your analytics apps with the same data. Instead of writing code to integrate all of your tools individually, send data to Segment, once.

  2. Install tracking for the last time. We're the last integration you'll ever need to write. You only need to instrument Segment once. Reduce all of your tracking code and advertising tags into a single set of API calls.

  3. Send data from anywhere. Send Segment data from any device, and we'll transform and send it on to any tool.

  4. Query your data in SQL. Slice, dice, and analyze your data in detail with Segment SQL. We'll transform and load your customer behavioral data directly from your apps into Amazon Redshift, Google BigQuery, or Postgres. Save weeks of engineering time by not having to invent your own data warehouse and ETL pipeline.

    For example, you can capture data on any app:

    analytics.track('Order Completed', { price: 99.84 })

    Then, query the resulting data in SQL:

    select * from app.order_completed
    order by price desc

🚀 Startup Program


Analytics is available through CocoaPods and Carthage.


pod "Analytics", "3.7.0"

Note: Segment strongly recommends that you use a dynamic framework to manage your project dependencies. If you prefer static libraries, you can add use_modular_headers! or use_frameworks! :linkage => :static in your Podfile. However, you must then manually update all of your dependencies on a regular schedule.


github "segmentio/analytics-ios"


Refer to the Quickstart documentation at https://segment.com/docs/libraries/ios/quickstart.


More detailed documentation is available at https://segment.com/docs/libraries/ios.


Stars: 343


Used By

Total: 0


4.1.2 -

Version 4.1.2 (12 November, 2020)

  • Fix Standarized all SDK versions between dependency managers. Migrated to importing modules vs headers. Removed all linked frameworks.
  • Fix Fixed missing userId in traits.
  • Fix Fixed an issue with NSCopying preceding SEGSerialization.
  • Fix Output log messages when events are trimmed from the queue.
  • Fix Added category option to screen calls.

4.1.1 -

Version 4.1.1 (27 October, 2020)

  • Fix Fixed example projects using old branch for SPM.
  • Fix Repaired mac example project.
  • [Fix] Fixed carthage support for main library and destinations.

4.1.0 -

Version 4.1.0 (19 October, 2020)

  • New Added Webhook Integration.
  • New Renamed module from Analytics to Segment.
  • Fix Removed unused mobile attribution.
  • New Added ability for customer to make their types serializable.
  • New Added necessary changes for Edge Functions.

4.0.5 (pre-release) -

  • Fix Fixed issue where non-serializable types would get into payload.
  • Fix Fixed double device payload.
  • New Deprecated configuration access and updated associated tests.
  • Fix Disregard payloads that fail conversion from plist to json.
  • New Added Swift and Carthage badging.

4.0.4 -

  • New Added MacOS support.
  • Fix Fixed SEGLog permissions.
  • Fix Adopted Swift 5 syntax in tests. Removed SwiftTryCatch dependency for tests. Fixed deadlock from #916.

4.0.3 -

Version 4.0.3 (6 July, 2020)

  • Fix Fixed an issue with old traits overwriting new traits.
  • New Added full example flow with Swift Package Manager compatibility.
  • Fix Fixed SwiftUI previews in macOS Catalyst builds.

4.0.2 -

Version 4.0.2 (25 June, 2020)

  • New Separate public utils from private utils appropriately.
  • New Payload Info & Traits Fixes.
  • New Updated SPM for code coverage compatibility.
  • New Removed Quick and Nimble, updated unit tests.

4.0.1 -

  • New Added global state management; Middleware now receive all context data.
  • New change logic for screen naming conventions.
  • New Fixed crash on UISceneDelegate applications.
  • New Renamed middleware methods to match a.js naming.
  • New Added Swift Package Manager support.
  • New Updated class names for Swift.

3.9.0 -

  • New Backport defaultSettings feature from 4.x to 3.x.
  • Fix Automatic Screen Tracking with consistent naming conventions

4.0.0-beta.1 -

  • New Makes IDFA support externally/customer driven.

3.8.2 -

  • Fix Adds check to make sure cached settings aren't empty before being used.

3.8.1 -

  • Fix Fixed a crash in the file storage.
  • Fix Adds back erroneously removed build/version data from App Opened event.
  • Fix Pushlishes filenames use for storage.
  • Fix Fixes incorrect naming in screen reporting.

4.0.0-beta.0 -

  • New Added integration middleware functionality.

3.8.0 -

  • Promoting 3.8.x series to stable release. This includes all changes since 3.7.
  • Fix Implement maximum batch request size.

3.8.0-beta.2 -

Version 3.8.0-beta.2 (15th April, 2020)

  • Fix Move SEGQueue from UserDefaults to caches directory.
  • Fix Fix issues around plist->json conversion and nil values.
  • Fix Expect dictionary as well as bool for integration enablement.
  • Fix Differences observed in how iOS/android pass userId/anonId; Corrected.
  • Fix Look at previously cached settings before blowing them away.
  • Fix Added experimental feature to enable nanosecond granularity on timestamps.

3.7.1 -

The following fixes were backported from the 3.8.x betas

  • Fix: Fallback to last settings loaded on iOS.
  • Fix: Differences observed in how iOS/android pass userId/anonId; Corrected.
  • Fix: Fix GCD mutual dependency

3.8.0-beta.1 -

  • Fix Reload static context data when the app returns from background.
  • Fix Fixes issue where customers can overwrite information regarding integration enablement.
  • Fix Swapped JSON in for the storage format instead of plists.
  • Fix Hardened handling of user-supplied data in event properties.
  • New Added support for SSL pinning.
  • Fix CoreTelephony library is now only included on iOS targets.

3.8.0-beta.0 -

  • New: Add iOS Backgrounded Event.
  • Fix: Fix GCD mutual dependency
  • Fix: adding “name” field to payload; updated nimble to version 7.3.4

3.7.0 -

This release promotes 3.7.0-beta.4 to stable.

3.7.0-beta.4 -

  • Fix: Remove invalid .clang-format symlink which can cause issues with manual builds.
  • Fix: Collect context.device.type as ios.
  • Fix: Fix Xcode warning.

Version 3.7.0-beta.3 -

  • Fix: Allow setting anonymousId
  • Fix: Remove stray log

Version 3.6.10 -

  • Fix: Add deep links redaction

Version 3.7.0-beta.2 -

  • Fix: Add deep links redaction

Version 3.6.10-beta -

  • Fix: Add deep links redaction

Version 3.7.0-beta.1 -

  • Fix: Remove -beta suffix from CFBundleShortVersionString

Version 3.7.0-beta -

  • Improvement: Make the maximum queue size configurable

  • Improvement: Make the flush interval configurable

  • Fix: Fix linking issues when automatic framework linking is disabled

  • Fix: Retry HTTP 429 status codes

  • Fix: Send RFC 7231 Formatted User Agent

  • Fix: Ensure queue is always < 1000 items

  • Fix: Reset SEGUserIdKey only on tvOS

  • Fix: Renames GZIP category to prevent collisions

  • Fix: sharedAnalytics returns null before setup

  • Fix: Swift 4 support

Version 3.6.9 -

  • Fix: Fixes some compiler warnings seen when importing analytics-ios via Swift in a Carthage project.
  • Fix: Fix crash when trying to get screen name in some cases.
  • New: Support schema defaults.
  • New: Send disabled events to Segment so they can be surfaced in the debugger. This won't be sent to any destinations.
  • Fix: Fix date formatting to be RFC 3339 compliant.
  • Fix: Always deliver events asynchronously to integrations.

Version 3.6.8 has been deleted as it contained a bug which could cause events to not be delivered to the Segment API.

3.6.8 -

  • Fix: Fixes some compiler warnings seen when importing analytics-ios via Swift in a Carthage project.
  • Fix: Fix crash when trying to get screen name in some cases.
  • New: Support schema defaults.
  • New: Send disabled events to Segment so they can be surfaced in the debugger. This won't be sent to any destinations.
  • Fix: Fix date formatting to be RFC 3339 compliant.
  • Improvement: Run connection factory asynchronously so it doesn't block queuing events.
  • Fix: Always deliver events asynchronously to integrations.

Version 3.6.7 *(24th August, 2017)* -

  • Use DEBUG preprocessor flag to conditionally disable assertions in prod #711

Version 3.6.6 (Aug 15, 2017) -

  • Update Info.plist version with library version. Add Makefile for building dynamic framework via Carthage. Explicitly distributing frameworks for installation outside of dependency managers.