Keychain の AccessGroup などで利用する Bundle Seed Id(App Identifer) を取得する方法です。
import UIKit import Security extension UIApplication { class var bundleSeedId: String { struct Static { static var token : dispatch_once_t = 0 static var identifier: String! } dispatch_once(&Static.token) { let query: NSDictionary = NSDictionary(objects: [kSecClassGenericPassword, "Bundle Seed ID", kCFBooleanTrue], forKeys: [kSecClass, kSecAttrAccount, kSecReturnAttributes]) var result: Unmanaged<AnyObject>? var status: OSStatus = SecItemCopyMatching(query as CFDictionaryRef, &result) if status == errSecItemNotFound { status = SecItemAdd(query as CFDictionaryRef, &result); } if status == errSecSuccess { if let op = result?.toOpaque() { let resultDict: NSDictionary = Unmanaged<NSDictionary>.fromOpaque(op).takeUnretainedValue() if let accessGroup = resultDict[kSecAttrAccessGroup as NSString] as? NSString { let components = accessGroup.componentsSeparatedByString(".") Static.identifier = components[0] as? String } } } } return Static.identifier } }