Skip to content

Commit 8cec2af

Browse files
committed
More linux compatibility with empty dictionary data
1 parent b4b54e2 commit 8cec2af

File tree

7 files changed

+12
-17
lines changed

7 files changed

+12
-17
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.build

LinuxMain.swift

Lines changed: 0 additions & 1 deletion
This file was deleted.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:4.2
1+
// swift-tools-version:5.5
22

33
import PackageDescription
44

Sources/OpenStepSerializer.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,16 @@ class OpenStepSerializer {
6565
if key == "rootObject" {
6666
comment = " /* Project object */"
6767
}
68-
68+
#if os(Linux)
69+
let row: String
70+
if let dict = val as? [AnyHashable: Any], dict.isEmpty {
71+
row = "\(key) = {\n}\(comment);" // print on linux give [:] ...
72+
} else {
73+
row = "\(key) = \(val)\(comment);"
74+
}
75+
#else
6976
let row = "\(key) = \(val)\(comment);"
77+
#endif
7078
for line in row.components(separatedBy: "\n") {
7179
lines.append("\t\(line)")
7280
}

Tests/Utils.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,7 @@ extension XCTestCase {
5252
do {
5353
let contents = try String(contentsOf: url)
5454
let testContents = try String(contentsOf: testURL)
55-
#if os(Linux)
56-
XCTAssertEqual(contents.replacingOccurrences(matchingPattern: "classes = \\{\\s*\\};", by: "classes = [:];"), testContents, "diff \(url.path) \(testURL.path)")
57-
#else
5855
XCTAssertEqual(contents, testContents)
59-
#endif
60-
6156
} catch {
6257
XCTFail("\(error)")
6358
}
@@ -67,12 +62,7 @@ extension XCTestCase {
6762
do {
6863
let contents = try String(contentsOf: url)
6964
let testContents = try String(contentsOf: testURL)
70-
#if os(Linux)
71-
XCTAssertNotEqual(contents.replacingOccurrences(matchingPattern: "classes = \\{\\s*\\};", by: "classes = [:];"), testContents, "diff \(url.path) \(testURL.path)")
72-
#else
7365
XCTAssertNotEqual(contents, testContents)
74-
#endif
75-
7666
} catch {
7767
XCTFail("\(error)")
7868
}

Tests/XcodeProjKitEditionTests.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ class XcodeProjKitEditionTests: XCTestCase {
4848

4949
let testURL = URL(fileURLWithPath: XcodeProjKitEditionTests.directory + resource.replacingOccurrences(of: "ok/", with: "") + "." + XcodeProj.pbxprojFileExtension)
5050
try proj.write(to: testURL)
51-
52-
let testproj = try XcodeProj(url: testURL)
51+
let testproj: XcodeProj = try XcodeProj(url: testURL)
5352
XCTAssertEqual(PBXProject.Version(major: 12, minor: 0), testproj.project.lastUpgradeCheck)
5453

5554

Tests/XcodeProjKitWriteTests.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ class XcodeProjKitWriteTests: XCTestCase {
109109
let testURLPlist = URL(fileURLWithPath: XcodeProjKitWriteTests.directory + resource.replacingOccurrences(of: "ok/", with: "") + ".plist")
110110
try proj.write(to: testURLPlist, format: .xml)
111111
try XcodeProj(url: testURLPlist).write(to: testURLPlist.appendingPathExtension("pbxproj"), format: .openStep, projectName: proj.projectName, lineEnding: proj.lineEnding)
112-
print("\(url.path)")
113-
print("\(testURLPlist.appendingPathExtension("pbxproj").path)")
114112
assertContentsEqual(url, testURLPlist.appendingPathExtension("pbxproj"))
115113

116114
// test passing by json before recoding to openstep

0 commit comments

Comments
 (0)