Skip to content

Commit

Permalink
Merge pull request #172 from MobileNativeFoundation/xcode14
Browse files Browse the repository at this point in the history
Support Xcode 14 logs
  • Loading branch information
ecamacho authored Jun 29, 2022
2 parents 083e1ac + b06f0db commit dc6093f
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Sources/XCLogParser/activityparser/ActivityParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ public class ActivityParser {
return try parseDVTDocumentLocation(iterator: &iterator)
} else if className == String(describing: IBDocumentMemberLocation.self) {
return try parseIBDocumentMemberLocation(iterator: &iterator)
} else if className == String(describing: DVTMemberDocumentLocation.self) {
return try parseDVTMemberDocumentLocation(iterator: &iterator)
}
throw XCLogParserError.parseError("Unexpected className found parsing DocumentLocation \(className)")
}
Expand Down Expand Up @@ -565,4 +567,11 @@ public class ActivityParser {
throw XCLogParserError.parseError("Unexpected token parsing Bool: \(token)")
}

private func parseDVTMemberDocumentLocation(iterator: inout IndexingIterator<[Token]>)
throws -> DVTMemberDocumentLocation {
return DVTMemberDocumentLocation(documentURLString: try parseAsString(token: iterator.next()),
timestamp: try parseAsDouble(token: iterator.next()),
member: try parseAsString(token: iterator.next()))
}

}
22 changes: 22 additions & 0 deletions Sources/XCLogParser/activityparser/IDEActivityModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -568,3 +568,25 @@ public class IBDocumentMemberLocation: DVTDocumentLocation {
try container.encode(attributeSearchLocation, forKey: .attributeSearchLocation)
}
}

// MARK: Added in Xcode 14

//// From DVTFoundation.framework
public class DVTMemberDocumentLocation: DVTDocumentLocation, Equatable {

public let member: String

public init(documentURLString: String, timestamp: Double, member: String) {
self.member = member
super.init(documentURLString: documentURLString, timestamp: timestamp)
}

// MARK: Equatable method

public static func == (lhs: DVTMemberDocumentLocation, rhs: DVTMemberDocumentLocation) -> Bool {
return lhs.documentURLString == rhs.documentURLString &&
lhs.timestamp == rhs.timestamp &&
lhs.member == rhs.member
}

}
2 changes: 1 addition & 1 deletion Sources/XCLogParser/commands/Version.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ import Foundation

public struct Version {

public static let current = "0.2.33"
public static let current = "0.2.34"

}
27 changes: 27 additions & 0 deletions Tests/XCLogParserTests/ActivityParserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -348,4 +348,31 @@ class ActivityParserTests: XCTestCase {

XCTAssertEqual("file:///project/EntityComponentView.m", documentLocation.documentURLString)
}

let expectedDVTMemberDocumentLocation: DVTMemberDocumentLocation = DVTMemberDocumentLocation(
documentURLString: "file:///project/EntityComponentView.m",
timestamp: 2.2,
member: "abcdef")

let memberDocumentLocationTokens: [Token] = {
return [
Token.className("DVTMemberDocumentLocation"),
Token.classNameRef("DVTMemberDocumentLocation"),
Token.string("file:///project/EntityComponentView.m"),
Token.double(2.2),
Token.string("abcdef")]
}()

func testParseDVTMemberDocumentLocation() throws {
var iterator = memberDocumentLocationTokens.makeIterator()
let documentLocation = try parser.parseDocumentLocation(iterator: &iterator)
XCTAssert(documentLocation is DVTMemberDocumentLocation,
"Document location should be a DVTMemberDocumentLocation")

guard let documentMemberLocation = documentLocation as? DVTMemberDocumentLocation else {
return
}
XCTAssertEqual(expectedDVTMemberDocumentLocation, documentMemberLocation)
}

}

0 comments on commit dc6093f

Please sign in to comment.