自定义框架中应用程序的访问捆绑包标识符

时间:2019-05-13 11:32:05

标签: ios swift frameworks bundle-identifier

我正在设计一个SDK,在某个时间点我要进行一些URL调用。为此,我需要正在打电话的应用程序的上下文。作为上下文,我想使用该sdk传递应用程序的捆绑包标识符。

SDK采用库的形式,某些第三方应用程序将导入并使用该库。我有UIViewController的引用,该引用正在第三方应用程序中调用url调用。我不知道是否只有UIViewController引用就足够了。

那么我如何获得他们应用程序的捆绑包标识符?

谢谢

1 个答案:

答案 0 :(得分:1)

非常简单

// VC is ref to the class object of the main app

// This will give the class type of the object
let objectType = type(of: vc) 

//This will get you the bundle of the main app
let bundle = Bundle(for: objectType.self)

// This will finally give you the bundle
let bundleId = bundle.bundleIdentifier
相关问题