Skip to content

Commit

Permalink
Resolved issue in iOS/Mac OSx
Browse files Browse the repository at this point in the history
Added the sample project for Mac OSx
Updated the readme file.
  • Loading branch information
vigneshuvi authored and Vignesh Kumar committed Mar 11, 2020
1 parent 0be5579 commit 8e1f5bf
Show file tree
Hide file tree
Showing 20 changed files with 1,935 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ Examples/ObjectiveC/Demo/xcodebuild.log
Examples/ObjectiveC/build
Examples/ObjectiveC/Pods/*

Examples/MacOS/SampleMacSwift/SampleMacSwift.xcworkspace/*
Examples/MacOS/SampleMacSwift/xcuserdata
Examples/MacOS/SampleMacSwift/xcodebuild.log
Examples/MacOS/SampleMacSwift/build
Examples/MacOS/SampleMacSwift/Pods/*

Examples/CarthageExport/Carthage/*

*.lock
Expand Down
24 changes: 24 additions & 0 deletions Examples/MacOS/SampleMacSwift/Podfile
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 Examples/MacOS/SampleMacSwift/SampleMacSwift.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions Examples/MacOS/SampleMacSwift/SampleMacSwift/AppDelegate.swift
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
}


}

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"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions Examples/MacOS/SampleMacSwift/SampleMacSwift/Info.plist
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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
col1,col2,col3
a,b,c
col1,col2,col3
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 Examples/MacOS/SampleMacSwift/SampleMacSwift/ViewController.swift
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("vigneshuvi@gmail.com", 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("vinoth@gmail.com", 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 = "John@gmail.com"
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 Examples/MacOS/SampleMacSwift/SampleMacSwiftTests/Info.plist
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>
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.
}
}

}
Loading

0 comments on commit 8e1f5bf

Please sign in to comment.