Good music in a movie is not only good music but also music that is in sync with what happens on the screen. I can imagine it's not a trivial job to achieve this. So it made me wonder what generally comes first. Is the music written first and are the takes and cuts "choreographed" around it, or is the music written afterwards?
To make this an answerable question I'd like to focus on feature films, not musical films. And I'd like to know the general trend, because obviously there will always be exceptions to the rule.