diff --git a/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/MFSJSONEntity/include/MFSJSONEntity.h b/MFSJSONEntity/include/MFSJSONEntity.h new file mode 120000 index 0000000..b47205b --- /dev/null +++ b/MFSJSONEntity/include/MFSJSONEntity.h @@ -0,0 +1 @@ +../MFSJSONEntity.h \ No newline at end of file diff --git a/MFSJSONEntity/include/MFSJSONEntityElementProtocol.h b/MFSJSONEntity/include/MFSJSONEntityElementProtocol.h new file mode 120000 index 0000000..0a653a6 --- /dev/null +++ b/MFSJSONEntity/include/MFSJSONEntityElementProtocol.h @@ -0,0 +1 @@ +../MFSJSONEntityElementProtocol.h \ No newline at end of file diff --git a/MFSJSONEntity/include/MFSJSONEntityPropertyProtocol.h b/MFSJSONEntity/include/MFSJSONEntityPropertyProtocol.h new file mode 120000 index 0000000..4a7f708 --- /dev/null +++ b/MFSJSONEntity/include/MFSJSONEntityPropertyProtocol.h @@ -0,0 +1 @@ +../MFSJSONEntityPropertyProtocol.h \ No newline at end of file diff --git a/MFSJSONEntity/include/NSObject+JSONEntity.h b/MFSJSONEntity/include/NSObject+JSONEntity.h new file mode 120000 index 0000000..3c39f05 --- /dev/null +++ b/MFSJSONEntity/include/NSObject+JSONEntity.h @@ -0,0 +1 @@ +../NSObject+JSONEntity.h \ No newline at end of file diff --git a/MFSJSONEntity/include/NSObject+MFSJSONEntity.h b/MFSJSONEntity/include/NSObject+MFSJSONEntity.h new file mode 120000 index 0000000..2b9274c --- /dev/null +++ b/MFSJSONEntity/include/NSObject+MFSJSONEntity.h @@ -0,0 +1 @@ +../NSObject+MFSJSONEntity.h \ No newline at end of file diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..d665d86 --- /dev/null +++ b/Package.swift @@ -0,0 +1,30 @@ +// swift-tools-version:5.2 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "MFSJSONEntity", + products: [ + // Products define the executables and libraries produced by a package, and make them visible to other packages. + .library( + name: "MFSJSONEntity", + targets: ["MFSJSONEntity"]), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + // .package(url: /* package url */, from: "1.0.0"), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages which this package depends on. + .target( + name: "MFSJSONEntity", + dependencies: [], + path:"MFSJSONEntity" + ), + .testTarget( + name: "MFSJSONEntityTests", + dependencies: ["MFSJSONEntity"]), + ] +) diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift new file mode 100644 index 0000000..7afa94a --- /dev/null +++ b/Tests/LinuxMain.swift @@ -0,0 +1,7 @@ +import XCTest + +import MFSJSONEntityTests + +var tests = [XCTestCaseEntry]() +tests += MFSJSONEntityTests.allTests() +XCTMain(tests) diff --git a/Tests/MFSJSONEntityTests/MFSJSONEntityTests.swift b/Tests/MFSJSONEntityTests/MFSJSONEntityTests.swift new file mode 100644 index 0000000..50fce5f --- /dev/null +++ b/Tests/MFSJSONEntityTests/MFSJSONEntityTests.swift @@ -0,0 +1,34 @@ +import XCTest +@testable import MFSJSONEntity + +final class MFSJSONEntityTests: XCTestCase { + func testExample() { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct + // results. + print("Hello, MFS JSONEntity! ") + let person = Person() + person.name = "max" + person.age = 99 + let personDict = person.propertyDictionary() + print(personDict!) + + let JSONString = "{\"name\":\"max\",\"age\":98}" + if let JSONData = JSONString.data(using: .utf8), let dictionary = try? JSONSerialization.jsonObject(with: JSONData, options: .fragmentsAllowed) as? [String:Any], let obj = Person.object(with: dictionary) as? Person { + print("person:\(obj), name:\(obj.name), age:\(obj.age)") + } + let propertys = Person.propertyNames() + print("Person propertys:\(propertys)") + } + + static var allTests = [ + ("testExample", testExample), + ] +} + +@objc class Person: NSObject { + var name:String? + var age:Int? + var other:String? {nil} + +} diff --git a/Tests/MFSJSONEntityTests/XCTestManifests.swift b/Tests/MFSJSONEntityTests/XCTestManifests.swift new file mode 100644 index 0000000..1e9362f --- /dev/null +++ b/Tests/MFSJSONEntityTests/XCTestManifests.swift @@ -0,0 +1,9 @@ +import XCTest + +#if !canImport(ObjectiveC) +public func allTests() -> [XCTestCaseEntry] { + return [ + testCase(MFSJSONEntityTests.allTests), + ] +} +#endif