← 资料库索引 ← 官方文档 原始链接 ↗ 🔍
官方文档

identifierForVendor(IDFV)| Apple 开发者文档 原文标题:identifierForVendor | Apple Developer Documentation

发表时间:(页面未标注)采集时间:2026-10-09 10:27:36来源:developer.apple.com原文语言:en状态:抽取受限

内容概要总结

Apple 官方对 UIDevice.identifierForVendor(IDFV)的接口说明。IDFV 是一个字母数字字符串,用于在同一设备上把 App 唯一标识到其所属开发者(vendor)。同一 vendor 的 App 在同一设备上取值相同;不同 vendor 的 App 或不同设备上的 App 取值不同。

正常情况下 vendor 由 App Store 提供的数据决定;若 App 非经 App Store 安装(如企业签名或开发中的 App),则依据 App 的 bundle ID 计算 vendor ID(bundle ID 假定为反向 DNS 格式)。iOS 6 取 bundle ID 的前两个分量生成 vendor ID;iOS 7 取除最后一段外的所有分量,单段 bundle ID 则整段使用。文档给出对照表说明 com.example.app1 与 com.example.app2 会得到相同的 vendor ID。

若取值为 nil,应稍后重试(例如设备重启后、用户尚未解锁设备时)。该值在 App(或同 vendor 的其他 App)安装于设备期间保持不变;当用户删除该 vendor 的全部 App 后再重装时会变化,使用 Xcode 安装测试包或通过 ad-hoc 分发安装时也可能变化,因此 App 若存储该值需优雅处理标识变化。

翻译内容

原文内容(English)

⚠ 说明:原站为 JS 渲染,正文经浏览器渲染(browser-bridge)获取;已剔除站点导航与页脚,仅保留文章主体。

实例属性(Instance Property)

identifierForVendor

一个字母数字字符串,用于在 App 的 vendor 维度上唯一标识一台设备。

支持平台:iOS 6.0+、iPadOS 6.0+、Mac Catalyst 13.1+、tvOS、visionOS 1.0+

var identifierForVendor: UUID? { get }

讨论(Discussion)

该属性的值,对于来自同一 vendor、运行在同一台设备上的 App 是相同的。对于同一台设备上来自不同 vendor 的 App,以及不同设备上的 App(无论是否同一 vendor),会返回不同的值。

通常情况下,vendor 由 App Store 提供的数据决定。如果 App 不是从 App Store 安装的(例如企业分发的 App 以及仍在开发中的 App),则会依据 App 的 bundle ID 计算出一个 vendor 标识符。该 bundle ID 被假定为反向 DNS 格式。

在 iOS 6 中,使用 bundle ID 的前两个分量来生成 vendor ID。如果 bundle ID 只有一个分量,则使用整个 bundle ID。

在 iOS 7 中,使用 bundle ID 中除最后一个分量之外的所有分量来生成 vendor ID。如果 bundle ID 只有一个分量,则使用整个 bundle ID。

下表列出一组 bundle ID,以及系统使用 bundle ID 的哪些部分来计算 vendor ID。

Bundle IDiOS 6.xiOS 7.x
Com.example.app1Com.example.app1Com.example.app1
Com.example.app2Com.example.app2Com.example.app2
Com.example.app.app1Com.example.app.app1Com.example.app.app1
Com.example.app.app2Com.example.app.app2Com.example.app.app2
ExampleExampleExample

例如,com.example.app1 和 com.example.app2 会被认为具有相同的 vendor ID。

如果该值为 nil,请稍等片刻后再重新获取该值。这种情况会发生,例如设备已重启但用户尚未解锁设备之时。

在 App(或来自同一 vendor 的另一个 App)安装于该 iOS 设备期间,该属性的值保持不变。当用户从设备上删除该 vendor 的所有 App,随后又重新安装其中一个或多个时,该值会发生变化。在使用 Xcode 安装测试构建,或通过 ad-hoc 分发在设备上安装 App 时,该值也可能变化。因此,如果你的 App 将该属性的值存储到任何地方,你应当优雅地处理标识符发生变化的情况。

另见(See also)

识别设备与操作系统

  • var name: String —— 设备的名称。
  • var systemName: String —— 设备上运行的操作系统名称。
  • var systemVersion: String —— 操作系统的当前版本。
  • var model: String —— 设备的型号。
  • var localizedModel: String —— 设备型号的本地化字符串。
  • var userInterfaceIdiom: UIUserInterfaceIdiom —— 当前设备上应使用的界面风格。

Skip Navigation
Get Started
Platforms
Technologies
Community
Documentation
Downloads
Support
Sign in
Documentation
Swift
Language:
Swift
Objective-C
All Technologies
UIKit

