-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUG] xcparse doesn't export screenshots for iPhone Xʀ on Xcode 11.1 …
…or below (#31) Change Description: These changes are to help address issues with using xcparse on Xcode 11.1 and below. Apple's xcresulttool, which we use to extract the screenshots, crashes in some versions when attempting to export out attachments to directory paths that have Unicode characters like "iPhone Xʀ" or "한국어". This leads to the user being unable to get their screenshots & not knowing why. The changes here introduce the ability for xcparse to understand the version of xcresulttool & change behavior of exporting based off the versioning. For xcresulttool versions below 15500, we change "iPhone Xʀ" to "iPhone XR" & any other non-ASCII compatible characters into their lossy ASCII conversion (often "?"). For xcresulttool 15500 or above, we continue exporting how we always have. In all cases for users with xcresulttool below 15500, we warn them about the issue in their version and encourage them to update Xcode. In cases where users with xcresulttool version below 155000 have a destination folder path that can not be represented in ASCII, we hard-fail export and alert the user they need to update Xcode. Test Plan/Testing Performed: Tested that with these changes, iPhone XR screenshots can be retrieved on Xcode 11.1. When using test run configuration names with Korean characters, confirmed that we export into a lossy ASCII version of the string (though this will lead to loss of some folders since "한국어" & "중국어" will both become "???")
- Loading branch information
1 parent
dcc689f
commit 9d0c482
Showing
8 changed files
with
153 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// Version+XCPTooling.swift | ||
// XCParseCore | ||
// | ||
// Created by Alex Botkin on 11/8/19. | ||
// | ||
|
||
import Foundation | ||
import SPMUtility | ||
|
||
public extension Version { | ||
static func xcresulttoolCompatibleWithUnicodeExportPath() -> Version { | ||
return Version(15500, 0, 0) | ||
} | ||
|
||
static func xcresulttool() -> Version? { | ||
guard let xcresulttoolVersionResult = XCResultToolCommand.Version().run() else { | ||
return nil | ||
} | ||
do { | ||
let xcresultVersionString = try xcresulttoolVersionResult.utf8Output() | ||
|
||
let components = xcresultVersionString.components(separatedBy: CharacterSet(charactersIn: ",\n")) | ||
for string in components { | ||
let trimmedString = string.trimmingCharacters(in: .whitespacesAndNewlines) | ||
if trimmedString.hasPrefix("xcresulttool version ") { | ||
let xcresulttoolVersionString = trimmedString.replacingOccurrences(of: "xcresulttool version ", with: "") | ||
// Check to see if we can convert it to a number | ||
var xcresulttoolVersion: Version? | ||
|
||
if let xcresulttoolVersionInt = Int(xcresulttoolVersionString) { | ||
xcresulttoolVersion = Version(xcresulttoolVersionInt, 0, 0) | ||
} else { | ||
xcresulttoolVersion = Version(string: xcresulttoolVersionString) | ||
} | ||
|
||
return xcresulttoolVersion | ||
} | ||
} | ||
|
||
return nil | ||
} catch { | ||
print("Failed to parse xcresulttool version with error: \(error)") | ||
return nil | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters