The guilds were the antecedents of modern unions.
The development of Freemasonry is entirely unrelated to that of guilds. If anything, Freemasonry sought to serve as a refuge for those rejected by the guilds, either because they did not fit or because they would not fit.
The guilds openly favoured many factors above skill, craft, or profession. Jews, of course, were denied entry into any and all of the guilds, because they were Jews. Gypsies, too. And the non-Saxon, i.e., the Celts, the Welsh, Scots, and Irish, in England. More important were race, ethnicity, family origin, region of origin, religion, socio-economic status, political affiliation, size of bribe attending application, et cetera.
Favouritism, cronyism, nepotism, discrimination, all determined who got in, and who did not.
To contribute to the reputation of a guild, once admitted, one had to submit to the will of guild. Loyalty – the least of virtues – was demanded. Betrayal of that loyalty meant expulsion, and ostracisation.