Prepare your apples: Peel, core, and slice the apples into roughly 1/4-inch thick pieces. Aim for uniform thickness so they cook evenly.
Combine dry ingredients: In a large bowl, whisk together the granulated sugar, brown sugar, flour (or cornstarch), cinnamon, nutmeg, allspice (if using), and salt. This ensures the spices and thickener are evenly distributed.
Coat the apples: Add the sliced apples to the bowl with the dry ingredients. Gently toss until all the apple slices are well coated. Stir in the lemon juice to help prevent browning and add a touch of brightness.
Cook the filling: Transfer the coated apples to a large saucepan or Dutch oven. Cook over medium heat, stirring occasionally, for about 10-15 minutes. The apples should begin to soften but still hold their shape. If using flour as a thickener, you may notice it needs a bit longer to cook out the raw flavor.
Thicken and finish: Reduce the heat to low. Add the small pieces of butter to the saucepan. Continue to stir gently until the butter is melted and the filling has thickened to your desired consistency. This usually takes another 5-10 minutes. Be careful not to overcook, as you want the apples to retain some texture.
Cool the filling: Remove the saucepan from the heat and let the apple pie filling cool completely before using it in your pies or other desserts. This allows it to thicken further.