Obtain bundle identifier programmatically in Swift?

前端 未结 3 1188
旧时难觅i
旧时难觅i 2020-12-30 18:11

How can I get the bundle ID in Swift?

Objective-C version:

NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
3条回答
  •  孤独总比滥情好
    2020-12-30 18:44

    It's pretty much the same thing in Swift except the class and method names have been shortened:

    let bundleIdentifier = Bundle.main.bundleIdentifier // return type is String?
    

提交回复
热议问题