-
-
Notifications
You must be signed in to change notification settings - Fork 123
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
script should handle archives as well as regular builds #34
Conversation
Can you describe the changes? |
Sure! How's the new description ☝️? |
@sindresorhus pls consider this a friendly “ping” to let me know if you want any changes to accept this. |
LaunchAtLogin/copy-helper.sh
Outdated
else | ||
WHERE="${BUILT_PRODUCTS_DIR}" | ||
origin_helper_path="${WHERE}/$FRAMEWORKS_FOLDER_PATH/LaunchAtLogin.framework/Resources/LaunchAtLoginHelper.app" | ||
helper_dir="${WHERE}/$CONTENTS_FOLDER_PATH/Library/LoginItems" |
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.
Use tab-indentation.
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.
This one is the same for both branches, so it could be outside the if-statement.
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.
Unfortunately, it can't be set outside the if
bc it's used inside the if
to set origin_helper_path
(and again outside to set helper_path
), but it also depends on the value of WHERE
which is set differently in the if
and else
cases.
Perhaps you have a different setup in mind?
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.
Unfortunately, it can't be set outside the if
bc it's used inside the if
to set origin_helper_path
(and again outside to set helper_path
), but it also depends on the value of WHERE
which is set differently in the if
and else
cases.
Perhaps you have a different setup in mind?
LaunchAtLogin/copy-helper.sh
Outdated
@@ -1,7 +1,15 @@ | |||
#!/bin/bash | |||
|
|||
origin_helper_path="$BUILT_PRODUCTS_DIR/$FRAMEWORKS_FOLDER_PATH/LaunchAtLogin.framework/Resources/LaunchAtLoginHelper.app" | |||
helper_dir="$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/Library/LoginItems" | |||
if [ "${DEPLOYMENT_LOCATION}" = "YES" ] ; then |
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.
if [ "${DEPLOYMENT_LOCATION}" = "YES" ] ; then | |
if [ "${DEPLOYMENT_LOCATION}" = "YES" ]; then |
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.
This could use a code comment to make it clear what the if
check does.
LaunchAtLogin/copy-helper.sh
Outdated
origin_helper_path="$BUILT_PRODUCTS_DIR/$FRAMEWORKS_FOLDER_PATH/LaunchAtLogin.framework/Resources/LaunchAtLoginHelper.app" | ||
helper_dir="$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/Library/LoginItems" | ||
if [ "${DEPLOYMENT_LOCATION}" = "YES" ] ; then | ||
WHERE="${DSTROOT}" |
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.
WHERE
is too generic. Make a descriptive variable name. Should also be lowercase.
@@ -18,5 +26,5 @@ fi | |||
|
|||
if [[ $CONFIGURATION == "Release" ]]; then | |||
rm -rf "$origin_helper_path" | |||
rm "$(dirname "$origin_helper_path")/copy-helper.sh" | |||
rm "$(dirname "$origin_helper_path")/copy-helper.sh" || true |
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.
Why are you silencing errors?
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.
If there's no copy-helper.sh
file in that location, that command will return a non-zero value and - bc it's the last command - the script will return that value. When the script returns a non-zero value, it causes that build step to fail.
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.
If there's no copy-helper.sh
file in that location, the rm
command will return a non-zero value and - bc it's the last command - the script will return that value. When the script returns a non-zero value, it causes that build step to fail.
Are you sure about this? I've never had any problems using "Archive", only "Profile". |
It was causing problems for me when trying to make an Archive. |
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.
@sindresorhus I believe the latest commit addresses all your suggestions. Please have another look.
@sindresorhus pls have another look at this PR. I believe everything you've asked for has either been implemented or addressed if it can't be implemented. |
I've tried using your fork @sweetleon and my Archiving process stopped working... |
Actually what stopped working is the Hardening & Signing process I have with this script:
Here's the error:
|
@@ -18,5 +26,5 @@ fi | |||
|
|||
if [[ $CONFIGURATION == "Release" ]]; then | |||
rm -rf "$origin_helper_path" |
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 think an || true
also needs to be added here. Basically what happens is that on first "Release" or "Archive" build the script deletes the files, any consecutive build thinks that the Frameworks has already been copied over and skips copying the framework again, hence the files are already missing from there...
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.
If that folder isn't present, there'd be a message printed to stderr
but it shouldn't cause the script to fail. (Since it's not the last command in the script, it doesn't determine the script's exit code.) Are you seeing the script fail bc of this?
LOCATION="$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/Library/LoginItems/LaunchAtLoginHelper.app" ...
Seems like you're trying to codesign the exact thing the script is designed to delete. Once it's deleted, you won't have to codesign it. So I'd maybe chance the last line of the script to first check if it exists: |
Idk guys I've forked the repo and just done this: |
I tried this out now in my app and when archiving, I'm getting errors. Xcode 11.4.1.
|
Does this cause the build to fail? The changes should cause the build to ignore these errors. |
It did build successfully yes, but the helper app ended up at:
( Instead of:
|
@sweetleon Was your error that prompted this PR the following?
Because I just got and turned out it was because the LaunchAtLogin run script had moved to before the "Embed Framework" script in "Build Phases". Can you check if that's the case for you too? |
@sindresorhus that sounds familiar, but I'm no longer working on that project so I can't be sure. |
Fixes #7 by (a) deleting
LaunchAtLogin.app
from the correct location during Archive/Profiling builds, which differs from where it's during Debug/Run builds.IssueHunt Summary
Referenced issues
This pull request has been submitted to:
IssueHunt has been backed by the following sponsors. Become a sponsor