Skip to content

Commit 44d9795

Browse files
committed
Run linter on app targets instead of appex ones
This changes the strategy to only have a single Script Build phase on the parent app target, rather than having one on each app extension target. The initial rationale for calling the linter on each app extension target independently (and limiting the linter just to that target) was that it would ensure the linter would be run even if we only try to build the app extension target independently (e.g. selecting the scheme associated with that app extension when building). SO I thought it made more sense to make each target call the linter for their own. But in practice, an app extension is never build / run without building the app target as well. Especially, if you look at each scheme corresponding to an app extension (e.g. the `WordPressStatsWidgets` scheme) you can see in the "Build" tab of the scheme that it will also build the `WordPress` app target anyway. Given this, it ends up being (1) easier to maintain (e.g. if we add new appextension targets in the future), and (2) more performant / faster to just run the linter swift script once, from the app target, and have it scan the files for each of the appextension targets it finds in the `xcodeproj` in one go — rather than running it from scratch as many times as there are appextension targets in the project. The performance boost we'll get from this new approach is because each invocation of the linter parses the whole `project.pbxproj` file (to find the list of targets then the list of files built by the targets). So only doing that once when we build the `WordPress` or `Jetpack` targets is more efficient than re-parsing the project file multiple times for each app extension target being built.
1 parent 946eab7 commit 44d9795

2 files changed

Lines changed: 11 additions & 158 deletions

File tree

