├── Assets ├── build-phases.png └── example.png ├── Example ├── Example.xcodeproj │ └── project.pbxproj └── Example │ ├── Assets.xcassets │ ├── AccentColor.colorset │ │ └── Contents.json │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── Contents.json │ ├── ContentView.swift │ ├── ExampleApp.swift │ └── Preview Content │ └── Preview Assets.xcassets │ └── Contents.json ├── LICENSE ├── Package.swift ├── Plugins └── GitCommitInfoPlugin.swift ├── README.md └── Sources └── GitCommitInfoGenerator └── main.swift /Assets/build-phases.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PGSSoft/GitCommitInfoPlugin/e852bf2173c937ec412b3ef47164465ff289fefb/Assets/build-phases.png -------------------------------------------------------------------------------- /Assets/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PGSSoft/GitCommitInfoPlugin/e852bf2173c937ec412b3ef47164465ff289fefb/Assets/example.png -------------------------------------------------------------------------------- /Example/Example.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 56; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | B4F34BE62ADEBCC4006E8200 /* ExampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4F34BE52ADEBCC4006E8200 /* ExampleApp.swift */; }; 11 | B4F34BE82ADEBCC4006E8200 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4F34BE72ADEBCC4006E8200 /* ContentView.swift */; }; 12 | B4F34BEA2ADEBCC5006E8200 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B4F34BE92ADEBCC5006E8200 /* Assets.xcassets */; }; 13 | B4F34BED2ADEBCC5006E8200 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B4F34BEC2ADEBCC5006E8200 /* Preview Assets.xcassets */; }; 14 | /* End PBXBuildFile section */ 15 | 16 | /* Begin PBXFileReference section */ 17 | B4F34BE22ADEBCC4006E8200 /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 18 | B4F34BE52ADEBCC4006E8200 /* ExampleApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleApp.swift; sourceTree = ""; }; 19 | B4F34BE72ADEBCC4006E8200 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; 20 | B4F34BE92ADEBCC5006E8200 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 21 | B4F34BEC2ADEBCC5006E8200 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 22 | /* End PBXFileReference section */ 23 | 24 | /* Begin PBXFrameworksBuildPhase section */ 25 | B4F34BDF2ADEBCC4006E8200 /* Frameworks */ = { 26 | isa = PBXFrameworksBuildPhase; 27 | buildActionMask = 2147483647; 28 | files = ( 29 | ); 30 | runOnlyForDeploymentPostprocessing = 0; 31 | }; 32 | /* End PBXFrameworksBuildPhase section */ 33 | 34 | /* Begin PBXGroup section */ 35 | B4F34BD92ADEBCC4006E8200 = { 36 | isa = PBXGroup; 37 | children = ( 38 | B4F34BE42ADEBCC4006E8200 /* Example */, 39 | B4F34BE32ADEBCC4006E8200 /* Products */, 40 | ); 41 | sourceTree = ""; 42 | }; 43 | B4F34BE32ADEBCC4006E8200 /* Products */ = { 44 | isa = PBXGroup; 45 | children = ( 46 | B4F34BE22ADEBCC4006E8200 /* Example.app */, 47 | ); 48 | name = Products; 49 | sourceTree = ""; 50 | }; 51 | B4F34BE42ADEBCC4006E8200 /* Example */ = { 52 | isa = PBXGroup; 53 | children = ( 54 | B4F34BE52ADEBCC4006E8200 /* ExampleApp.swift */, 55 | B4F34BE72ADEBCC4006E8200 /* ContentView.swift */, 56 | B4F34BE92ADEBCC5006E8200 /* Assets.xcassets */, 57 | B4F34BEB2ADEBCC5006E8200 /* Preview Content */, 58 | ); 59 | path = Example; 60 | sourceTree = ""; 61 | }; 62 | B4F34BEB2ADEBCC5006E8200 /* Preview Content */ = { 63 | isa = PBXGroup; 64 | children = ( 65 | B4F34BEC2ADEBCC5006E8200 /* Preview Assets.xcassets */, 66 | ); 67 | path = "Preview Content"; 68 | sourceTree = ""; 69 | }; 70 | /* End PBXGroup section */ 71 | 72 | /* Begin PBXNativeTarget section */ 73 | B4F34BE12ADEBCC4006E8200 /* Example */ = { 74 | isa = PBXNativeTarget; 75 | buildConfigurationList = B4F34BF02ADEBCC5006E8200 /* Build configuration list for PBXNativeTarget "Example" */; 76 | buildPhases = ( 77 | B4F34BDE2ADEBCC4006E8200 /* Sources */, 78 | B4F34BDF2ADEBCC4006E8200 /* Frameworks */, 79 | B4F34BE02ADEBCC4006E8200 /* Resources */, 80 | ); 81 | buildRules = ( 82 | ); 83 | dependencies = ( 84 | B4F34BF62ADEBD62006E8200 /* PBXTargetDependency */, 85 | ); 86 | name = Example; 87 | productName = Example; 88 | productReference = B4F34BE22ADEBCC4006E8200 /* Example.app */; 89 | productType = "com.apple.product-type.application"; 90 | }; 91 | /* End PBXNativeTarget section */ 92 | 93 | /* Begin PBXProject section */ 94 | B4F34BDA2ADEBCC4006E8200 /* Project object */ = { 95 | isa = PBXProject; 96 | attributes = { 97 | BuildIndependentTargetsInParallel = 1; 98 | LastSwiftUpdateCheck = 1500; 99 | LastUpgradeCheck = 1500; 100 | TargetAttributes = { 101 | B4F34BE12ADEBCC4006E8200 = { 102 | CreatedOnToolsVersion = 15.0; 103 | }; 104 | }; 105 | }; 106 | buildConfigurationList = B4F34BDD2ADEBCC4006E8200 /* Build configuration list for PBXProject "Example" */; 107 | compatibilityVersion = "Xcode 14.0"; 108 | developmentRegion = en; 109 | hasScannedForEncodings = 0; 110 | knownRegions = ( 111 | en, 112 | Base, 113 | ); 114 | mainGroup = B4F34BD92ADEBCC4006E8200; 115 | packageReferences = ( 116 | B4F34BF42ADEBD58006E8200 /* XCRemoteSwiftPackageReference "GitCommitInfoPlugin" */, 117 | ); 118 | productRefGroup = B4F34BE32ADEBCC4006E8200 /* Products */; 119 | projectDirPath = ""; 120 | projectRoot = ""; 121 | targets = ( 122 | B4F34BE12ADEBCC4006E8200 /* Example */, 123 | ); 124 | }; 125 | /* End PBXProject section */ 126 | 127 | /* Begin PBXResourcesBuildPhase section */ 128 | B4F34BE02ADEBCC4006E8200 /* Resources */ = { 129 | isa = PBXResourcesBuildPhase; 130 | buildActionMask = 2147483647; 131 | files = ( 132 | B4F34BED2ADEBCC5006E8200 /* Preview Assets.xcassets in Resources */, 133 | B4F34BEA2ADEBCC5006E8200 /* Assets.xcassets in Resources */, 134 | ); 135 | runOnlyForDeploymentPostprocessing = 0; 136 | }; 137 | /* End PBXResourcesBuildPhase section */ 138 | 139 | /* Begin PBXSourcesBuildPhase section */ 140 | B4F34BDE2ADEBCC4006E8200 /* Sources */ = { 141 | isa = PBXSourcesBuildPhase; 142 | buildActionMask = 2147483647; 143 | files = ( 144 | B4F34BE82ADEBCC4006E8200 /* ContentView.swift in Sources */, 145 | B4F34BE62ADEBCC4006E8200 /* ExampleApp.swift in Sources */, 146 | ); 147 | runOnlyForDeploymentPostprocessing = 0; 148 | }; 149 | /* End PBXSourcesBuildPhase section */ 150 | 151 | /* Begin PBXTargetDependency section */ 152 | B4F34BF62ADEBD62006E8200 /* PBXTargetDependency */ = { 153 | isa = PBXTargetDependency; 154 | productRef = B4F34BF52ADEBD62006E8200 /* GitCommitInfoPlugin */; 155 | }; 156 | /* End PBXTargetDependency section */ 157 | 158 | /* Begin XCBuildConfiguration section */ 159 | B4F34BEE2ADEBCC5006E8200 /* Debug */ = { 160 | isa = XCBuildConfiguration; 161 | buildSettings = { 162 | ALWAYS_SEARCH_USER_PATHS = NO; 163 | ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; 164 | CLANG_ANALYZER_NONNULL = YES; 165 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 166 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; 167 | CLANG_ENABLE_MODULES = YES; 168 | CLANG_ENABLE_OBJC_ARC = YES; 169 | CLANG_ENABLE_OBJC_WEAK = YES; 170 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 171 | CLANG_WARN_BOOL_CONVERSION = YES; 172 | CLANG_WARN_COMMA = YES; 173 | CLANG_WARN_CONSTANT_CONVERSION = YES; 174 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 175 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 176 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 177 | CLANG_WARN_EMPTY_BODY = YES; 178 | CLANG_WARN_ENUM_CONVERSION = YES; 179 | CLANG_WARN_INFINITE_RECURSION = YES; 180 | CLANG_WARN_INT_CONVERSION = YES; 181 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 182 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 183 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 184 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 185 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 186 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 187 | CLANG_WARN_STRICT_PROTOTYPES = YES; 188 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 189 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 190 | CLANG_WARN_UNREACHABLE_CODE = YES; 191 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 192 | COPY_PHASE_STRIP = NO; 193 | DEBUG_INFORMATION_FORMAT = dwarf; 194 | ENABLE_STRICT_OBJC_MSGSEND = YES; 195 | ENABLE_TESTABILITY = YES; 196 | ENABLE_USER_SCRIPT_SANDBOXING = YES; 197 | GCC_C_LANGUAGE_STANDARD = gnu17; 198 | GCC_DYNAMIC_NO_PIC = NO; 199 | GCC_NO_COMMON_BLOCKS = YES; 200 | GCC_OPTIMIZATION_LEVEL = 0; 201 | GCC_PREPROCESSOR_DEFINITIONS = ( 202 | "DEBUG=1", 203 | "$(inherited)", 204 | ); 205 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 206 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 207 | GCC_WARN_UNDECLARED_SELECTOR = YES; 208 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 209 | GCC_WARN_UNUSED_FUNCTION = YES; 210 | GCC_WARN_UNUSED_VARIABLE = YES; 211 | IPHONEOS_DEPLOYMENT_TARGET = 17.0; 212 | LOCALIZATION_PREFERS_STRING_CATALOGS = YES; 213 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 214 | MTL_FAST_MATH = YES; 215 | ONLY_ACTIVE_ARCH = YES; 216 | SDKROOT = iphoneos; 217 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; 218 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 219 | }; 220 | name = Debug; 221 | }; 222 | B4F34BEF2ADEBCC5006E8200 /* Release */ = { 223 | isa = XCBuildConfiguration; 224 | buildSettings = { 225 | ALWAYS_SEARCH_USER_PATHS = NO; 226 | ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; 227 | CLANG_ANALYZER_NONNULL = YES; 228 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 229 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; 230 | CLANG_ENABLE_MODULES = YES; 231 | CLANG_ENABLE_OBJC_ARC = YES; 232 | CLANG_ENABLE_OBJC_WEAK = YES; 233 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 234 | CLANG_WARN_BOOL_CONVERSION = YES; 235 | CLANG_WARN_COMMA = YES; 236 | CLANG_WARN_CONSTANT_CONVERSION = YES; 237 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 238 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 239 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 240 | CLANG_WARN_EMPTY_BODY = YES; 241 | CLANG_WARN_ENUM_CONVERSION = YES; 242 | CLANG_WARN_INFINITE_RECURSION = YES; 243 | CLANG_WARN_INT_CONVERSION = YES; 244 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 245 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 246 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 247 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 248 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 249 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 250 | CLANG_WARN_STRICT_PROTOTYPES = YES; 251 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 252 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 253 | CLANG_WARN_UNREACHABLE_CODE = YES; 254 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 255 | COPY_PHASE_STRIP = NO; 256 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 257 | ENABLE_NS_ASSERTIONS = NO; 258 | ENABLE_STRICT_OBJC_MSGSEND = YES; 259 | ENABLE_USER_SCRIPT_SANDBOXING = YES; 260 | GCC_C_LANGUAGE_STANDARD = gnu17; 261 | GCC_NO_COMMON_BLOCKS = YES; 262 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 263 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 264 | GCC_WARN_UNDECLARED_SELECTOR = YES; 265 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 266 | GCC_WARN_UNUSED_FUNCTION = YES; 267 | GCC_WARN_UNUSED_VARIABLE = YES; 268 | IPHONEOS_DEPLOYMENT_TARGET = 17.0; 269 | LOCALIZATION_PREFERS_STRING_CATALOGS = YES; 270 | MTL_ENABLE_DEBUG_INFO = NO; 271 | MTL_FAST_MATH = YES; 272 | SDKROOT = iphoneos; 273 | SWIFT_COMPILATION_MODE = wholemodule; 274 | VALIDATE_PRODUCT = YES; 275 | }; 276 | name = Release; 277 | }; 278 | B4F34BF12ADEBCC5006E8200 /* Debug */ = { 279 | isa = XCBuildConfiguration; 280 | buildSettings = { 281 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 282 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 283 | CODE_SIGN_STYLE = Automatic; 284 | CURRENT_PROJECT_VERSION = 1; 285 | DEVELOPMENT_ASSET_PATHS = "\"Example/Preview Content\""; 286 | DEVELOPMENT_TEAM = F9ZBJ8H4Z9; 287 | ENABLE_PREVIEWS = YES; 288 | GENERATE_INFOPLIST_FILE = YES; 289 | INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; 290 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 291 | INFOPLIST_KEY_UILaunchScreen_Generation = YES; 292 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 293 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 294 | LD_RUNPATH_SEARCH_PATHS = ( 295 | "$(inherited)", 296 | "@executable_path/Frameworks", 297 | ); 298 | MARKETING_VERSION = 1.0; 299 | PRODUCT_BUNDLE_IDENTIFIER = com.xebia.Example; 300 | PRODUCT_NAME = "$(TARGET_NAME)"; 301 | SWIFT_EMIT_LOC_STRINGS = YES; 302 | SWIFT_VERSION = 5.0; 303 | TARGETED_DEVICE_FAMILY = "1,2"; 304 | }; 305 | name = Debug; 306 | }; 307 | B4F34BF22ADEBCC5006E8200 /* Release */ = { 308 | isa = XCBuildConfiguration; 309 | buildSettings = { 310 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 311 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 312 | CODE_SIGN_STYLE = Automatic; 313 | CURRENT_PROJECT_VERSION = 1; 314 | DEVELOPMENT_ASSET_PATHS = "\"Example/Preview Content\""; 315 | DEVELOPMENT_TEAM = F9ZBJ8H4Z9; 316 | ENABLE_PREVIEWS = YES; 317 | GENERATE_INFOPLIST_FILE = YES; 318 | INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; 319 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; 320 | INFOPLIST_KEY_UILaunchScreen_Generation = YES; 321 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 322 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; 323 | LD_RUNPATH_SEARCH_PATHS = ( 324 | "$(inherited)", 325 | "@executable_path/Frameworks", 326 | ); 327 | MARKETING_VERSION = 1.0; 328 | PRODUCT_BUNDLE_IDENTIFIER = com.xebia.Example; 329 | PRODUCT_NAME = "$(TARGET_NAME)"; 330 | SWIFT_EMIT_LOC_STRINGS = YES; 331 | SWIFT_VERSION = 5.0; 332 | TARGETED_DEVICE_FAMILY = "1,2"; 333 | }; 334 | name = Release; 335 | }; 336 | /* End XCBuildConfiguration section */ 337 | 338 | /* Begin XCConfigurationList section */ 339 | B4F34BDD2ADEBCC4006E8200 /* Build configuration list for PBXProject "Example" */ = { 340 | isa = XCConfigurationList; 341 | buildConfigurations = ( 342 | B4F34BEE2ADEBCC5006E8200 /* Debug */, 343 | B4F34BEF2ADEBCC5006E8200 /* Release */, 344 | ); 345 | defaultConfigurationIsVisible = 0; 346 | defaultConfigurationName = Release; 347 | }; 348 | B4F34BF02ADEBCC5006E8200 /* Build configuration list for PBXNativeTarget "Example" */ = { 349 | isa = XCConfigurationList; 350 | buildConfigurations = ( 351 | B4F34BF12ADEBCC5006E8200 /* Debug */, 352 | B4F34BF22ADEBCC5006E8200 /* Release */, 353 | ); 354 | defaultConfigurationIsVisible = 0; 355 | defaultConfigurationName = Release; 356 | }; 357 | /* End XCConfigurationList section */ 358 | 359 | /* Begin XCRemoteSwiftPackageReference section */ 360 | B4F34BF42ADEBD58006E8200 /* XCRemoteSwiftPackageReference "GitCommitInfoPlugin" */ = { 361 | isa = XCRemoteSwiftPackageReference; 362 | repositoryURL = "https://github.com/PGSSoft/GitCommitInfoPlugin"; 363 | requirement = { 364 | kind = upToNextMajorVersion; 365 | minimumVersion = 0.0.1; 366 | }; 367 | }; 368 | /* End XCRemoteSwiftPackageReference section */ 369 | 370 | /* Begin XCSwiftPackageProductDependency section */ 371 | B4F34BF52ADEBD62006E8200 /* GitCommitInfoPlugin */ = { 372 | isa = XCSwiftPackageProductDependency; 373 | package = B4F34BF42ADEBD58006E8200 /* XCRemoteSwiftPackageReference "GitCommitInfoPlugin" */; 374 | productName = "plugin:GitCommitInfoPlugin"; 375 | }; 376 | /* End XCSwiftPackageProductDependency section */ 377 | }; 378 | rootObject = B4F34BDA2ADEBCC4006E8200 /* Project object */; 379 | } 380 | -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "platform" : "ios", 6 | "size" : "1024x1024" 7 | } 8 | ], 9 | "info" : { 10 | "author" : "xcode", 11 | "version" : 1 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Example/Example/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Example/ContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // Example 4 | // 5 | // Created by Michal Kowalski on 17/10/2023. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct ContentView: View { 11 | var body: some View { 12 | NavigationStack { 13 | List { 14 | VStack(alignment: .leading) { 15 | Text("Commit hash").font(.caption) 16 | Text(GitCommitInfo.commitHash) 17 | } 18 | VStack(alignment: .leading) { 19 | Text("Branch name").font(.caption) 20 | Text(GitCommitInfo.branchName) 21 | } 22 | VStack(alignment: .leading) { 23 | Text("Short commit hash").font(.caption) 24 | Text(GitCommitInfo.shortCommitHash) 25 | } 26 | VStack(alignment: .leading) { 27 | Text("Commit message").font(.caption) 28 | Text(GitCommitInfo.commitSubject) 29 | } 30 | VStack(alignment: .leading) { 31 | Text("Timestamp").font(.caption) 32 | Text("\(GitCommitInfo.unixTimestamp)") 33 | } 34 | }.navigationTitle("About") 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Example/Example/ExampleApp.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ExampleApp.swift 3 | // Example 4 | // 5 | // Created by Michal Kowalski on 17/10/2023. 6 | // 7 | 8 | import SwiftUI 9 | 10 | @main 11 | struct ExampleApp: App { 12 | var body: some Scene { 13 | WindowGroup { 14 | ContentView() 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Example/Example/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Xebia Poland 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version: 5.9 2 | 3 | import PackageDescription 4 | 5 | let package = Package( 6 | name: "GitCommitInfoPlugin", 7 | products: [ 8 | .plugin( 9 | name: "GitCommitInfoPlugin", 10 | targets: ["GitCommitInfoPlugin"]), 11 | .executable(name: "GitCommitInfoGenerator", targets: ["GitCommitInfoGenerator"]) 12 | ], 13 | targets: [ 14 | .plugin( 15 | name: "GitCommitInfoPlugin", 16 | capability: .buildTool(), 17 | dependencies: ["GitCommitInfoGenerator"] 18 | ), 19 | .target(name: "GitCommitInfoGenerator") 20 | ] 21 | ) 22 | -------------------------------------------------------------------------------- /Plugins/GitCommitInfoPlugin.swift: -------------------------------------------------------------------------------- 1 | import PackagePlugin 2 | import Foundation 3 | 4 | @main 5 | struct GitCommitInfoPlugin: BuildToolPlugin { 6 | static let toolName = "GitCommitInfoGenerator" 7 | static let outputFileName = "GitCommitInfo.swift" 8 | /// Entry point for creating build commands for targets in Swift packages. 9 | func createBuildCommands(context: PluginContext, 10 | target: Target) async throws -> [Command] { 11 | let generatorTool = try context.tool(named: Self.toolName) 12 | let outputPath = context.pluginWorkDirectory.appending(Self.outputFileName) 13 | return [gitCommitInfoBuildCommand(generatorTool: generatorTool, outputPath: outputPath)] 14 | } 15 | } 16 | 17 | #if canImport(XcodeProjectPlugin) 18 | import XcodeProjectPlugin 19 | 20 | extension GitCommitInfoPlugin: XcodeBuildToolPlugin { 21 | // Entry point for creating build commands for targets in Xcode projects. 22 | func createBuildCommands(context: XcodePluginContext, 23 | target: XcodeTarget) throws -> [Command] { 24 | let generatorTool = try context.tool(named: Self.toolName) 25 | let outputPath = context.pluginWorkDirectory.appending(Self.outputFileName) 26 | return [gitCommitInfoBuildCommand(generatorTool: generatorTool, outputPath: outputPath)] 27 | } 28 | } 29 | 30 | #endif 31 | 32 | extension GitCommitInfoPlugin { 33 | func gitCommitInfoBuildCommand(generatorTool: PluginContext.Tool, 34 | outputPath: Path ) -> Command{ 35 | return .buildCommand( 36 | displayName: "Generating GitCommitInfo file", 37 | executable: generatorTool.path, 38 | arguments: [outputPath], 39 | outputFiles: [outputPath] 40 | ) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GitCommitInfoPlugin 2 | ![Example](Assets/example.png) 3 | 4 | GitCommitInfoPlugin is a simple to use Swift package build plugin that allows you to display basic information from the last git commit. You can use it to prepare info view about current commit for QA team or prepare what's new view based on the commit message. 5 | 6 | ## Requirements 7 | 8 | Xcode 14 or above 9 | 10 | ## Usage 11 | 12 | 1. Add dependency `File -> Add Package Dependencies` enter url to github repo. 13 | 2. Add Plugin to your target in section `Build Phases -> Run Build Tool Plug-ins` 14 | ![Build phases](Assets/build-phases.png) 15 | 3. Access properties from `GitCommitInfo` in your view. 16 | 17 | ```swift 18 | import SwiftUI 19 | 20 | struct ContentView: View { 21 | var body: some View { 22 | NavigationStack { 23 | List { 24 | VStack(alignment: .leading) { 25 | Text("Commit hash").font(.caption) 26 | Text(GitCommitInfo.commitHash) 27 | } 28 | VStack(alignment: .leading) { 29 | Text("Branch name").font(.caption) 30 | Text(GitCommitInfo.branchName) 31 | } 32 | VStack(alignment: .leading) { 33 | Text("Short commit hash").font(.caption) 34 | Text(GitCommitInfo.shortCommitHash) 35 | } 36 | VStack(alignment: .leading) { 37 | Text("Commit message").font(.caption) 38 | Text(GitCommitInfo.commitSubject) 39 | } 40 | VStack(alignment: .leading) { 41 | Text("Timestamp").font(.caption) 42 | Text("\(GitCommitInfo.unixTimestamp)") 43 | } 44 | }.navigationTitle("About") 45 | } 46 | } 47 | } 48 | ``` 49 | ## License 50 | 51 | MIT 52 | -------------------------------------------------------------------------------- /Sources/GitCommitInfoGenerator/main.swift: -------------------------------------------------------------------------------- 1 | // 2 | // main.swift 3 | // GitCommitInfoGenerator 4 | // 5 | // Created by Michal Kowalski on 03/10/2023. 6 | // 7 | 8 | import Foundation 9 | 10 | let args = CommandLine.arguments 11 | let outputFile = args[1] 12 | 13 | struct GitHelper { 14 | 15 | static private func projectDir() -> String { 16 | ProcessInfo.processInfo.environment["PROJECT_DIR"]! 17 | } 18 | 19 | static private func shell(_ command: String) -> String { 20 | let process = Process() 21 | let pipe = Pipe() 22 | let errorPipe = Pipe() 23 | process.standardOutput = pipe 24 | process.standardError = errorPipe 25 | process.arguments = ["-c", command] 26 | process.launchPath = "/bin/zsh" 27 | process.launch() 28 | 29 | let errorData = errorPipe.fileHandleForReading.readDataToEndOfFile() 30 | guard errorData.isEmpty else { 31 | fatalError("Error executing shell command \(String(data: errorData, encoding: .utf8)!)") 32 | } 33 | let data = pipe.fileHandleForReading.readDataToEndOfFile() 34 | let output = String(data: data, encoding: .utf8)! 35 | 36 | return output 37 | } 38 | 39 | static func gitCommand(_ cmd: String) -> String { 40 | "\(shell("cd \(projectDir()) && \(cmd)").trimmingCharacters(in: .whitespacesAndNewlines))" 41 | } 42 | 43 | } 44 | 45 | let commitHash = GitHelper.gitCommand("git log -1 --pretty=\"%H\"") 46 | let shortCommitHash = GitHelper.gitCommand("git log -1 --pretty=\"%h\"") 47 | let shortSubject = GitHelper.gitCommand("git log -1 --pretty=\"%s\"") 48 | let branchName = GitHelper.gitCommand("git rev-parse --abbrev-ref HEAD") 49 | let timestamp = GitHelper.gitCommand("git log -1 --pretty=\"%ct\"") 50 | 51 | let content = """ 52 | struct GitCommitInfo { 53 | 54 | static var commitHash: String { 55 | "\(commitHash)" 56 | } 57 | 58 | static var shortCommitHash: String { 59 | "\(shortCommitHash)" 60 | } 61 | 62 | static var commitSubject: String { 63 | "\(shortSubject)" 64 | } 65 | 66 | static var branchName: String { 67 | "\(branchName)" 68 | } 69 | 70 | static var unixTimestamp: Double { 71 | \(timestamp) 72 | } 73 | } 74 | """ 75 | 76 | do { 77 | try content.data(using: .utf8)?.write(to: URL(fileURLWithPath: outputFile)) 78 | } catch { 79 | fatalError(error.localizedDescription) 80 | } 81 | --------------------------------------------------------------------------------