From 4dd121f961189e92e60b4100843c0c8352048acc Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 25 May 2023 14:34:22 -0500 Subject: [PATCH] updated version Signed-off-by: Matt Bruce --- VDSSample.xcodeproj/project.pbxproj | 4 +- .../ViewControllers/MenuViewController.swift | 38 +++++++++++-------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/VDSSample.xcodeproj/project.pbxproj b/VDSSample.xcodeproj/project.pbxproj index 93bfb3b..4122d31 100644 --- a/VDSSample.xcodeproj/project.pbxproj +++ b/VDSSample.xcodeproj/project.pbxproj @@ -650,7 +650,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 17; + CURRENT_PROJECT_VERSION = 18; DEVELOPMENT_TEAM = 59V5935DHZ; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = VDSSample/Info.plist; @@ -680,7 +680,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 17; + CURRENT_PROJECT_VERSION = 18; DEVELOPMENT_TEAM = 59V5935DHZ; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = VDSSample/Info.plist; diff --git a/VDSSample/ViewControllers/MenuViewController.swift b/VDSSample/ViewControllers/MenuViewController.swift index cf82f54..5063362 100644 --- a/VDSSample/ViewControllers/MenuViewController.swift +++ b/VDSSample/ViewControllers/MenuViewController.swift @@ -65,27 +65,17 @@ class MenuCell: UITableViewCell { class MenuViewController: UITableViewController, TooltipLaunchable { override func viewDidLoad() { - title = "VDS Sample: Build \(Bundle.main.buildNumber ?? "none")" + title = "VDS Sample: Build \(Bundle.main.build ?? "none")" let tooltip = VDS.Tooltip() - tooltip.title = "Release Notes" - tooltip.content = getReleaseNotes() + let bundle = VDS.Bundle(for: VDS.Badge.self) + tooltip.title = "Release Notes: \(bundle.build ?? "")" + tooltip.content = bundle.contents("ReleaseNotes") navigationItem.rightBarButtonItem = UIBarButtonItem(customView: tooltip) // UIBarButtonItem(barButtonSystemItem: .compose, target: self, action: #selector(buildInfoTapped)) super.viewDidLoad() overrideUserInterfaceStyle = .light tableView.register(MenuCell.self, forCellReuseIdentifier: "cell") } - - func getReleaseNotes() -> String { - let bundle = VDS.Bundle(for: VDS.Badge.self) - guard let fileURL = bundle.url(forResource: "ReleaseNotes", withExtension: "txt") else { return "none" } - do { - return try String(contentsOf: fileURL) - } catch { - print("error reading releaseNotes") - return "none" - } - } - + let items: [MenuComponent] = [ MenuComponent(title: "Badge", completed: true, viewController: BadgeViewController.self), MenuComponent(title: "Button", completed: true, viewController: ButtonViewController.self), @@ -169,7 +159,25 @@ class MenuViewController: UITableViewController, TooltipLaunchable { } extension Bundle { + var versionNumber: String? { + infoDictionary?["CFBundleShortVersionString"] as? String + } var buildNumber: String? { infoDictionary?["CFBundleVersion"] as? String } + + var build: String? { + guard let versionNumber, let buildNumber else { return nil } + return "\(versionNumber).\(buildNumber)" + } + + func contents(_ fileName: String, fileExtension: String = "txt" ) -> String { + guard let fileURL = url(forResource: fileName, withExtension: fileExtension) else { return "none" } + do { + return try String(contentsOf: fileURL) + } catch { + print("error reading releaseNotes") + return "none" + } + } }