Preheat the oven to 375 degrees F.
Put the bacon in a large, cold cast-iron skillet and cook over medium heat until the fat renders and the bacon is almost crisp, about 8 minutes.
Add the apple and onion. Cook, stirring occasionally, until the apple is crisp-tender, about 6 minutes.
Add 2 cans of beans with their liquid to the skillet.
Rinse and drain the remaining can of beans, and add it to the skillet.
Add the ketchup, molasses, sugar, mustard, vinegar, 1/2 teaspoon salt and pepper to taste, and stir to combine.
Bring the beans and apples to a low simmer, then transfer the skillet to the preheated oven.
Bake uncovered, until the apples are tender and jammy, about 30 minutes.