Harry Styles and Olivia Wilde have been linked after working together on her upcoming movie Don't Worry Darling

Harry Styles and Olivia Wilde had a cozy weekend before their relationship went public.

The singer, 26, was spotted putting his arms around the actress-director, 36, on Sunday, a day after they attended a friend's wedding together. Styles and Wilde were seen hanging out with a small group of friends in a parking lot and sticking close as the group said their goodbyes. The "Watermelon Sugar" singer leaned in close to Wilde several times as the group chatted.

After Styles and Wilde were seen holding hands at a friend's wedding in Montecito, California, over the weekend, a source confirmed to PEOPLE that "they have dated for a few weeks."

In this week's issue of PEOPLE, on newsstands Friday, sources said Wilde struck up a close friendship with Styles last fall as they began work on her highly-anticipated sophomore directorial project Don't Worry Darling, which she also stars in.

Olivia Wilde, Harry Styles

As they spent time together on-and off-set, their friendship "quickly turned romantic," said an insider. "Their chemistry was very obvious."

"Everyone saw it coming. During breaks, he's hasn't been able to stay away and visited her trailer," the source added.

Olivia Wilde Harry Styles
Harry Styles visits Olivia Wilde's Trailer on the set of "Don't Worry Darling"
| Credit: Backgrid

Wilde cast Styles in the movie in September, replacing former lead Shia LaBeouf. Despite their growing relationship, the two continue to keep things  "very professional" at work.

"Olivia and Harry created this loving and warm environment," said the insider. "Everyone loved working with them. She takes her work very seriously, but everyone saw it coming."

In Styles' recent cover story for Vogue's December issue, Wilde explained why she was so excited for the former One Direction member to bring his enthusiasm to her "incredibly stylistic" movie. Don't Worry Darling counts on Academy Award nominee designer Arianne Phillips (A Single Man) for costume design.

“To me, he’s very modern,” said Wilde of Styles, “and I hope that this brand of confidence as a male that Harry has—truly devoid of any traces of toxic masculinity—is indicative of his generation and therefore the future of the world. I think he is in many ways championing that, spearheading that. It’s pretty powerful and kind of extraordinary to see someone in his position redefining what it can mean to be a man with confidence.”