Honest answer: it depends heavily on the country, the city, and how much you invest, but the pattern is consistent enough to describe. Most cultures are friendly to foreigners and slower to befriend them; casual warmth comes easily almost everywhere, while entry into the inner circle of locals whose friendships formed in school takes deliberate effort and time. Big international cities are easiest for finding openness but paradoxically easy places to stay foreign, since you can live entirely in English inside the expat bubble; smaller cities offer fewer foreigners and shallower English, which forces the very integration that ends up feeling most rewarding. Some cultures famously take years to open but hold friendships for life once they do, others befriend fast and lightly, and knowing which type surrounds you sets sane expectations.
The levers that reliably work: language above everything, since even intermediate ability transforms how locals engage with you; joining things with built-in repetition, sports clubs, choirs, volunteering, hobby classes, religious communities, parent networks, because friendship grows from seeing the same faces weekly, not from one-off events; workplaces, which in many countries are the main friendship engine; and accepting invitations even when tired.
Realistic timeline: expect the first year to feel socially thin, the second to turn, and genuine local friendship to be a two-to-three-year project. Nearly everyone who makes it through that arc says the effort repaid itself many times over.