True, this has been often discussed,,,,,, and true with mixed advice, some which is professional, educated, correct and current NEC code compliant, other that is Billy Bob or Bubbas (wired their own house over a case of beer and by golly it works) which is incorrect and potentially hazardous, your money, your life, your risk and your choice which to follow.
Here is my advice (retired Electrical Engineer and not current on latest codes as the many fine still practicing professional electricians here) feel free to take or leave it. NO WARRANTY it may or may not be correct (too long retired), I'm NOT saying it is or it isn't, so there lol
If you're wiring a separate buildings 120/240 volt Single Phase Three Wire Sub Panel fed by a Main Panel in the house, under the latest code as far as I know, NO WARRANTY BILLY BOB so don't have a calf if its incorrect!!
Run 4 wires out, Two Ungrounded Hot Phase Conductors ,,,,,One GrounDED Conductor (Neutral),,,,,,,One Equipment GroundING Conductor
At the remote sub panel (Unlike at the main) keep the Ground Buss (Green and Bare equipment GroundING Conductors) and the Neutral Busses (Whites) separate and electrically isolated.
The panels metallic box/tub, same as any other non conducting metal enclosures, gets connected to the Ground Buss
Any buildings electrical service, as far as I know (unless code has changed), requires earth grounding to a proper Grounding Electrode using a Grounding Electrode Conductor (I used No. 4 bare copper). A Grounding Electrode may consist of buried conductive water pipes or structural or foundation steel or what are called "made electrodes" such as copper rod or rods driven into the earth. In our jurisdiction we bonded all readily available grounding electrodes and if no other were present we used "made" electrode(s). Check with local authority and utility provider. Since this is a sub panel in a remote separate building the Grounding Electrode via the Grounding Electrode Conductor is connected to the Ground Buss.
The wire size to the remote location depends on the wire used, the enclosure and/or direct burial or aerial etc. etc., and the distance and amperage.
SO THERE now feel free to go with "mixed advice" or educated experienced advice from professionals, or advice from lay persons or Billy Bob and Bubba or whom you please. DO NOT NECESSARILY GO WITH MINE although I practiced this for years as an engineer, I been retired too long. Electrical and legal questions often draw everyone out of the woodwork all of whom are experts (although a few indeed are) you know, so my final advice is to consult with local authority and the utility provider and go with competent professional advice versus lay persons.
Nuff said
John T