Skip to main content

Xcode starter project with the Ionic HTML5 framework using Swift

I mentioned in one of my previous posts, about how I thought the Ionic framework for building HTM5 apps was totally awesome. Well it is and the way I was trying to use it was to build a Hybrid iOS app. Ok, when I say hybrid, I mean the logic for the app is almost equally split between both native code and HTML5 code.

Why Hybrid app?

So the question is, without knowing any native iOS code, how did I come to the conclusion to build a hybrid app? Ok so apparently you can make a fully HTML5 app and use the Apache Cordova framework to build an iOS app without getting your hands dirty with native code, that sounds awesome! However, to me it was important to understand native code, just in the event that something goes wrong in the app and I need to fix it by tweaking native code, I am not completely clueless about how to go about fixing it. So in an attempt to know more about iOS internals, I started off by building simple native programs(apps?) using Swift with Xcode 6 beta at the time and I totally fell in love with Swift. It was at this time that I realised that in addition to Local Notifications, I could leverage one more feature that can come as a result of writing some native code; Core Data. So in my definition, I was no longer building an HTML5 app, I was building a "hybrid" app, that used both HTML5 and native code for the advantages it offered.

So what have I learned? 

So in addition to a whole bunch of useful things about developing for the iOS platform, I also learned that learning iOS development on your own can be a challenging task. In my case this was especially true, because more than learning how to build iOS apps, I was learning how to build iOS apps using Swift i.e. a new technology that has not been around for very long i.e. I started building my app sometime mid-2014. A good majority of the solutions out there for known iOS problems, use Objective-C and  since I lack(ed) Objective-C knowledge, it wasn't/isn't always easy to translate an Objective-C solution to Swift. Of course there exist, awesome developers like Jameson Quave that actually spend the time and effort to try and teach people by walking them through the various steps of building iOS apps. Ray Wanderlich also contains a comprehensive list if tutorials on iOS development with Swift.

So how am I trying to solve the problem I just mentioned?

Ok now that I have poured my heart out, I think it is time to stop procrastinating and get back on topic. So where was I? hmm....thats right, Ionic Rocks! So initially when I wanted to use Ionic framework for my app, I encountered a rather silly issue and at the time I did not bother solving it, because there was really no shortage of independent problems for me to solve. Anyway now that I have solved that rather simple problem that stopped me from using Ionic in my iOS app, I feel like I should share my knowledge and provide like an Xcode/Swift starter project that displays HTML content using the Ionic framework in a UIWebView. Please note, at this point, I am very well aware of the WKWebView, but since I am building something that works on iOS7 and upwards, I have decided to use the UIWebView.

You can fork the project from GitHub and if you think you can improve the project in anyway, please feel free to do so!

Just to be clear...

I received an email from someone asking me how to create an Ionic app with Swift. So to provide some more clarity, with this project you are creating a native iOS app. So what you will need is
  1. A machine that can run Xcode: at this time i.e. mid 2015, only Macs can run it
  2. Some familiarity with how to use Xcode: I would suggest give this tutorial a go! 
So in conclusion, if you are not familiar with Xcode once you create your first Xcode project to make an iOS app, you will be familiar with what I am talking about in this post. This GitHub repo is just an Xcode project template to help you get started on making your HTML5 iOS app.

Finally, I am working on My Day To-Do full-time right now so if you find my blog posts useful and want to support me you can buy the Pro version of My Day To-Do.

Comments

Amrutha said…
Before we get into how to use XCode on Windows, we should first define XCode. So XCode is an Integrated Development Environment (IDE), which is essentially a very powerful piece of software used to create Mac apps. If you intend to design programmes for the Mac OS, you should be aware that XCode is an Apple-created toolset that will help you get there. Designing apps for Windows is a far more doable effort because you can accomplish it on any platform. However, if you want to create Apple applications, XCode is essential.
xcode in windows

Popular posts from this blog

Upload to AWS S3 from Java API

In this post, you will see code samples for how to upload a file to AWS S3 bucket from a Java Spring Boot app. The code you will see here is from one of my open-source repositories on Github, called document-sharing. Problem Let’s say you are building a document sharing app where you allow your users to upload the file to a public cloud solution. Now, let’s say you are building the API for your app with Spring Boot and you are using AWS S3 as your public cloud solution. How would you do that? This blog post contains the code that can help you achieve that. Read more below,  Upload to AWS S3 bucket from Java Spring Boot app - My Day To-Do (mydaytodo.com)

Addressing app review rejections for auto-renewing subscription in-app purchase (iOS)

The ability to know what the weather is like while planning your day is a feature of  My Day To-Do  Pro and as of the last update it’s also a part of the  Lite version . Unlike the Pro version it’s an auto-renewing subscription based  in-app purchase (IAP)  in the Lite version. What means is that when a user purchases it, the user only pays for the subscription duration after which the user will be automatically charged for the next period. Adding an  auto-renewing  subscription based IAP proved to be somewhat challenging in terms of the app store review i.e. the app update was rejected by the App Review team thrice because of missing information about the IAP. Therefore in this post I will share my experiences and knowledge of adding auto-renewing IAP in hopes to save someone else the time that I had to spend on this problem. In-App purchase This year I started adding IAPs to My Day To-Do Lite which lead to learning about different types of IAP...

Serving HTML content in an iOS app that works in iOS 7 and later (using Swift)

As I have mentioned in an earlier post , I really enjoying coding in Swift. Now what am I doing with it? Well I am trying to build an HTML5 app that must work on devices with iOS 7. So in iOS8 apple has introduced a whole bunch of features that facilitate easy communication between web content and lets just call it back-end Swift code, but those features are not in iOS 7. So why do I want to build something that would work in an older OS? well I do not expect existing iOS users to upgrade to iOS 8 straight away and i also know a couple of people who would be very reluctant to upgrade their iPhones to iOS 8. Now in case you do not, you can have a read of the "Working with WebViews" section of this post , to know how to serve HTML content with WebViews. So when I started building my app, I wanted to know: How do I invoke some Swift code from my HTML content? Well the solution to this may feel a little bit "hacky" but it is a solution to achieve this.  The followi...