Being attached to a larger polity by no means that a small language community must be marginalized. Icelandic and Faroese survived centuries of union with a much larger and wealthier Denmark, to name one example not at random.
But those aren't places of mass immigration. Neither the UK nor Canada has an incentive to limit non-Gaelic immigration, and if the Gaelic region is part of a massive non-Gaelic country, its citizens will have an incentive to learn the majority language.
The other issue is that, as mentioned above, English is an increasingly dominant language as the 19th and 20th centuries progress. That makes it even tougher for Gaelic to survive. I think it needs strong political intervention.