I have a xcode swift project which I will be sending to someone.
is there a way to make it locked with a licence key or time expiration so that they won't misuse my code?
Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.Sign up to join this community
No - there is no provision for locking or expiration of files and Xcode is even designed to archive parts of builds so don't give your code to anyone you don't trust or can't realistically enforce violation of an agreement to not use/disclose your work. Also, macOS has time machine so there's that way to go back and look at files as they existed in the past.
The typical way to control this is to upload the program / results of a build to TestFlight for testing or valuation. Those apps generally expire after 60 days. That's much harder to reverse engineer than the source code.