2

I want to programmatically access the version and build information that is contained in MyFramework.framework at runtime.

I found some solutions here but they don't work. After translating to Swift 3, I find that Bundle.main.infoDictionary is empty.

How can I get this information?

Community
  • 1
  • 1
Raphael
  • 8,276
  • 4
  • 58
  • 91
  • 1
    Related: [Loading a resource (e.g. storyboard) in a Swift framework](http://stackoverflow.com/questions/24982848/loading-a-resource-e-g-storyboard-in-a-swift-framework). – Martin R May 21 '17 at 20:09

1 Answers1

5

It seems that the "main" bundle is reserved for app(lication)s. Loading a bundle for a framework class, that is

Bundle(for: MyClass.self)

works; its infoDictionary contains the expected values for keys "CFBundleShortVersionString" (version) and "CFBundleVersion" (build).

Raphael
  • 8,276
  • 4
  • 58
  • 91
  • To do: verify that the information is still there and correct if the code is run from an application context, not from within tests for the the framework on its own. – Raphael May 21 '17 at 19:31