Swift Tutorial to add library framework from Github

This tutorial explains how to add library framework from Github.

Imagine you refer to this page that having list of frameworks, and you would like to install one of the library, such as SwiftHTTP.

Step 1:

Go to the root folder of your application.

Run git submodule add <Github URL>

E.g. git submodule add https://github.com/daltoniam/SwiftHTTP

Step 2:

Open SwiftHTTP folder under the root folder of your application.

Drag SwiftHTTP.xcodeproj to your XCode Project.

Refer to below picture, drag SwiftHTTP.xcodeproj to Chats, the top level hierarchy of project.

Step 1 Drag xcodeproj to Project hierarchy

 

Step 3:

Click on SwiftHTTP.xcodeproj that added to your project hierarchy.

Check Deployment Target under General Tab.

Make sure it is the same with your application’s deployment target.

Step 3 Check Deployment Target

 

Step 4:

Click on your main application, under Build Phases Tab, click “+” under target dependencies section.

The end result is something like this.

Screen Shot 2014-12-22 at 7.53.12 pm

Step 5:

Add a new phase by clicking “+”  under Build Phases Tab, and choose “New Copy File Phase”, change the name to “Copy Frameworks”.

Screen Shot 2014-12-22 at 7.54.24 pm

Step 6:

Under the new phase “Copy Frameworks” added in last step, destination choose “Framework”, and add the frameworks.

The end result something like this

Screen Shot 2014-12-22 at 7.56.12 pm

 

Then test your code with the library:

 


var request = HTTPTask()
var params = ["k": "q:name=currency,stat=swift", "api" : "1", "server_host" : "swift"]
request.requestSerializer.headers["X-Mashape-Key"] = "Ri4j5gX4ORmshweHbjBSUUMevXWIp1i0xRujsnjCz7wW9w5zLB"
request.GET("https://imgshow-platform.p.mashape.com/", parameters: params, success: {(response: HTTPResponse) in
if let data = response.responseObject as? NSData {
let str = NSString(data: data, encoding: NSUTF8StringEncoding)
println("response: \(str)") //prints the HTML of the page
}
},failure: {(error: NSError, response: HTTPResponse?) in
println("error: \(error)")
})

 

Enhancing my personal reminder apps with outbounds calls feature

I had my own personal reminder apps for years. This reminder apps is greatly improving my schedule in workings and personal. I use the apps to remind me when to pay rent, when is the meeting held, and so on, day to day.

This is a simple reminder apps simply managing a list of tasks. I can configure a task name, start end time (hhmm format, such as 1000), a reminder text, then enter enabled field as 1 (To enable 1, To disable 0). Then I would configure the system check for the reminder every 10 min. If the current time drop between the start end time, it will simply remind me by sending an Apple APN Notification or Google GCM Notification.

Reminder Iphone Sample Task

I did built an outbounds call features last year using Freeswitch Outbounds SIP. But it is not user friendly as, I have to open the SIP Phone all the time in order to receive the outbounds call. I wonder why Apple do not have SIP built in into system core, like Samsung Phone.

Since this morning I just figure out to make outbounds calls to landline or cellphone from Freeswitch, therefore I would like to enhance my personal reminder apps with outbounds call feature.

When the time arrive, it will try contact me and announce the reminder text I configure that task.

It is not feasible to call me every 10 min, so I made it to have the task to only call me one time and it will going to sleep after that.

When creating the task, if enter “enabled” as 1, it will perform usual action, notify me via Apple APN. If enter as 2,  it will make outbounds call service. After made calls, update back to 0 to disable the task.

In this simple reminder apps system architecture, I greatly adopt microservice style. Each service itself is self-managed (start/stop/status individually), and only do a single task. Then they are able to support other apps if configure the way and the working flow. Like the reminder apps is actually a single service to schedule the tasks, have an admin interface to manage it. Cron job apps is another service to schedule HTTP cron job URL, have an admin interface to manage it, I created Reminder Apps Cron Job to trigger the reminder apps checks. Apple APN is another single service that send APN notification to Apple. Google GCM is another apps is another service to send message to Samsung (Sometimes I closed it when I am not in Malaysia). Today, a new service is created, is for outbounds call web service. Most of the web service I created here, are using Node.JS as server side, and Titanium Mobile (iPhone apps), and all using JavaScript. A little web service are using Java back end. All web services are secured using API Keys and Password Authentication for cross communication.