Serve PHP/MySQL with Apache/Nginx/FastCGI on Swift (iOS)

443 Views Asked by At

At work we have a enterprise store, meaning we can kind of bypass most of the main Apple App Store regulations. We have a special data-management system written in CodeIgniter with MySQL as the database engine serving the framework on Apache.

We are now getting more and more questions to run the system offline on the iPad. I've tried to use LocalStorage and such, yet it's just not enough and stable enough (WebStorage/WebSQL glitchy) and the allowed storage size is too small to fit all offline buffered data into.

I know this is very ugly, but as we mostly know, customers always find the most weird ways of requesting features and our sales team always manages to push it through without consulting us :P.

I did browse Google/DuckDuckGo and CocoaPods for a while, but I can't really find anything combining PHP serving within Swift (Objective-C would be ok too) serving it on Apache/Nginx/FastCGI with MySQL (I could substitute this with SQLite3).

I was wondering if anyone has experience with running an internal server in Swift/Objective-C in this fashion.

2

There are 2 best solutions below

0
On

If you wish to keep your current stack of technologies, you could use something like Realm. It is a replacement for Core Data, and it allows you to easily create objects from JSON REST API and store it to the local database. But you still have to write some application specific code to keep data on the mobile device in sync with the server, and you have to have RESTful services that produce JSON on the server.

If you're ready to switch your persistence stack, you could use Couchbase Mobile that allows you to transparently sync your data on the device with data in your backend database, back and forth. But then you have to use Couchbase on the server.

0
On

If you want server-side Objective-C, look at https://github.com/depinette/backtoweb

I have not updated this framework in a while but it worked for me.

It's based on fastcgi and it can be used with the Apache server integrated with OSX.

I suppose you could use swift instead of Objective-C.