diff --git a/Common/Extensions/NSBundle.swift b/Common/Extensions/NSBundle.swift index 1d4873224e..5974614d47 100644 --- a/Common/Extensions/NSBundle.swift +++ b/Common/Extensions/NSBundle.swift @@ -53,47 +53,6 @@ extension Bundle { } } - var gitRevision: String? { - return object(forInfoDictionaryKey: "com-loopkit-Loop-git-revision") as? String - } - - var gitBranch: String? { - return object(forInfoDictionaryKey: "com-loopkit-Loop-git-branch") as? String - } - - var sourceRoot: String? { - return object(forInfoDictionaryKey: "com-loopkit-Loop-srcroot") as? String - } - - var buildDateString: String? { - return object(forInfoDictionaryKey: "com-loopkit-Loop-build-date") as? String - } - - var xcodeVersion: String? { - return object(forInfoDictionaryKey: "com-loopkit-Loop-xcode-version") as? String - } - - var profileExpiration: Date? { - return object(forInfoDictionaryKey: "com-loopkit-Loop-profile-expiration") as? Date - } - - var profileExpirationString: String { - if let profileExpiration = profileExpiration { - return "\(profileExpiration)" - } else { - return "N/A" - } - } - - // These strings are only configured if it is a workspace build - var workspaceGitRevision: String? { - return object(forInfoDictionaryKey: "com-loopkit-LoopWorkspace-git-revision") as? String - } - - var workspaceGitBranch: String? { - return object(forInfoDictionaryKey: "com-loopkit-LoopWorkspace-git-branch") as? String - } - var localCacheDuration: TimeInterval { guard let localCacheDurationDaysString = object(forInfoDictionaryKey: "LoopLocalCacheDurationDays") as? String, let localCacheDurationDays = Double(localCacheDurationDaysString) else { diff --git a/Common/Models/BuildDetails.swift b/Common/Models/BuildDetails.swift new file mode 100644 index 0000000000..63517e7e79 --- /dev/null +++ b/Common/Models/BuildDetails.swift @@ -0,0 +1,69 @@ +// +// BuildDetails.swift +// Loop +// +// Created by Pete Schwamb on 6/13/23. +// Copyright © 2023 LoopKit Authors. All rights reserved. +// + +import Foundation + +class BuildDetails { + + static var `default` = BuildDetails() + + let dict: [String: Any] + + init() { + guard let url = Bundle.main.url(forResource: "BuildDetails", withExtension: ".plist"), + let data = try? Data(contentsOf: url), + let parsed = try? PropertyListSerialization.propertyList(from: data, format: nil) as? [String: Any] else + { + dict = [:] + return + } + dict = parsed + } + + var buildDateString: String? { + return dict["com-loopkit-Loop-build-date"] as? String + } + + var xcodeVersion: String? { + return dict["com-loopkit-Loop-xcode-version"] as? String + } + + var gitRevision: String? { + return dict["com-loopkit-Loop-git-revision"] as? String + } + + var gitBranch: String? { + return dict["com-loopkit-Loop-git-branch"] as? String + } + + var sourceRoot: String? { + return dict["com-loopkit-Loop-srcroot"] as? String + } + + var profileExpiration: Date? { + return dict["com-loopkit-Loop-profile-expiration"] as? Date + } + + var profileExpirationString: String { + if let profileExpiration = profileExpiration { + return "\(profileExpiration)" + } else { + return "N/A" + } + } + + // These strings are only configured if it is a workspace build + var workspaceGitRevision: String? { + return dict["com-loopkit-LoopWorkspace-git-revision"] as? String + } + + var workspaceGitBranch: String? { + return dict["com-loopkit-LoopWorkspace-git-branch"] as? String + } +} + diff --git a/Loop.xcodeproj/project.pbxproj b/Loop.xcodeproj/project.pbxproj index 31b6ebff59..15b74d6643 100644 --- a/Loop.xcodeproj/project.pbxproj +++ b/Loop.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 52; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -438,6 +438,8 @@ C11B9D64286779C000500CF8 /* MockKitUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C11B9D61286779C000500CF8 /* MockKitUI.framework */; }; C11B9D65286779C000500CF8 /* MockKitUI.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C11B9D61286779C000500CF8 /* MockKitUI.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; C11BD0552523CFED00236B08 /* SimpleBolusViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C11BD0542523CFED00236B08 /* SimpleBolusViewModel.swift */; }; + C11C5D152ABA0B38004BD0B5 /* BuildDetails.swift in Sources */ = {isa = PBXBuildFile; fileRef = C11C5D142ABA0B38004BD0B5 /* BuildDetails.swift */; }; + C11C5D172ABA2988004BD0B5 /* BuildDetails.plist in Resources */ = {isa = PBXBuildFile; fileRef = C11C5D162ABA2988004BD0B5 /* BuildDetails.plist */; }; C11C87DE1E21EAAD00BB71D3 /* HKUnit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F526D5E1DF2459000A04910 /* HKUnit.swift */; }; C1201E2C23ECDBD0002DA84A /* WatchContextRequestUserInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1201E2B23ECDBD0002DA84A /* WatchContextRequestUserInfo.swift */; }; C1201E2D23ECDF3D002DA84A /* WatchContextRequestUserInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1201E2B23ECDBD0002DA84A /* WatchContextRequestUserInfo.swift */; }; @@ -1482,6 +1484,8 @@ C11B9D60286779C000500CF8 /* MockKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MockKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; C11B9D61286779C000500CF8 /* MockKitUI.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MockKitUI.framework; sourceTree = BUILT_PRODUCTS_DIR; }; C11BD0542523CFED00236B08 /* SimpleBolusViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimpleBolusViewModel.swift; sourceTree = ""; }; + C11C5D142ABA0B38004BD0B5 /* BuildDetails.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BuildDetails.swift; sourceTree = ""; }; + C11C5D162ABA2988004BD0B5 /* BuildDetails.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = BuildDetails.plist; sourceTree = ""; }; C1201E2B23ECDBD0002DA84A /* WatchContextRequestUserInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WatchContextRequestUserInfo.swift; sourceTree = ""; }; C121D8CF29C7866D00DA0520 /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = cs; path = cs.lproj/Main.strings; sourceTree = ""; }; C121D8D029C7866D00DA0520 /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = cs; path = cs.lproj/Localizable.strings; sourceTree = ""; }; @@ -2110,6 +2114,7 @@ 7D7076511FE06EE1004AC8EA /* InfoPlist.strings */, 43EDEE6B1CF2E12A00393BE3 /* Loop.entitlements */, 43F5C2D41B92A4A6003EB13D /* Info.plist */, + C11C5D162ABA2988004BD0B5 /* BuildDetails.plist */, 43776F8F1B8022E90074EA36 /* AppDelegate.swift */, 1D12D3B82548EFDD00B53E8B /* main.swift */, 43776F9A1B8022E90074EA36 /* LaunchScreen.storyboard */, @@ -2618,6 +2623,7 @@ 4F11D3C120DD80B3006E072C /* WatchHistoricalGlucose.swift */, 4F7E8AC620E2AC0300AEA65E /* WatchPredictedGlucose.swift */, E9B08020253BBDE900BAD8F8 /* IntentExtensionInfo.swift */, + C11C5D142ABA0B38004BD0B5 /* BuildDetails.swift */, ); path = Models; sourceTree = ""; @@ -3497,6 +3503,7 @@ buildActionMask = 2147483647; files = ( C13255D6223E7BE2008AF50C /* BolusProgressTableViewCell.xib in Resources */, + C11C5D172ABA2988004BD0B5 /* BuildDetails.plist in Resources */, 43FCBBC21E51710B00343C1B /* LaunchScreen.storyboard in Resources */, B405E35A24D2B1A400DD058D /* HUDAssets.xcassets in Resources */, A966152623EA5A26005D8B29 /* DefaultAssets.xcassets in Resources */, @@ -3703,7 +3710,6 @@ inputFileListPaths = ( ); inputPaths = ( - "${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}", ); name = "Capture Build Details"; outputFileListPaths = ( @@ -3870,6 +3876,7 @@ 1D82E6A025377C6B009131FB /* TrustedTimeChecker.swift in Sources */, A98556852493F901000FD662 /* AlertStore+SimulatedCoreData.swift in Sources */, 899433B823FE129800FA4BEA /* OverrideBadgeView.swift in Sources */, + C11C5D152ABA0B38004BD0B5 /* BuildDetails.swift in Sources */, 89D1503E24B506EB00EDE253 /* Dictionary.swift in Sources */, A96DAC2C2838F31200D94E38 /* SharedLogging.swift in Sources */, 4302F4E31D4EA54200F0FCAF /* InsulinDeliveryTableViewController.swift in Sources */, diff --git a/Loop/BuildDetails.plist b/Loop/BuildDetails.plist new file mode 100644 index 0000000000..fe23d977d4 --- /dev/null +++ b/Loop/BuildDetails.plist @@ -0,0 +1,12 @@ + + + + + + diff --git a/Loop/Managers/DeviceDataManager.swift b/Loop/Managers/DeviceDataManager.swift index 96452b2e29..4e1cbfdf1d 100644 --- a/Loop/Managers/DeviceDataManager.swift +++ b/Loop/Managers/DeviceDataManager.swift @@ -677,14 +677,14 @@ final class DeviceDataManager { let report = [ "## Build Details", "* appNameAndVersion: \(Bundle.main.localizedNameAndVersion)", - "* profileExpiration: \(Bundle.main.profileExpirationString)", - "* gitRevision: \(Bundle.main.gitRevision ?? "N/A")", - "* gitBranch: \(Bundle.main.gitBranch ?? "N/A")", - "* workspaceGitRevision: \(Bundle.main.workspaceGitRevision ?? "N/A")", - "* workspaceGitBranch: \(Bundle.main.workspaceGitBranch ?? "N/A")", - "* sourceRoot: \(Bundle.main.sourceRoot ?? "N/A")", - "* buildDateString: \(Bundle.main.buildDateString ?? "N/A")", - "* xcodeVersion: \(Bundle.main.xcodeVersion ?? "N/A")", + "* profileExpiration: \(BuildDetails.default.profileExpirationString)", + "* gitRevision: \(BuildDetails.default.gitRevision ?? "N/A")", + "* gitBranch: \(BuildDetails.default.gitBranch ?? "N/A")", + "* workspaceGitRevision: \(BuildDetails.default.workspaceGitRevision ?? "N/A")", + "* workspaceGitBranch: \(BuildDetails.default.workspaceGitBranch ?? "N/A")", + "* sourceRoot: \(BuildDetails.default.sourceRoot ?? "N/A")", + "* buildDateString: \(BuildDetails.default.buildDateString ?? "N/A")", + "* xcodeVersion: \(BuildDetails.default.xcodeVersion ?? "N/A")", "", "## FeatureFlags", "\(FeatureFlags)", @@ -1673,7 +1673,7 @@ extension GlucoseStore : CGMStalenessMonitorDelegate { } extension DeviceDataManager: SupportInfoProvider { private var branchNameIfNotReleaseBranch: String? { - return Bundle.main.gitBranch.filter { branch in + return BuildDetails.default.gitBranch.filter { branch in return branch != "" && branch != "main" && branch != "master" && diff --git a/Loop/Managers/LoopAppManager.swift b/Loop/Managers/LoopAppManager.swift index 6a160790ab..b50093d293 100644 --- a/Loop/Managers/LoopAppManager.swift +++ b/Loop/Managers/LoopAppManager.swift @@ -226,7 +226,7 @@ class LoopAppManager: NSObject { analyticsServicesManager.identifyAppName(Bundle.main.bundleDisplayName) - if let workspaceGitRevision = Bundle.main.workspaceGitRevision { + if let workspaceGitRevision = BuildDetails.default.workspaceGitRevision { analyticsServicesManager.identifyWorkspaceGitRevision(workspaceGitRevision) } diff --git a/Loop/Managers/ProfileExpirationAlerter.swift b/Loop/Managers/ProfileExpirationAlerter.swift index a28d452783..3aa742732b 100644 --- a/Loop/Managers/ProfileExpirationAlerter.swift +++ b/Loop/Managers/ProfileExpirationAlerter.swift @@ -20,7 +20,7 @@ class ProfileExpirationAlerter { let now = Date() - guard let profileExpiration = Bundle.main.profileExpiration, now > profileExpiration - expirationAlertWindow else { + guard let profileExpiration = BuildDetails.default.profileExpiration, now > profileExpiration - expirationAlertWindow else { return } diff --git a/Loop/Views/SettingsView.swift b/Loop/Views/SettingsView.swift index 90859273e3..8fca56689b 100644 --- a/Loop/Views/SettingsView.swift +++ b/Loop/Views/SettingsView.swift @@ -58,7 +58,7 @@ public struct SettingsView: View { servicesSection } supportSection - if let profileExpiration = Bundle.main.profileExpiration, FeatureFlags.profileExpirationSettingsViewEnabled { + if let profileExpiration = BuildDetails.default.profileExpiration, FeatureFlags.profileExpirationSettingsViewEnabled { profileExpirationSection(profileExpiration: profileExpiration) } } diff --git a/Scripts/capture-build-details.sh b/Scripts/capture-build-details.sh index 7543ec579c..6122592374 100755 --- a/Scripts/capture-build-details.sh +++ b/Scripts/capture-build-details.sh @@ -10,11 +10,9 @@ SCRIPT_DIRECTORY="$(dirname "${0}")" error() { echo "ERROR: ${*}" >&2 - echo "Usage: ${SCRIPT} [-r|--git-source-root git-source-root] [-p|--provisioning-profile-path provisioning-profile-path] [-i|--info-plist-path info-plist-path]" >&2 + echo "Usage: ${SCRIPT} [-r|--git-source-root git-source-root] [-p|--provisioning-profile-path provisioning-profile-path]" >&2 echo "Parameters:" >&2 - echo " -r|--git-source-root root location of git repository to gather information from; optional, defaults to \${WORKSPACE_ROOT} if present, otherwise defaults to \${SRCROOT}" >&2 echo " -p|--provisioning-profile-path path to the .mobileprovision provisioning profile file to check for expiration; optional, defaults to \${HOME}/Library/MobileDevice/Provisioning Profiles/\${EXPANDED_PROVISIONING_PROFILE}.mobileprovision" >&2 - echo " -i|--info-plist-path path to the Info.plist file to modify; optional, defaults to \${BUILT_PRODUCTS_DIR}/\${INFOPLIST_PATH}" >&2 exit 1 } @@ -26,17 +24,12 @@ info() { echo "INFO: ${*}" >&2 } -git_source_root="${WORKSPACE_ROOT:-${SRCROOT}}" -info_plist_path="${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}" +info_plist_path="${BUILT_PRODUCTS_DIR}/${CONTENTS_FOLDER_PATH}/BuildDetails.plist" provisioning_profile_path="${HOME}/Library/MobileDevice/Provisioning Profiles/${EXPANDED_PROVISIONING_PROFILE}.mobileprovision" xcode_build_version=${XCODE_PRODUCT_BUILD_VERSION:-$(xcodebuild -version | grep version | cut -d ' ' -f 3)} while [[ $# -gt 0 ]] do case $1 in - -r|--git-source-root) - git_source_root="${2}" - shift 2 - ;; -i|--info-plist-path) info_plist_path="${2}" shift 2 @@ -52,16 +45,12 @@ if [ ${#} -ne 0 ]; then error "Unexpected arguments: ${*}" fi -if [ -z "${git_source_root}" ]; then - error "Must provide one of --git-source-root, \${WORKSPACE_ROOT}, or \${SRCROOT}." -fi - if [ "${info_plist_path}" == "/" -o ! -e "${info_plist_path}" ]; then - error "Must provide valid --info-plist-path, or have valid \${BUILT_PRODUCTS_DIR} and \${INFOPLIST_PATH} set." + error "File does not exist: ${info_plist_path}" + #error "Must provide valid --info-plist-path, or have valid \${BUILT_PRODUCTS_DIR} and \${INFOPLIST_PATH} set." fi -info "Gathering build details in ${git_source_root}" -cd "${git_source_root}" +info "Gathering build details in ${PWD}" if [ -e .git ]; then rev=$(git rev-parse HEAD) @@ -74,7 +63,7 @@ if [ -e .git ]; then fi fi -plutil -replace com-loopkit-Loop-srcroot -string "${git_source_root}" "${info_plist_path}" +plutil -replace com-loopkit-Loop-srcroot -string "${PWD}" "${info_plist_path}" plutil -replace com-loopkit-Loop-build-date -string "$(date)" "${info_plist_path}" plutil -replace com-loopkit-Loop-xcode-version -string "${xcode_build_version}" "${info_plist_path}" @@ -89,7 +78,7 @@ fi # determine if this is a workspace build # if so, fill out the git revision and branch -if [ -e ../LoopWorkspace.xcworkspace ] +if [ -e ../.git ] then pushd . > /dev/null cd .. diff --git a/Version.xcconfig b/Version.xcconfig index fadcd37ef5..69e2b6349d 100644 --- a/Version.xcconfig +++ b/Version.xcconfig @@ -7,7 +7,7 @@ // // Version [DEFAULT] -LOOP_MARKETING_VERSION = 3.2.2 +LOOP_MARKETING_VERSION = 3.2.3 CURRENT_PROJECT_VERSION = 57 // Optional override