Choose Product > Archive in Xcode to archive your project.
Open the Organizer by choosing Window > Organizer.
Select your archived project from the list on the left side of the Organizer.
Click the Distribute App button.
Choose Copy App from the list of options.
Click the Next button.
Pick a location to save the app.
Click the Export button.
Optionally you can copy the exported app to your Applications folder. The following article has more details:
https://www.swiftdevjournal.com/running-a-mac-app-outside-of-xcode/
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags: