Build iOS Mobile Application in Windows with Swift – Many students and bloggers are still struggling to develop iOS application, because they have no mac operating system this is one of the most reason to all other students and even staffs. But this is very simple even you have don’t mac operating system, you have always try to build the iOS app in Windows, its also possible for everyone.

textgram_1477822361

Now i have also used Windows operating system and i also develop one simple iOS application using Virtual Machine. So you have just click to download the virtual machine for mac

Build iOS Mobile Application in Windows with Swift

I have used one framework to develop iOS application that’s called Vapor which wriiten in swift and you have easily build the iOS mobile application in Vapor. If you are new in Swift and Vapor, don’t hesitate its very simple framework you can easily learn all other techniques in swift.

If you have already virtual machine and installed MAC then you have move on next step like swift installation suppose you have don’t virtual machine and not installed MAC, no problem just install VM and get MAC on your system its very easy procedure.

Install Swift Dashboard

Now the server side web framework Vapor is built on your Swift dashboard. Then add the Swift Package Manager to your Vapor framework. The swift package manager help to manage your all code in develop the app whatever you like, so just learn few techniques before proceed the swift package manager in your application.

Instead, you have used another way to build your application there are multiple options will be there in develop the iOS application this is major advantage of iOS developer so now you have understand why all users like develop iOS application. Alternatively you have install the Swift Version Manager in GitHub. Then just clone the project on your system and run the shells in command prompt.

git clone https://github.com/kylef/swiftenv.git ~/.swiftenv
 
echo 'export SWIFTENV_ROOT="$HOME/.swiftenv"' >> ~/.bash_profile
echo 'export PATH="$SWIFTENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(swiftenv init -)"' >> ~/.bash_profile

This is alternative way to build iOS app in swift through Vapor framework. Supposee you have some doubt in this way feel free to ask me via comments.

Next, we have install the one of Swift development package in command prompt. so just enter below commands after installing the Swift Package Manager.

swiftenv install DEVELOPMENT-SNAPSHOT-2016-05-31-a

Initialize First iOS application

Now times to build your irst iOS application in Vapor framework. I have develop simple project like one of paragraphs to be executed on the iOS application. First we have create the application name then the Swift Package Manager automatically fetch the build code from Vapor framework. Create one directory name which is used for store your application file, like the directory and our application content name is My_First_iOS_Application

mkdir My_First_iOS_Application
cd My_First_iOS_Application

swiftenv local DEVELOPMENT-SNAPSHOT-2016-05-31-a
swift package init --type executable

After running this script, the swift package manager creates two files like,

1. Sources/main.swift – this is the file where your code starts and runs.
2. Package.swift – this file stores information about your code, and its dependencies.

Include Vapor Manager

To install Vapor, we will add vapor dependency to our application in Package.swift. Then just replace your package.swift file with following coding:

import PackageDescription
 
let package = Package(
    name: "HelloWorld",
    dependencies: [
        .Package(url: "https://github.com/qutheory/vapor.git", majorVersion: 0, minor: 10)
    ]
)

Generate Xcode file

Next, we want add Swift Package Manager in Vapor dependencies. It can be generate as the Xcode file for your requirements like used your application. If you don’t like this editor, just ignore them and go on the next editor as you like:

swift package generate-xcodeproj
open My_First_iOS_Application.xcodeproj

Develop Vapor Code on your application

Firts let’s view the Xcode (or your favorite text editor as you want), open the main.swift file. In Xcode, you have need to make sure that you are running the correct version of Swift.

Build iOS Mobile Application in Windows with Swift

Now you have add the replace the existing code main.swift with:

import Vapor
 
let app = Application()
 
app.get("/") { request in
    return "This is my first iOS Application"
}
 
app.start()

In this code, we have import the Vapor Library, and initialize the Application object.

Run the Application

To run the app, open the directory My_First_iOS_Application target in Xcode, or execute the command line using the following code:

swift build
.build/debug/My_First_iOS_Application

Then just visit on browser localhost:8080 the output look like this,

Build iOS Mobile Application in Windows with Swift

We hope you have catch some idea in develop the mobile application, still struggling in develop the iOS app just go through the Swift Programming tutorial.