MacOS – What makes an app unique from POV of options -> assign to desktop

dockmacosmission-controlspaceswindow-manager

What is the set of things that differentiate one application from another from the point of view of right-click on dock icon -> Options -> Assign To (All Desktops / This Desktop / None)?

I've experimented and haven't been able to hit on a combination of actual binary name / Info.plist values / PkgInfo string that will make Mac OS X workspaces think a duplicated application is different from the original for purposes of automatic desktop assignment.

Best Answer

Found it, just leaving this here to make it easier for others to find answers via google. See:

Specifically, the one thing you need to care about is CFBundleIdentifier in the app's Contents/Info.plist file. Here is a part from a script that may be useful:

  # Change Bundle ID so desktop assignation works. Not sure if this will survive updates.
  # CFBundleIdentifier must contain only alphanumeric (A-Z,a-z,0-9), hyphen (-), and period (.) characters.
  # (Based on fiddling around there also seems to be a length limit.)
  UUID="$(echo $APP | md5sum | awk '{print $1}' | tr [0-9] [A-Z] | cut -c 1-4,29-32)"
  plutil -replace CFBundleIdentifier -string "cdi.$UUID" -- "$RUNTIMES/$APP/Contents/Info.plist"
  #plutil -replace CFBundleName -string "$APP" -- "$RUNTIMES/$APP/Contents/Info.plist"
  #plutil -replace CFBundleDisplayName -string "$APP" -- "$RUNTIMES/$APP/Contents/Info.plist"
  # To check: defaults read ~/Library/Preferences/com.apple.spaces.plist app-bindings

To see this in some context, see my answer to this question: Is there a simple way to have separate dock icons for different Chrome Profiles?