Преглед на файлове

Fix run script for branch name and commit ID to work with Xcode 15 (#274)

* BuildBranch fix for Xcode 15

- remove BuildBranch from Info.plist
- new Run script: get branch name and commit ID, replaces previous run script
- output to branch.txt
- use seven characters for the short commit reference, in line with GitHub
- run script early in build phases
- add branch.txt to FreeAPS project under FreeAPS/Resources
- add branch.txt to .gitignore
- read branch information from branch.txt also for upload of statistics in APSManager.swift

* Display build number like TestFlight (build number in brackets)

Previous style: iAPS v2.2.5 - 12
Changed to: iAPS 2.2.5 (12)
bjornoleh преди 2 години
родител
ревизия
29110721db

+ 2 - 0
.gitignore

@@ -80,3 +80,5 @@ fastlane/test_output
 fastlane/FastlaneRunner
 
 ConfigOverride.xcconfig
+
+branch.txt

Файловите разлики са ограничени, защото са твърде много
+ 9 - 5
FreeAPS.xcodeproj/project.pbxproj


+ 0 - 2
FreeAPS/Resources/Info.plist

@@ -8,8 +8,6 @@
 	<array>
 		<string>com.freeapsx.background-task.critical-event-log</string>
 	</array>
-	<key>BuildBranch</key>
-	<string></string>
 	<key>CBBundleDisplayName</key>
 	<string>$(APP_DISPLAY_NAME)</string>
 	<key>CFBundleDevelopmentRegion</key>

+ 23 - 1
FreeAPS/Sources/APS/APSManager.swift

@@ -948,7 +948,29 @@ final class BaseAPSManager: APSManager, Injectable {
                 let buildDate = Bundle.main.buildDate
                 let version = Bundle.main.releaseVersionNumber
                 let build = Bundle.main.buildVersionNumber
-                let branch = Bundle.main.infoDictionary?["BuildBranch"] as? String ?? ""
+
+                // Read branch information from branch.txt instead of infoDictionary
+                var branch = "Unknown"
+                if let branchFileURL = Bundle.main.url(forResource: "branch", withExtension: "txt"),
+                   let branchFileContent = try? String(contentsOf: branchFileURL)
+                {
+                    let lines = branchFileContent.components(separatedBy: .newlines)
+                    for line in lines {
+                        let components = line.components(separatedBy: "=")
+                        if components.count == 2 {
+                            let key = components[0].trimmingCharacters(in: .whitespaces)
+                            let value = components[1].trimmingCharacters(in: .whitespaces)
+
+                            if key == "BRANCH" {
+                                branch = value
+                                break
+                            }
+                        }
+                    }
+                } else {
+                    branch = "Unknown"
+                }
+
                 let copyrightNotice_ = Bundle.main.infoDictionary?["NSHumanReadableCopyright"] as? String ?? ""
                 let pump_ = pumpManager?.localizedTitle ?? ""
                 let cgm = settingsManager.settings.cgm

+ 20 - 1
FreeAPS/Sources/Modules/Settings/SettingsStateModel.swift

@@ -25,7 +25,26 @@ extension Settings {
 
             versionNumber = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "Unknown"
 
-            branch = Bundle.main.infoDictionary?["BuildBranch"] as? String ?? "Unknown"
+            // Read branch information from the branch.txt instead of infoDictionary
+            if let branchFileURL = Bundle.main.url(forResource: "branch", withExtension: "txt"),
+               let branchFileContent = try? String(contentsOf: branchFileURL)
+            {
+                let lines = branchFileContent.components(separatedBy: .newlines)
+                for line in lines {
+                    let components = line.components(separatedBy: "=")
+                    if components.count == 2 {
+                        let key = components[0].trimmingCharacters(in: .whitespaces)
+                        let value = components[1].trimmingCharacters(in: .whitespaces)
+
+                        if key == "BRANCH" {
+                            branch = value
+                            break
+                        }
+                    }
+                }
+            } else {
+                branch = "Unknown"
+            }
 
             copyrightNotice = Bundle.main.infoDictionary?["NSHumanReadableCopyright"] as? String ?? ""
 

+ 1 - 1
FreeAPS/Sources/Modules/Settings/View/SettingsRootView.swift

@@ -12,7 +12,7 @@ extension Settings {
             Form {
                 Section(
                     header: Text(
-                        "iAPS v\(state.versionNumber) - \(state.buildNumber) \nBranch: \(state.branch) \(state.copyrightNotice) "
+                        "iAPS v\(state.versionNumber) (\(state.buildNumber))\nBranch: \(state.branch) \(state.copyrightNotice) "
                     ).textCase(nil)
                 ) {
                     Toggle("Closed loop", isOn: $state.closedLoop)