An SPM CLI tool that validates multiple Xcode project targets for common files, duplicate references and forbidden resources.
brew tap michaelversus/xcodetargets https://github.com/michaelversus/XcodeTargets.git
brew install xcodetargets-clets you specify a path to your .xcode-targets.json configuration file.-rsets the path XcodeTargets should scan. This defaults to your current working directory.-venables verbose output. Default value is false.-eenables error only output. Default value is false. (Practical for CICD)
You can customize the behavior of XcodeTargets by creating a .xcode-targets.json file inside the directory you want to scan.
Example:
{
"name": "MyProject",
"fileMembershipSets": [
{
"targets": [
"App",
"AppStaging",
"AppProd"
],
"exclusive": {
"AppStaging": {
"files": [
"Config/Staging/*",
"Features/DebugPanel/"
],
"dependencies": ["StagingAnalytics"],
"frameworks": ["StagingSDK"]
},
"AppProd": {
"files": ["Config/Prod/.*"],
"dependencies": ["ProdAnalytics"],
"frameworks": ["ProdSDK"]
}
}
},
{
"targets": [
"Widget",
"WidgetExtension"
],
"exclusive": {
"WidgetExtension": {
"files": ["WidgetExtensionSpecific/*"],
"dependencies": ["WidgetExtensionSupport"],
"frameworks": []
}
}
}
],
"forbiddenResourceSets": [
{
"targets": ["App", "AppStaging", "AppProd"],
"paths": ["/Debug/", "Temporary/"]
},
{
"targets": ["Widget"],
"paths": ["LargeAssets/"]
}
],
"duplicatesValidationExcludedTargets": ["Tests", "UITests"]
}- fileMembershipSets validates that Xcode project targets contains same files. You can exclude files using the exclusive
- forbiddenResourceSets throws errors when files contain specific subpaths. (For example Snapshots to ensure that snapshot tests images are not included inside your binary for distribution)
- duplicatesValidationExcludedTargets you can add the Xcode project targets that you want to exclude from duplicate references validation.
xcodetargets -c path/to/.xcode-targets.json -r /path/to/projectXcodeTargets is build on top of
- tuist's XcodeProj library for parsing the xcodeproj file, which is available under the MIT license.
The implementation is inspired from the below ruby script:
Swift, the Swift logo, and Xcode are trademarks of Apple Inc., registered in the U.S. and other countries.
Contributions are more than welcome!