Scripts/BuildPhases/LintAppLocalizedStringsUsage.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ if [ ! -x "${LINTER_EXEC}" ] || ! (shasum -c "${LINTER_EXEC}.shasum" >/dev/null
1414
echo "Pre-compiled linter script ready"
1515
fi
1616

17-
"$LINTER_EXEC" "${PROJECT_FILE_PATH:-$1}" "${TARGET_NAME:-$2}"
17+
"$LINTER_EXEC" "${PROJECT_FILE_PATH:-$1}" # "${TARGET_NAME:-$2}"

WordPress/WordPress.xcodeproj/project.pbxproj

Lines changed: 10 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -15319,6 +15319,7 @@
1531915319
buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "WordPress" */;
1532015320
buildPhases = (
1532115321
E00F6488DE2D86BDC84FBB0B /* [CP] Check Pods Manifest.lock */,
15322+
09607CE7281C9CA6002D2E5A /* [Lint] Check AppLocalizedString usage */,
1532215323
825F0EBF1F7EBF7C00321528 /* App Icons: Add Version For Internal Releases */,
1532315324
1D60588D0D05DD3D006BFB54 /* Resources */,
1532415325
F9C5CF0222CD5DB0007CEF56 /* Copy Alternate Internal Icons (if needed) */,
@@ -15358,7 +15359,6 @@
1535815359
buildConfigurationList = 3F526C612538CF2C0069706C /* Build configuration list for PBXNativeTarget "WordPressStatsWidgets" */;
1535915360
buildPhases = (
1536015361
0AA1A8899C01FEF3599F6FCF /* [CP] Check Pods Manifest.lock */,
15361-
09DBEA51281333610019724E /* [Lint] Check AppLocalizedString usage */,
1536215362
3F526C482538CF2A0069706C /* Sources */,
1536315363
3F526C492538CF2A0069706C /* Frameworks */,
1536415364
3F526C4A2538CF2A0069706C /* Resources */,
@@ -15399,7 +15399,6 @@
1539915399
isa = PBXNativeTarget;
1540015400
buildConfigurationList = 733F36152126197800988727 /* Build configuration list for PBXNativeTarget "WordPressNotificationContentExtension" */;
1540115401
buildPhases = (
15402-
09DBEA52281333700019724E /* [Lint] Check AppLocalizedString usage */,
1540315402
733F35FF2126197800988727 /* Sources */,
1540415403
733F36002126197800988727 /* Frameworks */,
1540515404
733F36012126197800988727 /* Resources */,
@@ -15418,7 +15417,6 @@
1541815417
buildConfigurationList = 7358E6C4210BD318002323EB /* Build configuration list for PBXNativeTarget "WordPressNotificationServiceExtension" */;
1541915418
buildPhases = (
1542015419
BAE780768320204E29A6FE5B /* [CP] Check Pods Manifest.lock */,
15421-
09DBEA53281333770019724E /* [Lint] Check AppLocalizedString usage */,
1542215420
7358E6B4210BD318002323EB /* Sources */,
1542315421
7358E6B5210BD318002323EB /* Frameworks */,
1542415422
7358E6B6210BD318002323EB /* Resources */,
@@ -15438,7 +15436,6 @@
1543815436
buildConfigurationList = 74576681202B558C00F42E40 /* Build configuration list for PBXNativeTarget "WordPressDraftActionExtension" */;
1543915437
buildPhases = (
1544015438
74CC431A202B5C73000DAE1A /* [CP] Check Pods Manifest.lock */,
15441-
09DBEA4D281333060019724E /* [Lint] Check AppLocalizedString usage */,
1544215439
7457666E202B558C00F42E40 /* Sources */,
1544315440
7457666F202B558C00F42E40 /* Frameworks */,
1544415441
74576670202B558C00F42E40 /* Resources */,
@@ -15477,7 +15474,6 @@
1547715474
buildConfigurationList = 932225B71C7CE50400443B02 /* Build configuration list for PBXNativeTarget "WordPressShareExtension" */;
1547815475
buildPhases = (
1547915476
4F4D5C2BB6478A3E90ADC3C5 /* [CP] Check Pods Manifest.lock */,
15480-
09DBEA4C281329ED0019724E /* [Lint] Check AppLocalizedString usage */,
1548115477
932225A31C7CE50300443B02 /* Sources */,
1548215478
932225A41C7CE50300443B02 /* Frameworks */,
1548315479
932225A51C7CE50300443B02 /* Resources */,
@@ -15497,7 +15493,6 @@
1549715493
buildConfigurationList = 93E5284D19A7741A003A1A9C /* Build configuration list for PBXNativeTarget "WordPressTodayWidget" */;
1549815494
buildPhases = (
1549915495
4CB8AA817C9BD74F3416B27C /* [CP] Check Pods Manifest.lock */,
15500-
09DBEA4E2813334B0019724E /* [Lint] Check AppLocalizedString usage */,
1550115496
93E5283619A7741A003A1A9C /* Sources */,
1550215497
93E5283719A7741A003A1A9C /* Frameworks */,
1550315498
93E5283819A7741A003A1A9C /* Resources */,
@@ -15517,7 +15512,6 @@
1551715512
buildConfigurationList = 98A3C2FF239997DB0048D38D /* Build configuration list for PBXNativeTarget "WordPressThisWeekWidget" */;
1551815513
buildPhases = (
1551915514
591AAEE0843D274DDFF16F69 /* [CP] Check Pods Manifest.lock */,
15520-
09DBEA50281333590019724E /* [Lint] Check AppLocalizedString usage */,
1552115515
98A3C2EB239997DA0048D38D /* Sources */,
1552215516
98A3C2EC239997DA0048D38D /* Frameworks */,
1552315517
98A3C2ED239997DA0048D38D /* Resources */,
@@ -15537,7 +15531,6 @@
1553715531
buildConfigurationList = 98D31B9E2396ED7F009CFF43 /* Build configuration list for PBXNativeTarget "WordPressAllTimeWidget" */;
1553815532
buildPhases = (
1553915533
FF1C536C9FA7489B5AAA0FC2 /* [CP] Check Pods Manifest.lock */,
15540-
09DBEA4F281333530019724E /* [Lint] Check AppLocalizedString usage */,
1554115534
98D31B8A2396ED7E009CFF43 /* Sources */,
1554215535
98D31B8B2396ED7E009CFF43 /* Frameworks */,
1554315536
98D31B8C2396ED7E009CFF43 /* Resources */,
@@ -15576,7 +15569,6 @@
1557615569
buildConfigurationList = F1F163DC25658B4D003DC13B /* Build configuration list for PBXNativeTarget "WordPressIntents" */;
1557715570
buildPhases = (
1557815571
CE51D1C75430FDDD21B27F64 /* [CP] Check Pods Manifest.lock */,
15579-
09DBEA542813337F0019724E /* [Lint] Check AppLocalizedString usage */,
1558015572
F1F163BA25658B4D003DC13B /* Sources */,
1558115573
F1F163BB25658B4D003DC13B /* Frameworks */,
1558215574
F1F163BC25658B4D003DC13B /* Resources */,
@@ -15596,6 +15588,7 @@
1559615588
buildConfigurationList = FABB264D2602FC2C00C8785C /* Build configuration list for PBXNativeTarget "Jetpack" */;
1559715589
buildPhases = (
1559815590
FABB1FA72602FC2C00C8785C /* [CP] Check Pods Manifest.lock */,
15591+
09607CE8281C9D0F002D2E5A /* [Lint] Check AppLocalizedString usage */,
1559915592
3F32E4AE270EAF5100A33D51 /* Generate Credentials */,
1560015593
FABB1FA92602FC2C00C8785C /* App Icons: Add Version For Internal Releases */,
1560115594
FABB1FAA2602FC2C00C8785C /* Resources */,
@@ -16636,29 +16629,7 @@
1663616629
/* End PBXResourcesBuildPhase section */
1663716630

1663816631
/* Begin PBXShellScriptBuildPhase section */
16639-
096A92FB26E2A05400448C68 /* Generate Secrets / Credentials */ = {
16640-
isa = PBXShellScriptBuildPhase;
16641-
alwaysOutOfDate = 1;
16642-
buildActionMask = 2147483647;
16643-
files = (
16644-
);
16645-
inputFileListPaths = (
16646-
"$(SRCROOT)/../Scripts/BuildPhases/GenerateCredentials.xcfilelist",
16647-
);
16648-
inputPaths = (
16649-
);
16650-
name = "Generate Secrets / Credentials";
16651-
outputFileListPaths = (
16652-
);
16653-
outputPaths = (
16654-
"$(BUILD_DIR)/Secrets/Secrets.swift",
16655-
);
16656-
runOnlyForDeploymentPostprocessing = 0;
16657-
shellPath = /bin/sh;
16658-
shellScript = "$SRCROOT/../Scripts/BuildPhases/GenerateCredentials.sh\n";
16659-
showEnvVarsInLog = 0;
16660-
};
16661-
09DBEA4C281329ED0019724E /* [Lint] Check AppLocalizedString usage */ = {
16632+
09607CE7281C9CA6002D2E5A /* [Lint] Check AppLocalizedString usage */ = {
1666216633
isa = PBXShellScriptBuildPhase;
1666316634
alwaysOutOfDate = 1;
1666416635
buildActionMask = 2147483647;
@@ -16678,7 +16649,7 @@
1667816649
shellScript = "\"$SRCROOT/../Scripts/BuildPhases/LintAppLocalizedStringsUsage.sh\"\n";
1667916650
showEnvVarsInLog = 0;
1668016651
};
16681-
09DBEA4D281333060019724E /* [Lint] Check AppLocalizedString usage */ = {
16652+
09607CE8281C9D0F002D2E5A /* [Lint] Check AppLocalizedString usage */ = {
1668216653
isa = PBXShellScriptBuildPhase;
1668316654
alwaysOutOfDate = 1;
1668416655
buildActionMask = 2147483647;
@@ -16698,144 +16669,26 @@
1669816669
shellScript = "\"$SRCROOT/../Scripts/BuildPhases/LintAppLocalizedStringsUsage.sh\"\n";
1669916670
showEnvVarsInLog = 0;
1670016671
};
16701-
09DBEA4E2813334B0019724E /* [Lint] Check AppLocalizedString usage */ = {
16702-
isa = PBXShellScriptBuildPhase;
16703-
alwaysOutOfDate = 1;
16704-
buildActionMask = 2147483647;
16705-
files = (
16706-
);
16707-
inputFileListPaths = (
16708-
);
16709-
inputPaths = (
16710-
);
16711-
name = "[Lint] Check AppLocalizedString usage";
16712-
outputFileListPaths = (
16713-
);
16714-
outputPaths = (
16715-
);
16716-
runOnlyForDeploymentPostprocessing = 0;
16717-
shellPath = "/bin/bash -eu";
16718-
shellScript = "\"$SRCROOT/../Scripts/BuildPhases/LintAppLocalizedStringsUsage.sh\"\n";
16719-
showEnvVarsInLog = 0;
16720-
};
16721-
09DBEA4F281333530019724E /* [Lint] Check AppLocalizedString usage */ = {
16722-
isa = PBXShellScriptBuildPhase;
16723-
alwaysOutOfDate = 1;
16724-
buildActionMask = 2147483647;
16725-
files = (
16726-
);
16727-
inputFileListPaths = (
16728-
);
16729-
inputPaths = (
16730-
);
16731-
name = "[Lint] Check AppLocalizedString usage";
16732-
outputFileListPaths = (
16733-
);
16734-
outputPaths = (
16735-
);
16736-
runOnlyForDeploymentPostprocessing = 0;
16737-
shellPath = "/bin/bash -eu";
16738-
shellScript = "\"$SRCROOT/../Scripts/BuildPhases/LintAppLocalizedStringsUsage.sh\"\n";
16739-
showEnvVarsInLog = 0;
16740-
};
16741-
09DBEA50281333590019724E /* [Lint] Check AppLocalizedString usage */ = {
16742-
isa = PBXShellScriptBuildPhase;
16743-
alwaysOutOfDate = 1;
16744-
buildActionMask = 2147483647;
16745-
files = (
16746-
);
16747-
inputFileListPaths = (
16748-
);
16749-
inputPaths = (
16750-
);
16751-
name = "[Lint] Check AppLocalizedString usage";
16752-
outputFileListPaths = (
16753-
);
16754-
outputPaths = (
16755-
);
16756-
runOnlyForDeploymentPostprocessing = 0;
16757-
shellPath = "/bin/bash -eu";
16758-
shellScript = "\"$SRCROOT/../Scripts/BuildPhases/LintAppLocalizedStringsUsage.sh\"\n";
16759-
showEnvVarsInLog = 0;
16760-
};
16761-
09DBEA51281333610019724E /* [Lint] Check AppLocalizedString usage */ = {
16762-
isa = PBXShellScriptBuildPhase;
16763-
alwaysOutOfDate = 1;
16764-
buildActionMask = 2147483647;
16765-
files = (
16766-
);
16767-
inputFileListPaths = (
16768-
);
16769-
inputPaths = (
16770-
);
16771-
name = "[Lint] Check AppLocalizedString usage";
16772-
outputFileListPaths = (
16773-
);
16774-
outputPaths = (
16775-
);
16776-
runOnlyForDeploymentPostprocessing = 0;
16777-
shellPath = "/bin/bash -eu";
16778-
shellScript = "\"$SRCROOT/../Scripts/BuildPhases/LintAppLocalizedStringsUsage.sh\"\n";
16779-
showEnvVarsInLog = 0;
16780-
};
16781-
09DBEA52281333700019724E /* [Lint] Check AppLocalizedString usage */ = {
16782-
isa = PBXShellScriptBuildPhase;
16783-
alwaysOutOfDate = 1;
16784-
buildActionMask = 2147483647;
16785-
files = (
16786-
);
16787-
inputFileListPaths = (
16788-
);
16789-
inputPaths = (
16790-
);
16791-
name = "[Lint] Check AppLocalizedString usage";
16792-
outputFileListPaths = (
16793-
);
16794-
outputPaths = (
16795-
);
16796-
runOnlyForDeploymentPostprocessing = 0;
16797-
shellPath = "/bin/bash -eu";
16798-
shellScript = "\"$SRCROOT/../Scripts/BuildPhases/LintAppLocalizedStringsUsage.sh\"\n";
16799-
showEnvVarsInLog = 0;
16800-
};
16801-
09DBEA53281333770019724E /* [Lint] Check AppLocalizedString usage */ = {
16802-
isa = PBXShellScriptBuildPhase;
16803-
alwaysOutOfDate = 1;
16804-
buildActionMask = 2147483647;
16805-
files = (
16806-
);
16807-
inputFileListPaths = (
16808-
);
16809-
inputPaths = (
16810-
);
16811-
name = "[Lint] Check AppLocalizedString usage";
16812-
outputFileListPaths = (
16813-
);
16814-
outputPaths = (
16815-
);
16816-
runOnlyForDeploymentPostprocessing = 0;
16817-
shellPath = "/bin/bash -eu";
16818-
shellScript = "\"$SRCROOT/../Scripts/BuildPhases/LintAppLocalizedStringsUsage.sh\"\n";
16819-
showEnvVarsInLog = 0;
16820-
};
16821-
09DBEA542813337F0019724E /* [Lint] Check AppLocalizedString usage */ = {
16672+
096A92FB26E2A05400448C68 /* Generate Secrets / Credentials */ = {
1682216673
isa = PBXShellScriptBuildPhase;
1682316674
alwaysOutOfDate = 1;
1682416675
buildActionMask = 2147483647;
1682516676
files = (
1682616677
);
1682716678
inputFileListPaths = (
16679+
"$(SRCROOT)/../Scripts/BuildPhases/GenerateCredentials.xcfilelist",
1682816680
);
1682916681
inputPaths = (
1683016682
);
16831-
name = "[Lint] Check AppLocalizedString usage";
16683+
name = "Generate Secrets / Credentials";
1683216684
outputFileListPaths = (
1683316685
);
1683416686
outputPaths = (
16687+
"$(BUILD_DIR)/Secrets/Secrets.swift",
1683516688
);
1683616689
runOnlyForDeploymentPostprocessing = 0;
16837-
shellPath = "/bin/bash -eu";
16838-
shellScript = "\"$SRCROOT/../Scripts/BuildPhases/LintAppLocalizedStringsUsage.sh\"\n";
16690+
shellPath = /bin/sh;
16691+
shellScript = "$SRCROOT/../Scripts/BuildPhases/GenerateCredentials.sh\n";
1683916692
showEnvVarsInLog = 0;
1684016693
};
1684116694
0AA1A8899C01FEF3599F6FCF /* [CP] Check Pods Manifest.lock */ = {

0 commit comments

Comments
 (0)