'xcode build to iPhone device it has an invalid code signature

I wanted to build my project in my iPhone, I got this error message

The operation couldn’t be completed. 
Unable to launch com.xxxx.test because it has an invalid code signature, 
inadequate entitlements or its profile has not been explicitly trusted by the user.

I tried to go to settings> general> VPN and device management but I have nothing inside it I only have the possibility to log in with a work or school account and nothing else. My app does not appear in the VPN and device management section therefore I cannot authorize anything.How can I fix it? Thanks.

Xcode 13.0 iPhone X iOS 15



Solution 1:[1]

This solved my case.

iPhone Settings -> General -> VPN and device management -> From "Developer App" section found "Apple Development: APPLE_ID" -> Trust 

See the screenshots:

enter image description here enter image description here

Solution 2:[2]

There are two solutions :

  • Solution 1: open System Preferences -> Users & Groups -> Add a user account (build with the new user is successfully

  • Solution 2: Open Keychain Access -> choose System, All Items -> delete certificate Apple Worldwide Developer Relations Certification Authority

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dharman
Solution 2 Saumya Gautam