This is not a one off, nor is the meaning so simple. But it looks like Gandhi himself clarified what he meant when he said it. The London Review has different wording, with ladoos, an Indian pastry:
Of the independence which India sought and achieved, Gandhi said in June 1947: ‘This is like eating wooden ladoos; if they eat it they die of colic; if they don’t they starve.’
Towards a National System of Education has the quote with "wooden loaf", explaining that it is "a well-known Gujarati metaphor". Likely both of those are translations, with "loaf" being the looser, easier-to-understand one. According to The Collected Works of Mahatma Gandhi, Volume 088, the source of the quote is Bihar Pachhi Dilhi (or બિહાર પછી દિલ્હી, Gujarati for "Delhi after Bihar" according to Google Translate).
That it is well known seems true; here's the story (metaphor?) in a completely different context:
Ranjit: So there is the story where golden, wooden ladoos [sweets] are made and they have a very nice colour. Someone says, "Oh, if you eat them you will lose all your teeth." But still he says, "They're very attractive! I want to eat them." He knows they are made from wood and that he might lose his teeth, but he can't help it.
Would you say that Reality is silence reflecting itself?
And this:
Marriage is like a wooden laddu (ball-shaped sweet): if you bite into it you get splinters in your mouth, but if you don’t bite into it you spend the rest of your life wondering how it must have tasted.
The Law Of Karma
And another about marriage:
There is a saying: “The one who eats the wooden ladoo regrets doing so, but so does the one who does not eat it.”
Life Without Conflict: Conflict Resolution