Created
January 25, 2021 16:33
-
-
Save drewster99/cd978cf3ca9cf7d24eab2409789a702a to your computer and use it in GitHub Desktop.
Swift iOS Xcode get and print all dynamic framework versions at runtime
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// iosFrameworkVersions.swift | |
// | |
// Created by Andrew Benson (@DrewsterBenson) on 1/11/2021. | |
// Copyright (C) 2021 Andrew Benson. | |
// License: MIT (https://opensource.org/licenses/MIT) | |
// | |
// Stick in AppDelegate to dump all your (non-Apple) framework versions, like this: | |
// | |
// Framework versions: | |
// Alamofire -- 4.9.0(1) | |
// AlamofireImage -- 3.6.0(1) | |
// Apollo -- 0.19.1(0.19.1) | |
// | |
print("Framework versions:") | |
let frameworks = Bundle.allFrameworks.filter { (f) -> Bool in | |
f.bundleIdentifier?.hasPrefix("com.apple.") == false | |
}.sorted { (a, b) -> Bool in | |
a.bundleURL.lastPathComponent < b.bundleURL.lastPathComponent | |
} | |
for framework in frameworks { | |
let nameToUse = framework.infoDictionary?[kCFBundleNameKey as String] as? String ?? framework.bundleURL.lastPathComponent | |
let short = framework.infoDictionary?["CFBundleShortVersionString"] as? String ?? "n/a" | |
let version = framework.infoDictionary?[kCFBundleVersionKey as String] as? String ?? "n/a" | |
let versionToUse = "\(short)(\(version))" | |
print(" \(nameToUse) -- \(versionToUse)") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment