{"id":17540494,"url":"https://github.com/fromkk/gitbranchname","last_synced_at":"2026-02-02T11:06:45.444Z","repository":{"id":146697831,"uuid":"71032514","full_name":"fromkk/GitBranchName","owner":"fromkk","description":"Sample of get the branch name for Xcode.","archived":false,"fork":false,"pushed_at":"2016-11-25T10:18:44.000Z","size":15,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-23T22:52:41.890Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fromkk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-16T05:43:07.000Z","updated_at":"2021-10-15T09:17:53.000Z","dependencies_parsed_at":"2023-04-03T10:31:01.487Z","dependency_job_id":null,"html_url":"https://github.com/fromkk/GitBranchName","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fromkk/GitBranchName","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fromkk%2FGitBranchName","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fromkk%2FGitBranchName/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fromkk%2FGitBranchName/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fromkk%2FGitBranchName/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fromkk","download_url":"https://codeload.github.com/fromkk/GitBranchName/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fromkk%2FGitBranchName/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29010740,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-02T10:37:29.253Z","status":"ssl_error","status_checked_at":"2026-02-02T10:37:28.644Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-20T22:24:02.480Z","updated_at":"2026-02-02T11:06:45.412Z","avatar_url":"https://github.com/fromkk.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sample of display git branch name\n\nAdd **branch.plist** to top of project.  \nChange scheme to **Shared**  \nSet build target to `Provide build setting from ***`\n\nadd code to **Scheme/Build/Pre-actions/Run Script**\n\n```bash\nbranch=\"master\"\nif [ ! -z \"${CIRCLE_BRANCH+x}\" ]; then\n    branch=$CIRCLE_BRANCH\nelif [ ! -z \"${TRAVIS_BRANCH+x}\" ]; then\n    branch=$TRAVIS_BRANCH\nelif [ ! -z \"${BITRISE_GIT_BRANCH+x}\" ]; then\n    branch=$BITRISE_GIT_BRANCH\nelse\n    git_path=$(which git)\n    if [ -e $git_path ]; then\n        branch=$($git_path --git-dir=$PROJECT_DIR/.git rev-parse --abbrev-ref HEAD)\n    fi\nfi\n\nplistName=$PROJECT_DIR/Branch\nplistPath=$plistName.plist\nif [ ! -e $plistPath ]; then\ntouch $plistPath\nfi\nchmod u+wr,g+wr,o+r $plistPath\ndefaults write $plistName \"branch\" $branch\n```\n\nBuild your apps then generated file of **Branch.plist**\n\nYou can get branch name from **Branch.plist**.  \n\nFor example:\n\n```swift\nstruct Branch {\n    private enum Constants {\n        static let defaultBranch: String = \"master\"\n        static let plistFileName: String = \"Branch\"\n        static let branchNameKey: String = \"branch\"\n    }\n\n    static var current: String {\n        guard let path: String = Bundle.main.path(forResource: Constants.plistFileName, ofType: \"plist\") else {\n            return Constants.defaultBranch\n        }\n        guard let plist: [String: String] = NSDictionary(contentsOfFile: path) as? [String: String] else {\n            return Constants.defaultBranch\n        }\n        return plist[Constants.branchNameKey] ?? Constants.defaultBranch\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffromkk%2Fgitbranchname","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffromkk%2Fgitbranchname","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffromkk%2Fgitbranchname/lists"}