Programming with swift backend and Angular 2 front. Is it possible? - ios

I didn't find anything on Google saying about it.. so, is it possible?
i.e discard the XCode's Storyboard and use Angular 2 to make apps.
PS: Swift isn't discartable for me due frameworks and done backend code. I am using FFT algorythm from Swift's AudioKit Framework.

Angular2 can be used with any compliant web server written in any language. As long as it speaks HTTP correctly it doesn't matter what it's written in.
Angular2 is a front end JavaScript based technology. As long as you have a web viewer that can render HTML and has a standards compliant JavaScript runtime you can make it talk to your back end.
You can wrap it in an app store compatible package but it will still be a JavaScript app and will connect to your backend in the exact same way that it would if you targeted the browser. The difference is it'll be able to leverage certain device specific capabilities. You will communicate with your backend by sending JSON (any format can be used) back and forth.
The key point is that all communication will be in the form of serialized messages only.
Even if your backend were running on the same device, there's no shared memory space.
Of course since a mobile app can persist it's own state locally it might not need a backend at all. This last point is very domain specific.

It could be posibble if you use Vapor as your backend engine. Take a look at Vapor's website for more info.

Related

Build entire iOS app as a website?

This might be a silly question, but wondering if I was able to build an iOS app completely in a UIWebview. Essentially not have one thing be native to iOS.
You can actually. There are several ways to use HTML5, CSS3, and Javascript to make mobile apps like iOS. You can use frameworks/programs like Cordova/PhoneGap. These frameworks/programs can let you use web languages and then compile it into an executable for the device. Something that can be submitted to the AppStore. Whether or not Apple accepts it thats another story. ;)
The other thing you can do is you want it to completely run off the web is you can essentially build a web app on a server like any other web app. However, you can put in CSS3 media queries and Javascript that can detect the size of the screen. Users can use their built in web browsers to access your site. If the screen isn't the right size, then you can redirect the user like if they try to access it with a laptop. With this method you can use server side scripting languages like PHP to do your computation processing. However, connection is required to the server and if a whole lot of people log in to your server, then the server can get bog down.
If you are interested in using web base languages for mobile applications, I highly suggest looking into PhoneGap/Cordova.

How to download external data such as json for use by ios

I have built a web app in php (beginner programmer) which displays local json data in table format and am now wanting to recreate the functionality in iOS.
For my web app I use a shell script run from my webserver to CURL the remote data from an API and store 'locally' (in my root folder on my web server), and then access and parse from there using php.
I am trying to work out how to do this for iOS (at a basic level, not worrying about caching for offline use at this stage).
What are the means (I assume classes and methods, I am new to OOP) within iOS to get (using http GET) external data and store it locally?
Where is the usual place to store it?
Much searching hasn't helped, partly due to my newness with Swift and OOP. I think I just need a starting place for my iOS learning journey and am hoping that some high level signposts and perhaps even methods and classes to search for will help me go on and get my hands dirty.

Apple swift - How can an app connect to existing heroku/S3 database

