Skip to contentSkip to navigationSkip to topbar
On this page
Looking for more inspiration?Visit the
(information)
You're in the right place! Segment documentation is now part of Twilio Docs. The content you are used to is still here—just in a new home with a refreshed look.

Analytics-iOS Frequently asked questions


(warning)

End-of-Support for Analytics-iOS in March 2026

End-of-support for the Analytics-iOS SDK is scheduled for March 2026. Segment's future development efforts concentrate on the new Analytics-Swift SDK. To migrate to Analytics-Swift, see the migration guide.


How big is the Segment SDK?

how-big-is-the-segment-sdk page anchor

The core Segment SDK is extremely lightweight. It is approximately 212 KB.


Can I install the SDK manually using a dynamic framework?

can-i-install-the-sdk-manually-using-a-dynamic-framework page anchor

Segment highly recommends using Swift Package Manager or Cocoapods. Segment can't guarantee support if you do not use a dependency manager.

However, if you cannot use Swift Package Manager or Cocoapods, you can manually install Segment's dynamic framework which lets you send data to Segment and on to enabled cloud-mode destinations. Segment doesn't support sending data to bundled, device-mode integrations outside of Cocoapods.

To install manually:

  1. Download the latest built SDK(link takes you to an external page), and unzip the zip file.
  2. Drag the unzipped Segment.framework folder into your XCode project.
  3. In the General Tab for your project, search for Embedded Binaries and add the Segment.framework.
Segment framework example.

Once you install the framework, import the header file and install as described in Install the SDK.

If you choose not to use a dependency manager, you must manually keep files up-to-date with regularly scheduled, manual updates.


Can I initiate multiple writeKeys for a single iOS project?

can-i-initiate-multiple-writekeys-for-a-single-ios-project page anchor

No, Segment doesn't support sending events to multiple writeKeys for a single iOS project post-initialization. You can conditionally set the writeKey based on an environment variable. For example:

1
let writeKey
2
ENV == 'production' ? (writeKey = 'A') : (writeKey = 'B')

Should I include each destination's native SDK in my project?

should-i-include-each-destinations-native-sdk-in-my-project page anchor

No. Don't include destination-native SDKs manually for a service Segment supports. Instead, bundle the destination's Segment-integration SDK.

If you already include destination native SDKs, you should remove them when you install the Segment SDK. Keeping the duplicate native SDK can cause symbol conflicts, namespace collisions, duplicate data, and sometimes even silent failures.


What if Analytics-iOS doesn't support a feature I want to use?

what-if-analytics-ios-doesnt-support-a-feature-i-want-to-use page anchor

If you're using device-mode for a mobile destination and want to access a feature from the tool's native SDK, you can include the header file and call the method just as normal.

For example, you might want access to Flurry's location logging or Localytics's attribution parameters. To use the destination's SDK you import the headers, then access the SDK as you would without Segment. Segment still handles initialization, event, screen and user tracking, plus all the proxied services and data storage for you. Here's an example for Flurry location logging:

1
#import <Segment/SEGAnalytics.h>
2
#import <Flurry-iOS-SDK/Flurry.h>
3
4
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
5
[locationManager startUpdatingLocation];
6
CLLocation *location = locationManager.location;
7
[Flurry setLatitude:location.coordinate.latitude
8
longitude:location.coordinate.longitude
9
horizontalAccuracy:location.horizontalAccuracy
10
verticalAccuracy:location.verticalAccuracy];
11

How do I use push notifications?

how-do-i-use-push-notifications page anchor

For services that send push notifications, you must first create a Push SSL certificate(link takes you to an external page). Then configure your application delegate similarly to the following example code, replacing YOUR_WRITE_KEY with your own Segment source write key.

Detailed examples of how to complete the process can be found in Apple's documentation(link takes you to an external page).

SwiftObjective-C
1
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
2
let configuration = AnalyticsConfiguration(writeKey: "YOUR_WRITE_KEY")
3
4
// Use launchOptions to track tapped notifications
5
configuration.launchOptions = launchOptions
6
Analytics.setup(with: configuration)
7
8
// See the Apple linked above for detailed setup information, as it will vary
9
// based on which versions of iOS are supported and what language is being used.
10
...
11
12
return true
13
}
14

