published on in all
tags: xcode-beta xcode-12 xcode

Xcode 12.0 initial git branch name

Xcode 12.0 beta (12A6159) switched initial git branch name: master to main. Is there a way how to switch it back or to any other branch name?

DVTSourceControl.framework is responsible for this. The framework is located in the bundle (Contents/SharedFrameworks). Call Hopper for help :)

Is there a main string anywhere?

Disassembled framework

We’re lucky. It’s there and the string is referenced in one place only:

Disassembled framework

And this place is the +[DVTSourceControlBranch initialBranchName] class method:

Disassembled framework

The method name is pretty clear, but what it does? Is there a string value stored in user defaults (key DVTSourceControlDefaultNewRepositoryBranchName)? Yes - use it as an initial branch name. No - fallback to main.

Git support is provided via the XPC service (bundled in the framework). Let’s try to set the voldemort value in this domain.

% defaults write \
    DVTSourceControlDefaultNewRepositoryBranchName voldemort

Create a new Xcode project and keep the Create Git repository on my Mac option enabled.

Does it work?

% git status
On branch voldemort

Yep! You can easily switch it back to master or any other branch name.