mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-11 02:51:11 +00:00
Register latest share extension during development
This commit is contained in:
1 parent
f6588c3c43
commit
606446a1b9
2 files changed
+66
No files matched your search
@@ -40,6 +40,24 @@
|
|||||||
debugDocumentVersioning = "YES"
|
debugDocumentVersioning = "YES"
|
||||||
debugServiceExtension = "internal"
|
debugServiceExtension = "internal"
|
||||||
allowLocationSimulation = "YES">
|
allowLocationSimulation = "YES">
|
||||||
|
<PostActions>
|
||||||
|
<ExecutionAction
|
||||||
|
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
|
||||||
|
<ActionContent
|
||||||
|
title = "Register dev QuickDrop for Finder Share"
|
||||||
|
scriptText = ""${SRCROOT}/scripts/use-dev-share-extension.sh" ">
|
||||||
|
<EnvironmentBuildable>
|
||||||
|
<BuildableReference
|
||||||
|
BuildableIdentifier = "primary"
|
||||||
|
BlueprintIdentifier = "69DA9A0D29E0BF5100A442DA"
|
||||||
|
BuildableName = "QuickDrop.app"
|
||||||
|
BlueprintName = "QuickDrop"
|
||||||
|
ReferencedContainer = "container:QuickDrop.xcodeproj">
|
||||||
|
</BuildableReference>
|
||||||
|
</EnvironmentBuildable>
|
||||||
|
</ActionContent>
|
||||||
|
</ExecutionAction>
|
||||||
|
</PostActions>
|
||||||
<BuildableProductRunnable
|
<BuildableProductRunnable
|
||||||
runnableDebuggingMode = "0">
|
runnableDebuggingMode = "0">
|
||||||
<BuildableReference
|
<BuildableReference
|
||||||
|
|||||||
Executable
+48
@@ -0,0 +1,48 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Make Finder > Share > QuickDrop use the app Xcode just built (not a stale Release/archive copy).
|
||||||
|
#
|
||||||
|
# macOS LaunchServices registers EVERY QuickDrop.app on disk that shares the bundle id
|
||||||
|
# (com.leonboettger.neardrop) -- Debug build, Release build, archives, old DerivedData, ... -- and the
|
||||||
|
# share sheet then picks among those duplicates heuristically, so a stale copy can run instead of the
|
||||||
|
# one you just built. This script makes the freshly built app the ONLY registered copy of that bundle id.
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# - Standalone: scripts/use-dev-share-extension.sh (re-points Finder at the newest Debug build)
|
||||||
|
# - Xcode: add as a Run post-action (Product > Scheme > Edit Scheme > Run > Post-actions >
|
||||||
|
# "+" > New Run Script Action; "Provide build settings from: QuickDrop"; paste:
|
||||||
|
# "${SRCROOT}/scripts/use-dev-share-extension.sh"
|
||||||
|
# Post-actions run outside the build sandbox, so lsregister/mdfind work there even
|
||||||
|
# though ENABLE_USER_SCRIPT_SANDBOXING is YES for build phases.
|
||||||
|
#
|
||||||
|
# `set -u` (not -e): a transient lsregister hiccup shouldn't fail the Xcode Run post-action (red dialog).
|
||||||
|
set -u
|
||||||
|
|
||||||
|
LSREGISTER="/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister"
|
||||||
|
BUNDLE_ID="com.leonboettger.neardrop"
|
||||||
|
|
||||||
|
# Prefer the app Xcode just built (post-action provides these); else the newest Debug build on disk.
|
||||||
|
APP=""
|
||||||
|
if [ "${BUILT_PRODUCTS_DIR:-}" != "" ] && [ "${WRAPPER_NAME:-}" != "" ] && [ -d "${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}" ]; then
|
||||||
|
APP="${BUILT_PRODUCTS_DIR}/${WRAPPER_NAME}"
|
||||||
|
else
|
||||||
|
APP="$(mdfind "kMDItemCFBundleIdentifier == '${BUNDLE_ID}'" 2>/dev/null | grep '/Build/Products/Debug/QuickDrop.app$' | head -1)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "${APP}" ] || [ ! -d "${APP}" ]; then
|
||||||
|
echo "use-dev-share-extension: no QuickDrop Debug build found -- build it in Xcode first." >&2
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Unregister every OTHER on-disk copy of the bundle id, then (re)register only this one.
|
||||||
|
mdfind "kMDItemCFBundleIdentifier == '${BUNDLE_ID}'" 2>/dev/null | while IFS= read -r other; do
|
||||||
|
[ "${other}" = "${APP}" ] && continue
|
||||||
|
"${LSREGISTER}" -u "${other}" 2>/dev/null || true
|
||||||
|
done
|
||||||
|
"${LSREGISTER}" -f "${APP}"
|
||||||
|
|
||||||
|
# Drop any stale running extension so the next Share rebuilds against the fresh registration.
|
||||||
|
pkill -f "${BUNDLE_ID}.ShareExtension" 2>/dev/null || true
|
||||||
|
|
||||||
|
echo "use-dev-share-extension: Finder Share -> QuickDrop now points at:"
|
||||||
|
echo " ${APP}"
|
||||||
Reference in new issue
Block a user