-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add build phase to detect nested frameworks #21130
Merged
mokagio
merged 3 commits into
mokagio/gutenberg-xcframework-setup
from
mokagio/detect-nested-frameworks
Jul 20, 2023
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,27 @@ | ||
#!/bin/sh -eu | ||
|
||
set pipefail | ||
|
||
# Nested frameworks (i.e. having a Frameworks/ folder inside *.app/Frameworks/.framework) is invalid and will make the build be rejected during TestFlight validation. | ||
# | ||
# See also https://github.com/woocommerce/woocommerce-ios/pull/4226 | ||
|
||
# This script is intended to be used as a Build Phase on the main app target, as the very last build phase (and especially after the "Embed Frameworks" phase) | ||
|
||
NESTED_FMKS_DIRS=$(find "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" -name Frameworks -depth 2) | ||
if [ -z "$NESTED_FMKS_DIRS" ]; then | ||
echo "✅ No nested framework found, you're good to go!" | ||
else | ||
echo "❌ Found nested \`Frameworks\` folder inside frameworks of final bundle." | ||
for fmk_dir in $NESTED_FMKS_DIRS; do | ||
# Extract the name of the parent framework containing the nested ones | ||
parent_fmk=$(basename $(dirname $fmk_dir) .framework) | ||
# Extract the list of frameworks nested inside that parent framework. In the next command: | ||
# * `-depth 1` is to avoid logging cases of "C nested in B itself nested in A" (2+ levels of nesting), since C nested in B will already be logged when looping on fmk_dir=B, so no need to log it during fmk_dir=A too. | ||
# * The `sed` command removes the leading `./` in the paths returned by `find`, then quote the results in backticks for nicer formatting in final message. | ||
# * The `tr` command joins all the lines (= found frameworks) with a `,`. Note that this will result in an extra comma at the end of the list too, but we'll get rid of that in the final message using ${nested_fmks%,} bash substitution. | ||
nested_fmks=$(cd "${fmk_dir}" && find . -name '*.framework' -depth 1 | sed "s:^./\(.*\)$:\`\1\`:" | tr '\n' ',') | ||
echo "error: Found nested frameworks in ${fmk_dir} -- Such a configuration is invalid and will be rejected by TestFlight. Please fix by choosing 'Do Not Embed' for the nested framework(s) ${nested_fmks%,} within the \`${parent_fmk}\` Xcode project which links to them. See paNNhX-ee-p2." | ||
done | ||
exit 1 | ||
fi |
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 |
---|---|---|
|
@@ -18311,6 +18311,7 @@ | |
37399571B0D91BBEAE911024 /* [CP] Embed Pods Frameworks */, | ||
920B9A6DAD47189622A86A9C /* [CP] Copy Pods Resources */, | ||
E1C5456F219F10E000896227 /* Copy Gutenberg JS */, | ||
3FF795712A6671DB00F27B17 /* Lint against nested frameworks */, | ||
); | ||
buildRules = ( | ||
); | ||
|
@@ -18607,6 +18608,7 @@ | |
FABB264A2602FC2C00C8785C /* [CP] Embed Pods Frameworks */, | ||
FABB264B2602FC2C00C8785C /* [CP] Copy Pods Resources */, | ||
FABB264C2602FC2C00C8785C /* Copy Gutenberg JS */, | ||
3FF795732A66730200F27B17 /* Lint against nested frameworks */, | ||
); | ||
buildRules = ( | ||
); | ||
|
@@ -20120,6 +20122,43 @@ | |
shellPath = /bin/sh; | ||
shellScript = "$SRCROOT/../Scripts/BuildPhases/GenerateCredentials.sh\n"; | ||
}; | ||
3FF795712A6671DB00F27B17 /* Lint against nested frameworks */ = { | ||
isa = PBXShellScriptBuildPhase; | ||
alwaysOutOfDate = 1; | ||
buildActionMask = 2147483647; | ||
files = ( | ||
); | ||
inputFileListPaths = ( | ||
); | ||
inputPaths = ( | ||
); | ||
name = "Lint against nested frameworks"; | ||
outputFileListPaths = ( | ||
); | ||
outputPaths = ( | ||
); | ||
runOnlyForDeploymentPostprocessing = 0; | ||
shellPath = /bin/sh; | ||
shellScript = "\"$SRCROOT/../Scripts/BuildPhases/LintNestedFrameworks.sh\"\n"; | ||
}; | ||
3FF795732A66730200F27B17 /* Lint against nested frameworks */ = { | ||
isa = PBXShellScriptBuildPhase; | ||
buildActionMask = 2147483647; | ||
files = ( | ||
); | ||
inputFileListPaths = ( | ||
); | ||
inputPaths = ( | ||
); | ||
name = "Lint against nested frameworks"; | ||
outputFileListPaths = ( | ||
); | ||
outputPaths = ( | ||
); | ||
runOnlyForDeploymentPostprocessing = 0; | ||
shellPath = /bin/sh; | ||
shellScript = "\"$SRCROOT/../Scripts/BuildPhases/LintNestedFrameworks.sh\"\n"; | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need the build phase in both WordPress and Jetpack. We cannot run this before building the apps in a centralized aggregated target because the script looks into the target's frameworks. |
||
49AE9271B82C7D67430387FA /* [CP] Embed Pods Frameworks */ = { | ||
isa = PBXShellScriptBuildPhase; | ||
buildActionMask = 2147483647; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only now notice that the shebang doesn't use Bash. Possibly why I ShellCheck warned me about having
pipefail
in there.