Required after #6309. Uses the same logic as in android (I cannot locate the PR right now). Tested on a mac.