In a frying pan, heat the olive oil over medium heat.
Add the onions and stir to coat with the oil. Reduce the heat to low and cook, stirring often, until the onions are caramelized to a deep golden brown, about 45 minutes.
Put the apples in a saucepan and add 1/4 cup water. Simmer over low heat until very tender, about 30 minutes. Mash the apples, but leave some nice chunky texture.
Add the onions, brown sugar, ginger, allspice, lemon zest and juice, and a pinch of salt to the pan with the apples and stir to mix well.