Skip to content

Commit c6b058b

Browse files
authored
Merge pull request #2069 from LoopKit/xcode-15-main
Backport cyclic dependency fixes from dev for building on Xcode 15
2 parents befcbcb + 976c9fc commit c6b058b

10 files changed

+110
-74
lines changed

Common/Extensions/NSBundle.swift

-41
Original file line numberDiff line numberDiff line change
@@ -53,47 +53,6 @@ extension Bundle {
5353
}
5454
}
5555

56-
var gitRevision: String? {
57-
return object(forInfoDictionaryKey: "com-loopkit-Loop-git-revision") as? String
58-
}
59-
60-
var gitBranch: String? {
61-
return object(forInfoDictionaryKey: "com-loopkit-Loop-git-branch") as? String
62-
}
63-
64-
var sourceRoot: String? {
65-
return object(forInfoDictionaryKey: "com-loopkit-Loop-srcroot") as? String
66-
}
67-
68-
var buildDateString: String? {
69-
return object(forInfoDictionaryKey: "com-loopkit-Loop-build-date") as? String
70-
}
71-
72-
var xcodeVersion: String? {
73-
return object(forInfoDictionaryKey: "com-loopkit-Loop-xcode-version") as? String
74-
}
75-
76-
var profileExpiration: Date? {
77-
return object(forInfoDictionaryKey: "com-loopkit-Loop-profile-expiration") as? Date
78-
}
79-
80-
var profileExpirationString: String {
81-
if let profileExpiration = profileExpiration {
82-
return "\(profileExpiration)"
83-
} else {
84-
return "N/A"
85-
}
86-
}
87-
88-
// These strings are only configured if it is a workspace build
89-
var workspaceGitRevision: String? {
90-
return object(forInfoDictionaryKey: "com-loopkit-LoopWorkspace-git-revision") as? String
91-
}
92-
93-
var workspaceGitBranch: String? {
94-
return object(forInfoDictionaryKey: "com-loopkit-LoopWorkspace-git-branch") as? String
95-
}
96-
9756
var localCacheDuration: TimeInterval {
9857
guard let localCacheDurationDaysString = object(forInfoDictionaryKey: "LoopLocalCacheDurationDays") as? String,
9958
let localCacheDurationDays = Double(localCacheDurationDaysString) else {

Common/Models/BuildDetails.swift

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
//
2+
// BuildDetails.swift
3+
// Loop
4+
//
5+
// Created by Pete Schwamb on 6/13/23.
6+
// Copyright © 2023 LoopKit Authors. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
class BuildDetails {
12+
13+
static var `default` = BuildDetails()
14+
15+
let dict: [String: Any]
16+
17+
init() {
18+
guard let url = Bundle.main.url(forResource: "BuildDetails", withExtension: ".plist"),
19+
let data = try? Data(contentsOf: url),
20+
let parsed = try? PropertyListSerialization.propertyList(from: data, format: nil) as? [String: Any] else
21+
{
22+
dict = [:]
23+
return
24+
}
25+
dict = parsed
26+
}
27+
28+
var buildDateString: String? {
29+
return dict["com-loopkit-Loop-build-date"] as? String
30+
}
31+
32+
var xcodeVersion: String? {
33+
return dict["com-loopkit-Loop-xcode-version"] as? String
34+
}
35+
36+
var gitRevision: String? {
37+
return dict["com-loopkit-Loop-git-revision"] as? String
38+
}
39+
40+
var gitBranch: String? {
41+
return dict["com-loopkit-Loop-git-branch"] as? String
42+
}
43+
44+
var sourceRoot: String? {
45+
return dict["com-loopkit-Loop-srcroot"] as? String
46+
}
47+
48+
var profileExpiration: Date? {
49+
return dict["com-loopkit-Loop-profile-expiration"] as? Date
50+
}
51+
52+
var profileExpirationString: String {
53+
if let profileExpiration = profileExpiration {
54+
return "\(profileExpiration)"
55+
} else {
56+
return "N/A"
57+
}
58+
}
59+
60+
// These strings are only configured if it is a workspace build
61+
var workspaceGitRevision: String? {
62+
return dict["com-loopkit-LoopWorkspace-git-revision"] as? String
63+
}
64+
65+
var workspaceGitBranch: String? {
66+
return dict["com-loopkit-LoopWorkspace-git-branch"] as? String
67+
}
68+
}
69+

Loop.xcodeproj/project.pbxproj

+9-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 52;
6+
objectVersion = 54;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -438,6 +438,8 @@
438438
C11B9D64286779C000500CF8 /* MockKitUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C11B9D61286779C000500CF8 /* MockKitUI.framework */; };
439439
C11B9D65286779C000500CF8 /* MockKitUI.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C11B9D61286779C000500CF8 /* MockKitUI.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
440440
C11BD0552523CFED00236B08 /* SimpleBolusViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C11BD0542523CFED00236B08 /* SimpleBolusViewModel.swift */; };
441+
C11C5D152ABA0B38004BD0B5 /* BuildDetails.swift in Sources */ = {isa = PBXBuildFile; fileRef = C11C5D142ABA0B38004BD0B5 /* BuildDetails.swift */; };
442+
C11C5D172ABA2988004BD0B5 /* BuildDetails.plist in Resources */ = {isa = PBXBuildFile; fileRef = C11C5D162ABA2988004BD0B5 /* BuildDetails.plist */; };
441443
C11C87DE1E21EAAD00BB71D3 /* HKUnit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F526D5E1DF2459000A04910 /* HKUnit.swift */; };
442444
C1201E2C23ECDBD0002DA84A /* WatchContextRequestUserInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1201E2B23ECDBD0002DA84A /* WatchContextRequestUserInfo.swift */; };
443445
C1201E2D23ECDF3D002DA84A /* WatchContextRequestUserInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1201E2B23ECDBD0002DA84A /* WatchContextRequestUserInfo.swift */; };
@@ -1482,6 +1484,8 @@
14821484
C11B9D60286779C000500CF8 /* MockKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MockKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
14831485
C11B9D61286779C000500CF8 /* MockKitUI.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MockKitUI.framework; sourceTree = BUILT_PRODUCTS_DIR; };
14841486
C11BD0542523CFED00236B08 /* SimpleBolusViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimpleBolusViewModel.swift; sourceTree = "<group>"; };
1487+
C11C5D142ABA0B38004BD0B5 /* BuildDetails.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BuildDetails.swift; sourceTree = "<group>"; };
1488+
C11C5D162ABA2988004BD0B5 /* BuildDetails.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = BuildDetails.plist; sourceTree = "<group>"; };
14851489
C1201E2B23ECDBD0002DA84A /* WatchContextRequestUserInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WatchContextRequestUserInfo.swift; sourceTree = "<group>"; };
14861490
C121D8CF29C7866D00DA0520 /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = cs; path = cs.lproj/Main.strings; sourceTree = "<group>"; };
14871491
C121D8D029C7866D00DA0520 /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = cs; path = cs.lproj/Localizable.strings; sourceTree = "<group>"; };
@@ -2110,6 +2114,7 @@
21102114
7D7076511FE06EE1004AC8EA /* InfoPlist.strings */,
21112115
43EDEE6B1CF2E12A00393BE3 /* Loop.entitlements */,
21122116
43F5C2D41B92A4A6003EB13D /* Info.plist */,
2117+
C11C5D162ABA2988004BD0B5 /* BuildDetails.plist */,
21132118
43776F8F1B8022E90074EA36 /* AppDelegate.swift */,
21142119
1D12D3B82548EFDD00B53E8B /* main.swift */,
21152120
43776F9A1B8022E90074EA36 /* LaunchScreen.storyboard */,
@@ -2618,6 +2623,7 @@
26182623
4F11D3C120DD80B3006E072C /* WatchHistoricalGlucose.swift */,
26192624
4F7E8AC620E2AC0300AEA65E /* WatchPredictedGlucose.swift */,
26202625
E9B08020253BBDE900BAD8F8 /* IntentExtensionInfo.swift */,
2626+
C11C5D142ABA0B38004BD0B5 /* BuildDetails.swift */,
26212627
);
26222628
path = Models;
26232629
sourceTree = "<group>";
@@ -3497,6 +3503,7 @@
34973503
buildActionMask = 2147483647;
34983504
files = (
34993505
C13255D6223E7BE2008AF50C /* BolusProgressTableViewCell.xib in Resources */,
3506+
C11C5D172ABA2988004BD0B5 /* BuildDetails.plist in Resources */,
35003507
43FCBBC21E51710B00343C1B /* LaunchScreen.storyboard in Resources */,
35013508
B405E35A24D2B1A400DD058D /* HUDAssets.xcassets in Resources */,
35023509
A966152623EA5A26005D8B29 /* DefaultAssets.xcassets in Resources */,
@@ -3703,7 +3710,6 @@
37033710
inputFileListPaths = (
37043711
);
37053712
inputPaths = (
3706-
"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}",
37073713
);
37083714
name = "Capture Build Details";
37093715
outputFileListPaths = (
@@ -3870,6 +3876,7 @@
38703876
1D82E6A025377C6B009131FB /* TrustedTimeChecker.swift in Sources */,
38713877
A98556852493F901000FD662 /* AlertStore+SimulatedCoreData.swift in Sources */,
38723878
899433B823FE129800FA4BEA /* OverrideBadgeView.swift in Sources */,
3879+
C11C5D152ABA0B38004BD0B5 /* BuildDetails.swift in Sources */,
38733880
89D1503E24B506EB00EDE253 /* Dictionary.swift in Sources */,
38743881
A96DAC2C2838F31200D94E38 /* SharedLogging.swift in Sources */,
38753882
4302F4E31D4EA54200F0FCAF /* InsulinDeliveryTableViewController.swift in Sources */,

Loop/BuildDetails.plist

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<!--
4+
BuildDetails.plist
5+
Loop
6+
7+
Created by Pete Schwamb on 6/13/23.
8+
Copyright (c) 2023 LoopKit Authors. All rights reserved.
9+
-->
10+
<plist version="1.0">
11+
<dict/>
12+
</plist>

Loop/Managers/DeviceDataManager.swift

+9-9
Original file line numberDiff line numberDiff line change
@@ -677,14 +677,14 @@ final class DeviceDataManager {
677677
let report = [
678678
"## Build Details",
679679
"* appNameAndVersion: \(Bundle.main.localizedNameAndVersion)",
680-
"* profileExpiration: \(Bundle.main.profileExpirationString)",
681-
"* gitRevision: \(Bundle.main.gitRevision ?? "N/A")",
682-
"* gitBranch: \(Bundle.main.gitBranch ?? "N/A")",
683-
"* workspaceGitRevision: \(Bundle.main.workspaceGitRevision ?? "N/A")",
684-
"* workspaceGitBranch: \(Bundle.main.workspaceGitBranch ?? "N/A")",
685-
"* sourceRoot: \(Bundle.main.sourceRoot ?? "N/A")",
686-
"* buildDateString: \(Bundle.main.buildDateString ?? "N/A")",
687-
"* xcodeVersion: \(Bundle.main.xcodeVersion ?? "N/A")",
680+
"* profileExpiration: \(BuildDetails.default.profileExpirationString)",
681+
"* gitRevision: \(BuildDetails.default.gitRevision ?? "N/A")",
682+
"* gitBranch: \(BuildDetails.default.gitBranch ?? "N/A")",
683+
"* workspaceGitRevision: \(BuildDetails.default.workspaceGitRevision ?? "N/A")",
684+
"* workspaceGitBranch: \(BuildDetails.default.workspaceGitBranch ?? "N/A")",
685+
"* sourceRoot: \(BuildDetails.default.sourceRoot ?? "N/A")",
686+
"* buildDateString: \(BuildDetails.default.buildDateString ?? "N/A")",
687+
"* xcodeVersion: \(BuildDetails.default.xcodeVersion ?? "N/A")",
688688
"",
689689
"## FeatureFlags",
690690
"\(FeatureFlags)",
@@ -1673,7 +1673,7 @@ extension GlucoseStore : CGMStalenessMonitorDelegate { }
16731673
extension DeviceDataManager: SupportInfoProvider {
16741674

16751675
private var branchNameIfNotReleaseBranch: String? {
1676-
return Bundle.main.gitBranch.filter { branch in
1676+
return BuildDetails.default.gitBranch.filter { branch in
16771677
return branch != "" &&
16781678
branch != "main" &&
16791679
branch != "master" &&

Loop/Managers/LoopAppManager.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ class LoopAppManager: NSObject {
226226

227227
analyticsServicesManager.identifyAppName(Bundle.main.bundleDisplayName)
228228

229-
if let workspaceGitRevision = Bundle.main.workspaceGitRevision {
229+
if let workspaceGitRevision = BuildDetails.default.workspaceGitRevision {
230230
analyticsServicesManager.identifyWorkspaceGitRevision(workspaceGitRevision)
231231
}
232232

Loop/Managers/ProfileExpirationAlerter.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ProfileExpirationAlerter {
2020

2121
let now = Date()
2222

23-
guard let profileExpiration = Bundle.main.profileExpiration, now > profileExpiration - expirationAlertWindow else {
23+
guard let profileExpiration = BuildDetails.default.profileExpiration, now > profileExpiration - expirationAlertWindow else {
2424
return
2525
}
2626

Loop/Views/SettingsView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public struct SettingsView: View {
5858
servicesSection
5959
}
6060
supportSection
61-
if let profileExpiration = Bundle.main.profileExpiration, FeatureFlags.profileExpirationSettingsViewEnabled {
61+
if let profileExpiration = BuildDetails.default.profileExpiration, FeatureFlags.profileExpirationSettingsViewEnabled {
6262
profileExpirationSection(profileExpiration: profileExpiration)
6363
}
6464
}

Scripts/capture-build-details.sh

+7-18
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ SCRIPT_DIRECTORY="$(dirname "${0}")"
1010

1111
error() {
1212
echo "ERROR: ${*}" >&2
13-
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
13+
echo "Usage: ${SCRIPT} [-r|--git-source-root git-source-root] [-p|--provisioning-profile-path provisioning-profile-path]" >&2
1414
echo "Parameters:" >&2
15-
echo " -r|--git-source-root <git-source-root> root location of git repository to gather information from; optional, defaults to \${WORKSPACE_ROOT} if present, otherwise defaults to \${SRCROOT}" >&2
1615
echo " -p|--provisioning-profile-path <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
17-
echo " -i|--info-plist-path <info-plist-path> path to the Info.plist file to modify; optional, defaults to \${BUILT_PRODUCTS_DIR}/\${INFOPLIST_PATH}" >&2
1816
exit 1
1917
}
2018

@@ -26,17 +24,12 @@ info() {
2624
echo "INFO: ${*}" >&2
2725
}
2826

29-
git_source_root="${WORKSPACE_ROOT:-${SRCROOT}}"
30-
info_plist_path="${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}"
27+
info_plist_path="${BUILT_PRODUCTS_DIR}/${CONTENTS_FOLDER_PATH}/BuildDetails.plist"
3128
provisioning_profile_path="${HOME}/Library/MobileDevice/Provisioning Profiles/${EXPANDED_PROVISIONING_PROFILE}.mobileprovision"
3229
xcode_build_version=${XCODE_PRODUCT_BUILD_VERSION:-$(xcodebuild -version | grep version | cut -d ' ' -f 3)}
3330
while [[ $# -gt 0 ]]
3431
do
3532
case $1 in
36-
-r|--git-source-root)
37-
git_source_root="${2}"
38-
shift 2
39-
;;
4033
-i|--info-plist-path)
4134
info_plist_path="${2}"
4235
shift 2
@@ -52,16 +45,12 @@ if [ ${#} -ne 0 ]; then
5245
error "Unexpected arguments: ${*}"
5346
fi
5447

55-
if [ -z "${git_source_root}" ]; then
56-
error "Must provide one of --git-source-root, \${WORKSPACE_ROOT}, or \${SRCROOT}."
57-
fi
58-
5948
if [ "${info_plist_path}" == "/" -o ! -e "${info_plist_path}" ]; then
60-
error "Must provide valid --info-plist-path, or have valid \${BUILT_PRODUCTS_DIR} and \${INFOPLIST_PATH} set."
49+
error "File does not exist: ${info_plist_path}"
50+
#error "Must provide valid --info-plist-path, or have valid \${BUILT_PRODUCTS_DIR} and \${INFOPLIST_PATH} set."
6151
fi
6252

63-
info "Gathering build details in ${git_source_root}"
64-
cd "${git_source_root}"
53+
info "Gathering build details in ${PWD}"
6554

6655
if [ -e .git ]; then
6756
rev=$(git rev-parse HEAD)
@@ -74,7 +63,7 @@ if [ -e .git ]; then
7463
fi
7564
fi
7665

77-
plutil -replace com-loopkit-Loop-srcroot -string "${git_source_root}" "${info_plist_path}"
66+
plutil -replace com-loopkit-Loop-srcroot -string "${PWD}" "${info_plist_path}"
7867
plutil -replace com-loopkit-Loop-build-date -string "$(date)" "${info_plist_path}"
7968
plutil -replace com-loopkit-Loop-xcode-version -string "${xcode_build_version}" "${info_plist_path}"
8069

@@ -89,7 +78,7 @@ fi
8978

9079
# determine if this is a workspace build
9180
# if so, fill out the git revision and branch
92-
if [ -e ../LoopWorkspace.xcworkspace ]
81+
if [ -e ../.git ]
9382
then
9483
pushd . > /dev/null
9584
cd ..

Version.xcconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88

99
// Version [DEFAULT]
10-
LOOP_MARKETING_VERSION = 3.2.2
10+
LOOP_MARKETING_VERSION = 3.2.3
1111
CURRENT_PROJECT_VERSION = 57
1212

1313
// Optional override

0 commit comments

Comments
 (0)