In-group favoritism is a central aspect of human behavior. People often help members of their own group more than members of other groups. Here we propose a mathematical framework for the evolution of in-group favoritism from a continuum of strategies. Unlike previous models, we do not pre-suppose that players never cooperate with out-group members. Instead, we determine the conditions under which preferential in-group cooperation emerges, and also explore situations where preferential out-group helping could evolve. Our approach is not based on explicit intergroup conflict, but instead uses evolutionary set theory. People can move between sets. Successful sets attract members, and successful strategies gain imitators. Individuals can employ different strategies when interacting with in-group versus out-group members. Our framework also allows us to implement different games for these two types of interactions. We prove general results and derive specific conditions for the evolution of cooperation based on in-group favoritism.