XcodeProj
XcodeProj copied to clipboard
`error: (DecodingError) typeMismatch(Swift.String, Swift.DecodingError.Context(codingPath: …, CodingKeys(stringValue: "shellScript", …)], debugDescription: "Expected to decode String but found an array instead.", …))`
Context 🕵️♀️
- Xcode 16.3 (16E140)
- Xcode project format: Xcode 16.3 (
objectVersion = 90) - Periphery 3.0.3
- XcodeProj 8.27.3
project.pbxproj:
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 90;
objects = {
…
/* Begin PBXShellScriptBuildPhase section */
A42660D00000000000000000 /* Test Shell Script */ = {
isa = PBXShellScriptBuildPhase;
name = "Test Shell Script";
shellPath = /bin/zsh;
shellScript = (
"echo 'Hello World!'",
"",
);
};
/* End PBXShellScriptBuildPhase section */
…
};
rootObject = A42B35300000000000000000 /* Project object */;
}
What 🌱
When I try to scan my project with Periphery (which uses XcodeProj) with periphery scan, I get this error message:
error: (DecodingError) typeMismatch(Swift.String, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "objects", intValue: nil), _DictionaryCodingKey(stringValue: "A42660D12C729D04000E0507", intValue: nil), CodingKeys(stringValue: "shellScript", intValue: nil)], debugDescription: "Expected to decode String but found an array instead.", underlyingError: nil))
It seems that at least since Xcode project format 16.3 (objectVersion = 90), shell scripts (Targets → <target name> → Build Phases → New Run Script Phase) are stored in arrays where each element represents a line, whereas before they were stored as a single string.
Hey @F1248, I'm here to help you squash bugs, answer questions, and become a contributor. Let's tackle this issue together! 🤖
The error you're encountering is due to a change in the Xcode project format starting from version 16.3, where the shellScript field in the PBXShellScriptBuildPhase section is now stored as an array of strings, with each element representing a line of the script. Previously, this was stored as a single string.
To resolve this issue, the XcodeProj library needs to be updated to handle the shellScript field as an array of strings when decoding. This would involve modifying the decoding logic to accommodate both the old format (single string) and the new format (array of strings).
As a temporary workaround, you could manually modify the project.pbxproj file to convert the array back into a single string for the shellScript field, but this is not ideal for long-term maintenance. It would be better to update the library to handle both formats.
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other
Same issue here on the shellScript key