mirror of
https://github.com/jmcnamara/libxlsxwriter
synced 2025-03-28 21:13:14 +00:00
Add Swift Package Manager support
This commit is contained in:
parent
052d70ff95
commit
1b7e99a7eb
42
Package.swift
Normal file
42
Package.swift
Normal file
@ -0,0 +1,42 @@
|
||||
// swift-tools-version: 5.7
|
||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "libxlsxwriter",
|
||||
products: [
|
||||
.library(
|
||||
name: "libxlsxwriter",
|
||||
targets: ["libxlsxwriter"]),
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "libxlsxwriter",
|
||||
path: ".",
|
||||
exclude: [
|
||||
"src/Makefile",
|
||||
],
|
||||
sources: [
|
||||
"include",
|
||||
"src",
|
||||
"third_party/minizip/zip.c",
|
||||
"third_party/minizip/ioapi.c",
|
||||
"third_party/tmpfileplus/tmpfileplus.c",
|
||||
"third_party/md5/md5.c"
|
||||
],
|
||||
publicHeadersPath: "include",
|
||||
linkerSettings: [
|
||||
.linkedLibrary("z")
|
||||
]),
|
||||
.testTarget(
|
||||
name: "libxlsxwritertests",
|
||||
dependencies: ["libxlsxwriter"],
|
||||
path: ".",
|
||||
sources: ["test/swift"],
|
||||
linkerSettings: [
|
||||
.linkedLibrary("z")
|
||||
]
|
||||
)
|
||||
]
|
||||
)
|
17
test/swift/test.swift
Normal file
17
test/swift/test.swift
Normal file
@ -0,0 +1,17 @@
|
||||
import XCTest
|
||||
@testable import libxlsxwriter
|
||||
|
||||
final class LibXlsxWriterTests: XCTestCase {
|
||||
func testExample() throws {
|
||||
let documentDirectory = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor:nil, create:false)
|
||||
let fileURL = documentDirectory.appendingPathComponent("hello_world.xlsx")
|
||||
|
||||
let workbook = workbook_new((fileURL.absoluteString.dropFirst(6) as NSString).fileSystemRepresentation)
|
||||
let worksheet = workbook_add_worksheet(workbook, nil)
|
||||
worksheet_write_string(worksheet, 0, 0, "Hello", nil)
|
||||
worksheet_write_number(worksheet, 1, 0, 123, nil)
|
||||
workbook_close(workbook)
|
||||
|
||||
print(fileURL)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user