Facebook released version 5.0 of its iPhone and iPad app Thursday. It’s a complete rewrite of the app. It actually works now. The iOS Facebook experience has been miserable for a long time. With Apple on the verge of releasing Facebook integration to both OS X and iOS, the update is only the beginning of a much closer alliance between the two tech Titans against their common enemy: Google.

Before, the Facebook app was just a thin wrapper for what were actually Web views. It wasn’t rendering Facebook with native code on the device. It was all running on Facebook’s servers, which made it grindingly slow and often resulted in absurd, inexplicable behavior. Users would tap on something to expand it and have something completely unrelated load instead.

Now Facebook is a real iOS app. It loads fast, it scrolls smoothly, and it feels built into the iPhone and iPad. The visual design isn’t a huge change, though there are some more natural gestures you’ll notice.

Facebook has two other fully native iOS apps that complement this update well. Its Facebook Messenger app allows for quicker individual and group messaging via Facebook, and Facebook Camera is the fastest way to shoot and upload photos to Facebook, as well as an attractive way to browse photo posts only.

Neither of these apps is necessary – the flagship Facebook app can handle messages and photos – but together they make Facebook into a more complete part of the iOS experience. It’s a new direction for Facebook, which once ran headlong towards a totally Web-based future.

Facebook has seen the drawbacks of an all-Web approach, and it has turned back. After a false start with Apple’s poorly received Ping music service, Facebook and Apple have found a way to work together, to the point that Facebook will soon be a built-in option for sharing and login on all of Apple’s platforms.

Why the about-face? Apple and Facebook have realized that by teaming up, they can squeeze out their common enemy: Google.

Google and Facebook clash over social software, and Google and Apple clash over mobile hardware and operating systems. These two areas of technology are increasingly intertwined. Our phones are where we communicate, and where we do much of our searching. All of these companies want to own this activity.

By teaming up with Facebook, Apple gets all the advantages of the social network without any of the costs, including the kinds of personalization Google wants to build with Google+. And by joining with Apple, Facebook becomes more central to the lives of Apple’s elite customers. If Google gets squeezed off of the iPhone, both Apple and Facebook stand to gain.