fix(desktop): launch WeChat share extension with system entry point
This commit is contained in:
1 parent
ebe5220c0d
commit
615a25f501
3 files changed
+13
-3
No files matched your search
@@ -38,10 +38,10 @@ final class ShareViewController: NSViewController {
|
||||
guard let url = shareURL(for: destination) else {
|
||||
throw CocoaError(.fileWriteUnknown)
|
||||
}
|
||||
if let context = extensionContext {
|
||||
_ = await context.open(url)
|
||||
context.completeRequest(returningItems: nil)
|
||||
guard let context = extensionContext, await context.open(url) else {
|
||||
throw CocoaError(.fileReadUnknown)
|
||||
}
|
||||
context.completeRequest(returningItems: nil)
|
||||
} catch {
|
||||
extensionContext?.cancelRequest(withError: error)
|
||||
}
|
||||
|
||||
@@ -30,12 +30,19 @@ sed \
|
||||
plutil -lint "$appex/Contents/Info.plist" >/dev/null
|
||||
swiftc \
|
||||
-O \
|
||||
-parse-as-library \
|
||||
-application-extension \
|
||||
-target "$target" \
|
||||
-sdk "$sdk" \
|
||||
-module-name EdgeEverShare \
|
||||
-emit-executable \
|
||||
-Xlinker -e -Xlinker _NSExtensionMain \
|
||||
-o "$appex/Contents/MacOS/EdgeEverShare" \
|
||||
"$source_directory/ShareViewController.swift"
|
||||
if ! xcrun nm -u "$appex/Contents/MacOS/EdgeEverShare" | grep -q '_NSExtensionMain'; then
|
||||
echo "Share extension is missing the NSExtensionMain entry point" >&2
|
||||
exit 1
|
||||
fi
|
||||
chmod 755 "$appex/Contents/MacOS/EdgeEverShare"
|
||||
codesign \
|
||||
--force \
|
||||
|
||||
@@ -96,6 +96,9 @@ if (requestedPlatform === "darwin") {
|
||||
const shareExtension = join(unpackedApp, "Contents", "PlugIns", "EdgeEverShare.appex", "Contents", "MacOS", "EdgeEverShare");
|
||||
assert.ok(existsSync(shareExtension), `macOS app bundle is missing the WeChat share extension: ${shareExtension}`);
|
||||
verifyMachOArch(shareExtension, requestedArch, "WeChat share extension");
|
||||
const extensionSymbols = spawnSync("nm", ["-u", shareExtension], { encoding: "utf8" });
|
||||
assert.equal(extensionSymbols.status, 0, `WeChat share extension symbol inspection failed: ${extensionSymbols.stderr || extensionSymbols.stdout}`);
|
||||
assert.match(extensionSymbols.stdout, /\b_NSExtensionMain\b/, "WeChat share extension must use the system extension entry point");
|
||||
const shareExtensionInfo = readFileSync(join(unpackedApp, "Contents", "PlugIns", "EdgeEverShare.appex", "Contents", "Info.plist"), "utf8");
|
||||
assert.match(shareExtensionInfo, /com\.apple\.share-services/, "WeChat share extension must register a share service");
|
||||
assert.match(shareExtensionInfo, /NSExtensionActivationSupportsFileWithMaxCount/, "WeChat share extension must accept shared files");
|
||||
|
||||
Reference in new issue
Block a user