Category Archives: xcode

Making a Mobile App from a WordPress Site

To be competitive in the online market, we all know you need to have a regular website as well as a mobile  website or at least a regular website that is mobile-friendly. Well, these days, that's not enough any longer. You also need to have an app!

The App Era

Why do I need an app when I already have a mobile friendly website?

If you are wondering why you should also have an app, here are some of the more important reasons why you should have an app that features your website in addition to the site itself:

  • We now live in the "era of the apps" or the "app era" as I call it. There are millions of people that use apps everyday but rarely go to their browser to look something up, so by having an app, you expand your viewing audience greatly to a fresh market segment that you would otherwise have no exposure to.
  • Promotion of your website online and in an app store - By making an app out of your already existing mobile website, you can offer it for free in the Google Play Store, Apple/ITunes' App Store and various download locations online.
  • Convenient - since you already have the website made, it's easy to wrap it a native mobile app wrapper with a little know how or you can hire someone to do it for a lot less then the cost of creating a complete app from scratch.

How to Create an iPhone App

This is a starting point for anyone wanting to know how to start developing iPhone apps. There is really only one way to correctly develop apps for iPhones and that is the method we will explain here. Unfortunately, iPhone and Android Apps must be created somewhat differently, although there are some things you can do to minimalize development if you have to create an app for both. However, in this guide, we will only discuss the iPhone app since it is clearly a different beast from Android apps.

As you can imagine, iPhones, Macs and anything Apple are very proprietary in nature, so the number one requirement for developing applications for iPhones is that you must have access to a Mac computer!

Simple Website Wrapper for iPhone Apps using Xcode

In this tutorial, I'll describe how to make a simple website wrapper that will allow you to make an iPhone app out of a website or web based app.

Prerequisites

The main thing you need to have before doing this exersize is a mobile friendly web site or web-based application. See one of my many tutorials on this site regarding responsive web design techniques to get started.

Also basic knowledge of IOS, iPhone and xcode development is needed. If these concepts are new to you, check out:

http://codewithchris.com/how-to-make-iphone-apps-with-no-programming-experience/

You'll find a very intuitive assortment of beginner tutorials on developing with xcode 7 at the above link. The site, coding with Chris, basically is dedicated to teaching xcode to new users and learning experts.

At the time I wrote this tutorial, near the end of 2015, the current version of Xcode was Xcode 7. You can download the latest version of Xcode for Mac at

https://developer.apple.com/xcode/download/

...or go the app store and search for xcode and you'll find it easy enough.

...and unfortunately, you do have to have a Mac to use Xcode, so if you only have a windows machine, you'll have to get a Mac to successfully develop any sort of iPhone apps.

Embedding a Website into an iPhone App with Xcode

After doing extensive research, I have determined that the best method of converting your web-based app or website into an iPhone app that can be offered in the app store is to use Xcode's webView class to wrap the website in a wrapper that makes it act like a native iPhone app. Without wasting any time, here is how I did it:

  1. Open Xcode, start a new "Single View" project and name it whatever you want your app to be named.
  2. Choose your programming language during the project creation procedure in Xcode. You could use objective-C or Swift. For this tutorial, we are using Swift, so select "Swift" as the coding language during the project creation process in Xcode.
  3. In the left navigation panel of xcode you can see the files in your project, click on the "ViewController.swift" filename and it will open it in the editor pane to the right. Make the contents of the file look like this:

import UIKit

class ViewController: UIViewController, UIWebViewDelegate  {

@IBOutlet var webView: UIWebView!

override func viewDidLoad() {
super.viewDidLoad()
let url = NSURL(string: "http://jafty.com")
let request = NSURLRequest(URL: url!)
webView.loadRequest(request)
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}

  1. Now this is the important part that most beginners miss! You have to connect the part of the code that reads "@IBOutlet var webView: UIWebView!", with the view it is in. This is important! Without doing this, it will not work. you have to open both the ViewController.swift file and the view's layout at the same time in two editors and click on the line no. in front of the line that reads "@IBoutlet...." and drag a line to the webview controller in the view's layout dialog window.