-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the sample project for Mac OSx Updated the readme file.
- Loading branch information
1 parent
0be5579
commit 8e1f5bf
Showing
20 changed files
with
1,935 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Uncomment this line to define a global platform for your project | ||
|
||
target 'SampleMacSwift' do | ||
# Comment this line if you're not using Swift and don't want to use dynamic frameworks | ||
use_frameworks! | ||
|
||
pod 'SwiftLoggly’ | ||
# pod 'SwiftCSVExport' | ||
pod 'SwiftCSVExport', :git => 'https://github.com/vigneshuvi/SwiftCSVExport.git', :tag => '2.1.0' | ||
# Pods for SampleMacSwift | ||
target 'SampleMacSwiftTests' do | ||
inherit! :search_paths | ||
# Pods for testing | ||
end | ||
target 'SampleMacSwiftUITests' do | ||
inherit! :search_paths | ||
# Pods for testing | ||
end | ||
|
||
end |
728 changes: 728 additions & 0 deletions
728
Examples/MacOS/SampleMacSwift/SampleMacSwift.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
Examples/MacOS/SampleMacSwift/SampleMacSwift/AppDelegate.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// AppDelegate.swift | ||
// SampleMacSwift | ||
// | ||
// Created by Vignesh, Kumar (623-Extern) on 11/03/20. | ||
// Copyright © 2020 Vignesh, Kumar (623-Extern). All rights reserved. | ||
// | ||
|
||
import Cocoa | ||
|
||
@NSApplicationMain | ||
class AppDelegate: NSObject, NSApplicationDelegate { | ||
|
||
|
||
|
||
func applicationDidFinishLaunching(_ aNotification: Notification) { | ||
// Insert code here to initialize your application | ||
} | ||
|
||
func applicationWillTerminate(_ aNotification: Notification) { | ||
// Insert code here to tear down your application | ||
} | ||
|
||
|
||
} | ||
|
58 changes: 58 additions & 0 deletions
58
...ples/MacOS/SampleMacSwift/SampleMacSwift/Assets.xcassets/AppIcon.appiconset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "mac", | ||
"size" : "16x16", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "16x16", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "32x32", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "32x32", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "128x128", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "128x128", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "256x256", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "256x256", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "512x512", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"size" : "512x512", | ||
"scale" : "2x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
Examples/MacOS/SampleMacSwift/SampleMacSwift/Assets.xcassets/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
737 changes: 737 additions & 0 deletions
737
Examples/MacOS/SampleMacSwift/SampleMacSwift/Base.lproj/Main.storyboard
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>$(DEVELOPMENT_LANGUAGE)</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIconFile</key> | ||
<string></string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
<key>LSMinimumSystemVersion</key> | ||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string> | ||
<key>NSHumanReadableCopyright</key> | ||
<string>Copyright © 2020 Vignesh, Kumar (623-Extern). All rights reserved.</string> | ||
<key>NSMainStoryboardFile</key> | ||
<string>Main</string> | ||
<key>NSPrincipalClass</key> | ||
<string>NSApplication</string> | ||
<key>NSSupportsAutomaticTermination</key> | ||
<true/> | ||
<key>NSSupportsSuddenTermination</key> | ||
<true/> | ||
</dict> | ||
</plist> |
3 changes: 3 additions & 0 deletions
3
Examples/MacOS/SampleMacSwift/SampleMacSwift/Resource/test.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
col1,col2,col3 | ||
a,b,c | ||
col1,col2,col3 |
14 changes: 14 additions & 0 deletions
14
Examples/MacOS/SampleMacSwift/SampleMacSwift/SampleMacSwift.entitlements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>com.apple.security.app-sandbox</key> | ||
<true/> | ||
<key>com.apple.security.files.downloads.read-write</key> | ||
<true/> | ||
<key>com.apple.security.files.user-selected.read-write</key> | ||
<true/> | ||
<key>com.apple.security.network.client</key> | ||
<true/> | ||
</dict> | ||
</plist> |
131 changes: 131 additions & 0 deletions
131
Examples/MacOS/SampleMacSwift/SampleMacSwift/ViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
// | ||
// ViewController.swift | ||
// SampleMacSwift | ||
// | ||
// Created by Vignesh, Kumar (623-Extern) on 11/03/20. | ||
// Copyright © 2020 Vignesh, Kumar (623-Extern). All rights reserved. | ||
// | ||
|
||
import Cocoa | ||
import Foundation | ||
import WebKit | ||
import SwiftCSVExport | ||
|
||
class User { | ||
var userid:Int = 0 | ||
var name:String = "" | ||
var email:String = "" | ||
var isValidUser:Bool = false | ||
var message:String = "" | ||
var balance:Double = 0.0 | ||
} | ||
|
||
|
||
class ViewController: NSViewController { | ||
|
||
@IBOutlet var webview: WKWebView! | ||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
// Generate CSV file | ||
let user1:NSMutableDictionary = NSMutableDictionary() | ||
user1.setObject(107, forKey: "userid" as NSCopying); | ||
user1.setObject("vignesh", forKey: "name" as NSCopying); | ||
user1.setObject("[email protected]", forKey: "email" as NSCopying); | ||
user1.setObject(true, forKey:"isValidUser" as NSCopying) | ||
user1.setObject("Hi 'Vignesh!', \nhow are you? \t Shall we meet tomorrow? \r Thanks ", forKey: "message" as NSCopying); | ||
user1.setObject(571.05, forKey: "balance" as NSCopying); | ||
|
||
let user2:NSMutableDictionary = NSMutableDictionary() | ||
user2.setObject(108, forKey: "userid" as NSCopying); | ||
user2.setObject("vinoth", forKey: "name" as NSCopying); | ||
user2.setObject(false, forKey:"isValidUser" as NSCopying) | ||
user2.setObject("[email protected]", forKey: "email" as NSCopying); | ||
user2.setObject("Hi Vinoth", forKey: "message" as NSCopying); | ||
user2.setObject(567.50, forKey: "balance" as NSCopying); | ||
|
||
let data:NSMutableArray = NSMutableArray() | ||
data.add(user1); | ||
data.add(user2); | ||
|
||
let user3 = User() | ||
user3.userid = 109 | ||
user3.name = "John" | ||
user3.email = "[email protected]" | ||
user3.isValidUser = true | ||
user3.message = "Hi Vignesh" | ||
user3.balance = 105.41; | ||
data.add(listPropertiesWithValues(user3)) // Able to convert Class object into NSMutableDictionary | ||
|
||
let header = ["userid", "name", "email", "message", "isValidUser","balance"] | ||
// Create a object for write CSV | ||
let writeCSVObj = CSV() | ||
writeCSVObj.rows = data | ||
writeCSVObj.delimiter = DividerType.comma.rawValue | ||
writeCSVObj.fields = header as NSArray | ||
writeCSVObj.name = "userlist2" | ||
|
||
// Write File using CSV class object | ||
let output = CSVExport.export(writeCSVObj); | ||
if output.result.isSuccess { | ||
guard let filePath = output.filePath else { | ||
print("Export Error: \(String(describing: output.message))") | ||
return | ||
} | ||
|
||
print("File Path: \(filePath)") | ||
self.readCSVPath(filePath) | ||
} else { | ||
print("Export Error: \(String(describing: output.message))") | ||
} | ||
|
||
let fileManager = FileManager.default | ||
if let fileURL = Bundle.main.url(forResource: "test", withExtension: "json") { | ||
print(fileURL) | ||
|
||
let filePath = fileURL.path | ||
// Check if file exists | ||
if fileManager.fileExists(atPath: filePath) { | ||
print("File exists") | ||
//self.readCSVPath(filePath, Bundle.main.bundleURL) | ||
} else { | ||
print("File does not exist") | ||
} | ||
} | ||
|
||
} | ||
|
||
func readCSVPath(_ filePath: String, _ basePath: URL) { | ||
|
||
let requestURL = URL(fileURLWithPath: filePath) | ||
webview.loadFileURL(requestURL, allowingReadAccessTo: basePath) | ||
|
||
// Read File and convert as CSV class object | ||
_ = CSVExport.readCSVObject(filePath); | ||
|
||
// Use 'SwiftLoggly' pod framework to print the Dictionary | ||
// loggly(LogType.Info, text: readCSVObj.name) | ||
// loggly(LogType.Info, text: readCSVObj.delimiter) | ||
} | ||
|
||
func readCSVPath(_ filePath: String) { | ||
|
||
let requestURL = URL(fileURLWithPath: filePath) | ||
webview.loadFileURL(requestURL, allowingReadAccessTo: requestURL.deletingLastPathComponent()) | ||
|
||
// Read File and convert as CSV class object | ||
_ = CSVExport.readCSVObject(filePath); | ||
|
||
|
||
|
||
|
||
|
||
// Use 'SwiftLoggly' pod framework to print the Dictionary | ||
// loggly(LogType.Info, text: readCSVObj.name) | ||
// loggly(LogType.Info, text: readCSVObj.delimiter) | ||
} | ||
|
||
|
||
|
||
} | ||
|
22 changes: 22 additions & 0 deletions
22
Examples/MacOS/SampleMacSwift/SampleMacSwiftTests/Info.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>$(DEVELOPMENT_LANGUAGE)</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
</dict> | ||
</plist> |
34 changes: 34 additions & 0 deletions
34
Examples/MacOS/SampleMacSwift/SampleMacSwiftTests/SampleMacSwiftTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// SampleMacSwiftTests.swift | ||
// SampleMacSwiftTests | ||
// | ||
// Created by Vignesh, Kumar (623-Extern) on 11/03/20. | ||
// Copyright © 2020 Vignesh, Kumar (623-Extern). All rights reserved. | ||
// | ||
|
||
import XCTest | ||
@testable import SampleMacSwift | ||
|
||
class SampleMacSwiftTests: XCTestCase { | ||
|
||
override func setUp() { | ||
// Put setup code here. This method is called before the invocation of each test method in the class. | ||
} | ||
|
||
override func tearDown() { | ||
// Put teardown code here. This method is called after the invocation of each test method in the class. | ||
} | ||
|
||
func testExample() { | ||
// This is an example of a functional test case. | ||
// Use XCTAssert and related functions to verify your tests produce the correct results. | ||
} | ||
|
||
func testPerformanceExample() { | ||
// This is an example of a performance test case. | ||
self.measure { | ||
// Put the code you want to measure the time of here. | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.