You will need an API (REST, etc.) running on a web server, with that web server having access to the firewalled-off database server. And authentication for your API so that you don’t have random people DDoSing your service and database.
Your database server should not be exposed to the internet at all, nor directly accessible from your client. Nor should you be sending SQL queries directly from the client through to the database server. Your API exposes a set of functionality and is very restrictive about what the client can request and receive.
Mobile app -> internet -> web server -> firewall -> SQL Server
You will probably not build this API service in Xcode, as Xcode is really meant for macOS and iOS development, not web server development.
The details of “how do I implement this” far exceed the scope of Stack Overflow. There are numerous tutorials and walkthroughs available online. Choose wisely.
solved How to connect Xcode project to existing MsSql server