Skip to content

Commit

Permalink
Merge pull request #2069 from LoopKit/xcode-15-main
Browse files Browse the repository at this point in the history
Backport cyclic dependency fixes from dev for building on Xcode 15
  • Loading branch information
ps2 committed Sep 19, 2023
2 parents befcbcb + 976c9fc commit c6b058b
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 74 deletions.
41 changes: 0 additions & 41 deletions Common/Extensions/NSBundle.swift
Expand Up @@ -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 {
Expand Down
69 changes: 69 additions & 0 deletions 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
}
}

11 changes: 9 additions & 2 deletions Loop.xcodeproj/project.pbxproj
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 52;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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 = "<group>"; };
C11C5D142ABA0B38004BD0B5 /* BuildDetails.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BuildDetails.swift; sourceTree = "<group>"; };
C11C5D162ABA2988004BD0B5 /* BuildDetails.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = BuildDetails.plist; sourceTree = "<group>"; };
C1201E2B23ECDBD0002DA84A /* WatchContextRequestUserInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WatchContextRequestUserInfo.swift; sourceTree = "<group>"; };
C121D8CF29C7866D00DA0520 /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = cs; path = cs.lproj/Main.strings; sourceTree = "<group>"; };
C121D8D029C7866D00DA0520 /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = cs; path = cs.lproj/Localizable.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -2618,6 +2623,7 @@
4F11D3C120DD80B3006E072C /* WatchHistoricalGlucose.swift */,
4F7E8AC620E2AC0300AEA65E /* WatchPredictedGlucose.swift */,
E9B08020253BBDE900BAD8F8 /* IntentExtensionInfo.swift */,
C11C5D142ABA0B38004BD0B5 /* BuildDetails.swift */,
);
path = Models;
sourceTree = "<group>";
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -3703,7 +3710,6 @@
inputFileListPaths = (
);
inputPaths = (
"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}",
);
name = "Capture Build Details";
outputFileListPaths = (
Expand Down Expand Up @@ -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 */,
Expand Down
12 changes: 12 additions & 0 deletions Loop/BuildDetails.plist
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!--
BuildDetails.plist
Loop
Created by Pete Schwamb on 6/13/23.
Copyright (c) 2023 LoopKit Authors. All rights reserved.
-->
<plist version="1.0">
<dict/>
</plist>
18 changes: 9 additions & 9 deletions Loop/Managers/DeviceDataManager.swift
Expand Up @@ -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)",
Expand Down Expand Up @@ -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" &&
Expand Down
2 changes: 1 addition & 1 deletion Loop/Managers/LoopAppManager.swift
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion Loop/Managers/ProfileExpirationAlerter.swift
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion Loop/Views/SettingsView.swift
Expand Up @@ -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)
}
}
Expand Down
25 changes: 7 additions & 18 deletions Scripts/capture-build-details.sh
Expand Up @@ -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 <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 <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 <info-plist-path> path to the Info.plist file to modify; optional, defaults to \${BUILT_PRODUCTS_DIR}/\${INFOPLIST_PATH}" >&2
exit 1
}

Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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}"

Expand All @@ -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 ..
Expand Down
2 changes: 1 addition & 1 deletion Version.xcconfig
Expand Up @@ -7,7 +7,7 @@
//

// Version [DEFAULT]
LOOP_MARKETING_VERSION = 3.2.2
LOOP_MARKETING_VERSION = 3.2.3
CURRENT_PROJECT_VERSION = 57

// Optional override
Expand Down

0 comments on commit c6b058b

Please sign in to comment.