Once you've passed in the launch options and configured the types of notifications your application should received you can then call into Segment's library to indicate that a device token and/or notification has been received.

SwiftObjective-C
1
// Let Segment Analytics know a device token was received
2
Analytics.shared().registeredForRemoteNotifications(deviceToken: deviceToken)
3
4
...
5
6
// Let Segment Analytics know that a remote notification was received
7
Analytics.shared().receivedRemoteNotification(userInfo)

Can I set user traits without a User ID?

can-i-set-user-traits-without-a-user-id page anchor

Yes, you can pass a nil value for the userId in an Identify call, like in the following example:

SwiftObjective-C
Analytics.shared().identify(nil, traits: ["email": "example@example.com", "gender": "F"])

Do you support iOS 10.x?

do-you-support-ios-10x page anchor

Analytics-iOS supports iOS 11.0+.

If you need support for older operating systems you can fork the Segment iOS repo on GitHub(link takes you to an external page) and build the framework(link takes you to an external page) with support for your version of iOS.


Is the Segment SDK compatible with Swift?

is-the-segment-sdk-compatible-with-swift page anchor

Yes, Swift's compatibility with Objective-C lets you create a source that contains files written in either language. To use the Segment Analytics-iOS SDK from a Swift source, follow these instructions from Apple(link takes you to an external page).


Can I help develop a destination?

can-i-help-develop-a-destination page anchor

Yes, the Segment Analytics-iOS SDK is open-source(link takes you to an external page).


How do I know when a destination is initialized?

how-do-i-know-when-a-destination-is-initialized page anchor

The iOS library posts a notification to indicate when it initializes any destination, so you can call its methods directly.

SwiftObjective-C
1
NotificationCenter.default.addObserver(self, selector: #selector(integrationDidStart(_:)), name: SEGAnalyticsIntegrationDidStart, object: nil)
2
3
@objc func integrationDidStart(_ notification:Notification) {
4
guard let integration = notification.object as? String else { return }
5
6
if integration == "Mixpanel" {
7
// Call Mixpanel library methods here.
8
}
9
}

Can I anonymize IP addresses?

can-i-anonymize-ip-addresses page anchor

Segment collects IP addresses for device-mode (iOS, Android, Analytics.js and Xamarin) events automatically. If you don't want to record your tracked users' IP in destinations (and in storage destinations like S3), you can set the event's context.ip field to 0.0.0.0 . The Segment servers don't record the IP address of the client for libraries if the context.ip field is already set.

If you'd like to centralize this logic, you can write a middleware for it.

The following examples show how to set a static 0 value for the IP.

SwiftObjective-C
Analytics.shared().track("Clicked Button", properties: nil, options: ["context": ["ip": "0.0.0.0"]])

How can I get the user's IDFA?

how-can-i-get-the-users-idfa page anchor

Some destinations, especially mobile attribution tools (for example, Kochava(link takes you to an external page)), require the IDFA (identifier for advertisers). The IDFA appears in Segment calls in the debugger as context.device.advertisingId. To capture this value with Analytics-iOS, follow the steps in Ad-tracking and IDFA. Remember that Apple now requires that the user consent to your tracking before you can collect the IDFA.


tvOS / macOS / Catalyst support

tvos--macos--catalyst-support page anchor

As of Version 4.1.0(link takes you to an external page), Analytics-iOS now supports tvOS, macOS, and Catalyst as well. You can follow the quickstart documentation to set it up.


AppClip tracking support

appclip-tracking-support page anchor

If you are tracking App Clips using iOS or Swift libraries, there is a chance that you may encounter zeros in your device ID. Segment recommends that you set your own device ID in this instance to avoid running into this issue.


Why am I seeing a value of — set for the network carrier?

why-am-i-seeing-a-value-of--set-for-the-network-carrier page anchor

With iOS 16.4(link takes you to an external page), Apple deprecated the method to return the network carrier. The iOS library can no longer return a valid value for the network carrier on devices using iOS 16.4 or later. As a result, you will likely see -- set for the context.network.carrier field.