Preferencepane version instead of systempreferences version

Hi.
Im trying to get the version of my preferencepane that i built in swift. But all i can get is the systempreferences app version, thats not very helpful in knowing what pane version is being used.

Im guessing there is a key for the actual pane bundleverion i can use, but i cannot find it with my googlefo.

Any suggestions?

I tried this so far:

Code Block  
textPaneVersion.stringValue = Bundle.main.object(forInfoDictionaryKey: kCFBundleVersionKey as String) as! String
textPaneVersion.stringValue = Bundle.main.infoDictionary?["CFBundleVersion"] as! String
textPaneVersion.stringValue = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String


Answered by najken in 676503022

Solved it, replace:

textPaneVersion.stringValue = Bundle.main.object(forInfoDictionaryKey: kCFBundleVersionKey as String) as! String

With:

textPaneVersion.stringValue = self.bundle.object(forInfoDictionaryKey: kCFBundleVersionKey as String) as! String
It's not clear what you are looking for.
Is it iOS or MacOS ?

Im trying to get the version of my preferencepane that i built in swift

key for the actual pane bundleverion

  • What do you get ?

  • What did you expect ?

Is it the build number ?
Then, call
Code Block
        let build = Bundle.main.infoDictionary!["CFBundleVersion"] as! String

Could you show the complete code for your preference Pane ?

Note: the build version is probably only useful from inside the app.
If so, did you see this notice:
https://developer.apple.com/documentation/preferencepanes

Note
Use preference pane bundles only for settings that must be managed separately from your app. For example, use it to manage settings that are shared between multiple apps in the same suite. Manage app-specific preferences using a custom preferences interface.


Hi, sorry for my late reply, I made a repo on github, with the expected result as well as actual result.

Code Block
textPaneVersion.stringValue = Bundle.main.infoDictionary!["CFBundleVersion"] as! String

Gave the result of 14.0, that's not anywhere in my project versions, my project version is 1.0. So its using system preferences version instead of my pane version.

Screenshots available on my GitHub:
testpane
Accepted Answer

Solved it, replace:

textPaneVersion.stringValue = Bundle.main.object(forInfoDictionaryKey: kCFBundleVersionKey as String) as! String

With:

textPaneVersion.stringValue = self.bundle.object(forInfoDictionaryKey: kCFBundleVersionKey as String) as! String
Preferencepane version instead of systempreferences version
 
 
Q