Essentials

Adopting Liquid Glass

UIKit updates

Essentials

Adopting Liquid Glass

UIKit updates

About app development with UIKit

Protecting the User’s Privacy

App structure

App and environment

Life cycle

Managing your app’s life cycle

Responding to the launch of your app

C

UIApplication

r
P

UIApplicationDelegate

Scenes

Transitioning to the UIKit scene-based life cycle

Device environment

C

UIDevice

Getting the shared device instance

P

class var current: UIDevice

Identifying the device and operating system

P

var name: String

P

var systemName: String

P

var systemVersion: String

P

var model: String

P

var localizedModel: String

P

var userInterfaceIdiom: UIUserInterfaceIdiom

P

var identifierForVendor: UUID?

Determining the available features

P

var isMultitaskingSupported: Bool

119 items were found. Tab back to navigate through them.

/
Navigator is ready
UIKit
UIDevice
identifierForVendor
Instance Property
identifierForVendor
An alphanumeric string that uniquely identifies a device to the app’s vendor.
iOS 6.0+
iPadOS 6.0+
Mac Catalyst 13.1+
tvOS
visionOS 1.0+
var identifierForVendor: UUID? { get }
Discussion

The value of this property is the same for apps that come from the same vendor running on the same device. A different value is returned for apps on the same device that come from different vendors, and for apps on different devices regardless of vendor.

Normally, the vendor is determined by data provided by the App Store. If the app wasn’t installed from the app store (such as enterprise apps and apps still in development), then a vendor identifier is calculated based on the app’s bundle ID. The bundle ID is assumed to be in reverse-DNS format.

In iOS 6, the first two components of the bundle ID are used to generate the vendor ID. If the bundle ID only has a single component, then the entire bundle ID is used.

In IOS 7, all components of the bundle except for the last component are used to generate the vendor ID. If the bundle ID only has a single component, then the entire bundle ID is used.

The following table shows a collection of bundle IDs and which portions of the bundle ID the system uses to calculate the vendor ID.

Bundle ID

iOS 6.x

iOS 7.x

Com.example.app1

Com.example.app1

Com.example.app1

Com.example.app2

Com.example.app2

Com.example.app2

Com.example.app.app1

Com.example.app.app1

Com.example.app.app1

Com.example.app.app2

Com.example.app.app2

Com.example.app.app2

Example

Example

Example

For example, com.example.app1 and com.example.app2 would appear to have the same vendor ID.

If the value is nil, wait and get the value again later. This happens, for example, after the device has been restarted but before the user has unlocked the device.

The value in this property remains the same while the app (or another app from the same vendor) is installed on the iOS device. The value changes when the user deletes all of that vendor’s apps from the device and subsequently reinstalls one or more of them. The value can also change when installing test builds using Xcode or when installing an app on a device using ad-hoc distribution. Therefore, if your app stores the value of this property anywhere, you should gracefully handle situations where the identifier changes.

See also
Identifying the device and operating system
var name: String
The name of the device.
var systemName: String
The name of the operating system running on the device.
var systemVersion: String
The current version of the operating system.
var model: String
The model of the device.
var localizedModel: String
The model of the device as a localized string.
var userInterfaceIdiom: UIUserInterfaceIdiom
The style of interface to use on the current device.
Current page is identifierForVendor
Apple
Developer
Documentation
Platforms
iOS
iPadOS
macOS
tvOS
visionOS
watchOS
Tools
Swift
SwiftUI
Swift Playground
TestFlight
Xcode
Xcode Cloud
SF Symbols
Topics & Technologies
Accessibility
Accessories
App Extension
App Store
Audio & Video
Augmented Reality
Design
Distribution
Education
Fonts
Games
Health & Fitness
In-App Purchase
Localization
Maps & Location
Machine Learning & AI
Open Source
Security
Safari & Web
Resources
Documentation
Tutorials
Downloads
Forums
Videos
Support
Support Articles
Contact Us
Bug Reporting
System Status
Account
Apple Developer
App Store Connect
Certificates, IDs, & Profiles
Feedback Assistant
Programs
Apple Developer Program
Apple Developer Enterprise Program
App Store Small Business Program
MFi Program
News Partner Program
Video Partner Program
Security Bounty Program
Security Research Device Program
Events
Meet with Apple
Apple Developer Centers
App Store Awards
Apple Design Awards
Apple Developer Academies
WWDC
To submit feedback on documentation, visit Feedback Assistant.
Select a color scheme preference
Light
Dark
Auto
English
简体中文
日本語
한국어
Español
Deutsch
Français
Italiano
Português
Copyright © 2026 Apple Inc. All rights reserved.Terms of UsePrivacy PolicyAgreements and Guidelines