Im new to iOS and new to SWIFT with no previous experience with Obj-C. But, Im not new to Ruby. I have a web based app on heroku and am beginning to learn SWIFT so I can build an iOS counterpart. I need to wrap my head around the bigger picture before I can get started and I can not figure out how these apps connect to databases.
Can an iOS app connect to an S3 database...and share that database with a website? Is there documentation on this process that I have over looked.
Connecting an iOS app to a public database would really be a bad idea - all server logic should be implemented on the client, and you would also need to hardcode database user name and password in your app.
A better way is to create a server app exposing a set of REST APIs and being responsible of dealing with the database. This way you can better control at server side what the app client is able to do on the database.
If you have an order entry app, for instance, you can create APIs to:
login
register
create an order
modify an order
add a contact
delete a contact
etc...
Some of the advantages are that:
in case you need to update the logic (but not the API interface), you just need to update the server, whereas in your scenario you'd need to release a new version of the mobile app
you control and limit how client apps access to the data (preventing for instance a user to access another user's orders)
if you want to develop the same app in another platform (android, ...), you reuse the same APIs
To get started, I'd suggest you to read the AFNetworking tutorial on raywenderlch.com, focused on a ios networking library, but talking about JSON, REST, remote APIs etc.
Next you have to choose a server side technology - the most popular nowadays is node.js - to get started you can read other tutorials on the same website:
http://www.raywenderlich.com/61078/write-simple-node-jsmongodb-web-service-ios-app
http://www.raywenderlich.com/61264/write-ios-app-uses-node-jsmongodb-web-service
if you don't want to use node.js and/or mongodb... the same architecture applies, just languages and technologies differ. Just transpose what you learn from there.
If you want to read about other languages to use at server side, just google for it - if you want to use ruby, try with ios rest api server ruby.
Note: I made no mention of swift because your question looks more like an architectural problem than a language specific problem. The tutorials I mentioned here use objective-c, once you've designed an architecture and chosen the language at server side, you can start looking into how to call REST API from swift.

PhoneGap with Django Backend

I'm working on a web application that uses django.
I would like to create a native application of the site for ios / android using phone gap.
Is this possible? As I understand native devices cannot interpret python code.
It is early in the project and if it proves too difficult I may go with a different framework I.e backbone.js.
Any thoughts / experiences?
That's right, you cannot run python code on iOS or Android using PhoneGap, but there is no need to do that. Yes, you can build a native mobile application of your site using PhoneGap.
I'll try to explain a bit how these technologies compare to each other:
Django is a python web framework running on a web server
PhoneGap is a framework for building native mobile applications using web technologies (HTML5+CSS+Javascript), the application will run on a mobile device
One common approach is to build the mobile UI with i.e. jQuery Mobile and use the Django web application to provide a RESTful API to get data to the application.
Take a look at this another question for more details.
Edit: Answer the question in the first comment
Yes, it's possible to build a fast and well working application with these frameworks. The performance with today's smartphones is more dependent on the quality of the implementation than i.e. jQuery mobile and Django in themselves.
Basically with PhoneGap there are three different ways for showing the content to the user:
server side generated pages
pages generated on the client side with Javascript usin data from the server, transferred in a predefined format using for example JSON
a combination of the previous two
This answer clarifies server-client communication and page rendering quite well.
You could use PhoneGap a bit like a constrained web browser, and basically show content directly from your server as you would when the user accesses the site with a normal web browser. But I don't recommend this, though. This approach has many downsides to it (i.e. what happens when the user opens a link from your website leading to another website?)
To be accurate, at least in my opinion, UI written with Javascript and running inside an app built with PhoneGap is not native. Comparing native applications and PhoneGap applications is another thing, here is one take on explaining the differences.
I don't know what kind of service you are building, but in general I'd suggest evaluating the different approaches before starting to build an application. Would a responsive mobile optimized web site do or is there real need for what an app can provide?
If you decide to build an app with PhoneGap, I'd suggest that you do it with client side Javascript and fetch the data from the Django backend with XHR requests in JSON format. There are lots of examples available in the internet.

Communication between Rails apps

I have built two rails apps that need to communicate and send files between each other. For example one rails app would send a request to view a table in the other apps' database. The other app would then render json of that table and send it back. I would also like one app to send a text file stored in its public directory to the other app's public directory.
I have never done anything like this so I don't even know where to begin. Any help would be appreciated. Thanks!
You requirement is common for almost all the web apps irrespective of rails, Communicating with each other is required by most modern web apps. But there is a small understanding that you need to get hold on,
Web sites should not directly access each others internal data (such as tables), (even if they are build by the same language (in this case Rails) by the same developer),
That is where the web-services comes in to play, So you should expose your data through web services so that not only rails application can consume that, but also any app that knows how to consume a web service will get benefit.
Coming back to your question with Rails, rails supports REST web services out of the box, So do some googling about web services, REST web services with rails
HTH
As a starting point, look at ActiveResource.
Railscast
docs
Message queuing systems such as RabbitMQ may be used to communicate things internally between different apps such as a "mailer" app and a main "hub" application.
Alternatively, you can use a shared connection to something like redis stick things onto a "queue" in one app and read them for processing from the other.
In recent Rails versions, it is rather easy to develop API only applications. In the Rails core master, there was even a special application type for these apps briefly (until it got yanked again). But it is still available as a plugin and probably one day becomes actually part of Rails core again. See http://blog.wyeworks.com/2012/4/20/rails-for-api-applications-rails-api-released for more information.
To actually develop and maintain the API of the backend service and make sure both backend and frontend have the same understanding of the resources, you can use ROAR which is great way to build great APIs.
Generally, you should fully define your backend application with an API. Trying to be clever and to skip some of the design steps will only bring you headaches in the long run...
Check out Morpheus. It lets you create RESTful services and use familiar ActiveRecord syntax in the client.

Resources