Is there a way to code sign ad-hoc iOS apps for longer than 7 days in Xcode?
Free developer membership apps require resigning to be functional after 7 days.

Paid developer membership apps expire after 1 year. You can also submit an app for testing to TestFlight which signs apps for 90 days. You can purchase a developer membership at https://developer.apple.com

If your device is jailbroken, you can resign your apps with a free developer account for as long as you wish, on device with Extender: Reloaded, available from the repo http://repo.incendo.ws.