Fixed solution for SWIFT 3
To make it work, create a new command line tool tool.
Go to “File” → “Create” → “Project” → “macOS” → “Command Line Tool”.
import Foundation print("Hello, World!") func solveMefirst(firstNo: Int , secondNo: Int) -> Int { return firstNo + secondNo } func input() -> String { let keyboard = FileHandle.standardInput let inputData = keyboard.availableData return NSString(data: inputData, encoding:String.Encoding.utf8.rawValue) as! String } let num1 = readLine() let num2 = readLine() var IntNum1 = Int(num1!) var IntNum2 = Int(num2!) print("Addition of numbers is : \(solveMefirst(firstNo: IntNum1!, secondNo: IntNum2!))")
And run the project using CMD + R
source share