Early hookup for mac

This commit is contained in:
Connor Yoh 2025-07-16 10:52:38 +01:00
parent 39ca9f47d8
commit e4a81c0849
3 changed files with 26 additions and 108 deletions

View File

@ -212,76 +212,6 @@ jobs:
echo "CERT_ID=$CERT_ID" >> $GITHUB_ENV
echo "Certificate imported."
- name: Sign all native libs
if: false && matrix.platform == 'macos-13'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
APPLE_SIGNING_IDENTITY: ${{ env.CERT_ID }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
APPLE_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
run: |
cd ./frontend/src-tauri/libs
MAIN_JAR=$(ls stirling-pdf*.jar | head -n 1)
find "$MAIN_JAR" -name "*.dylib" -exec codesign --force --options runtime --sign "$CERT_ID" {} \;
- name: Sign JAR with jarsigner
if: false && (matrix.platform == 'macos-latest' || matrix.platform == 'macos-13')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
APPLE_SIGNING_IDENTITY: ${{ env.CERT_ID }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
APPLE_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
run: |
echo "🔐 Signing JAR with jarsigner..."
cd ./frontend/src-tauri/libs
# Get the main JAR
MAIN_JAR=$(ls stirling-pdf*.jar | head -n 1)
echo "📦 Processing main JAR: $MAIN_JAR"
# Create a backup
cp "$MAIN_JAR" "${MAIN_JAR}.backup"
# Sign the JAR using jarsigner with the Apple Developer certificate
echo "🔐 Signing JAR with Apple Developer certificate..."
KEYCHAIN_PATH="$HOME/Library/Keychains/build.keychain-db"
echo "Using keychain path: $KEYCHAIN_PATH"
# Ensure keychain is unlocked and accessible
security unlock-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
security set-keychain-settings -t 3600 -u build.keychain
# Try jarsigner with proper error handling
echo "Attempting jarsigner with KeychainStore..."
jarsigner -verbose \
-keystore "$KEYCHAIN_PATH" \
-storetype KeychainStore \
-storepass "$KEYCHAIN_PASSWORD" \
-keypass "$APPLE_CERTIFICATE_PASSWORD" \
-signedjar "${MAIN_JAR}.signed" \
"$MAIN_JAR" \
"$CERT_ID";
echo "✅ KeychainStore signing successful"
# Replace original with signed JAR
mv "${MAIN_JAR}.signed" "$MAIN_JAR"
# Verify the signature
echo "🔍 Verifying JAR signature..."
jarsigner -verify -verbose "$MAIN_JAR"
echo "✅ JAR signed successfully with jarsigner"
- name: Check DMG creation dependencies (macOS only)
if: matrix.platform == 'macos-latest' || matrix.platform == 'macos-13'
run: |
@ -310,37 +240,6 @@ jobs:
tauriScript: npx tauri
args: ${{ matrix.args }}
- name: Debug DMG creation failure (macOS-13 only)
if: failure() && matrix.platform == 'macos-13'
run: |
echo "🐛 DMG creation failed on macOS-13, investigating..."
# Check if bundle_dmg.sh exists and show its contents
BUNDLE_DMG_PATH="./frontend/src-tauri/target/x86_64-apple-darwin/release/bundle/dmg/bundle_dmg.sh"
if [ -f "$BUNDLE_DMG_PATH" ]; then
echo "📄 bundle_dmg.sh contents:"
cat "$BUNDLE_DMG_PATH"
echo ""
echo "🔍 bundle_dmg.sh permissions:"
ls -la "$BUNDLE_DMG_PATH"
echo ""
echo "📋 Trying to run bundle_dmg.sh manually:"
cd "$(dirname "$BUNDLE_DMG_PATH")"
bash -x "./$(basename "$BUNDLE_DMG_PATH")" || echo "Manual execution also failed"
else
echo "❌ bundle_dmg.sh not found at $BUNDLE_DMG_PATH"
fi
# Check for any log files in the DMG directory
DMG_DIR="./frontend/src-tauri/target/x86_64-apple-darwin/release/bundle/dmg"
if [ -d "$DMG_DIR" ]; then
echo "📁 DMG directory contents:"
ls -la "$DMG_DIR"
echo ""
echo "🔍 Looking for log files:"
find "$DMG_DIR" -name "*.log" -o -name "*.err" | head -5
fi
- name: Rename artifacts
shell: bash
run: |
@ -362,7 +261,7 @@ jobs:
- name: Upload artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: tauri-${{ matrix.name }}
name: Stirling-PDF-${{ matrix.name }}
path: ./dist/*
retention-days: 7

View File

@ -31,6 +31,15 @@ pub fn initialize_file_handler(app: &AppHandle<tauri::Wry>) {
check_command_line_args();
}
/// Early initialization for macOS delegate registration
pub fn early_init() {
#[cfg(target_os = "macos")]
{
add_log("🔄 Early macOS initialization...".to_string());
macos_native::register_delegate_early();
}
}
/// Check command line arguments for file paths (universal fallback)
fn check_command_line_args() {
let args: Vec<String> = std::env::args().collect();
@ -100,12 +109,10 @@ mod macos_native {
true
}
pub fn register_open_file_handler(app: &AppHandle<tauri::Wry>) {
add_log("🔧 Registering macOS native file handler...".to_string());
// Register the delegate immediately when the module loads
pub fn register_delegate_early() {
add_log("🔧 Registering macOS delegate early...".to_string());
// Store the app handle
*APP_HANDLE.lock().unwrap() = Some(app.clone());
unsafe {
let delegate_class = Class::get("AppDelegate").unwrap_or_else(|| {
let superclass = class!(NSObject);
@ -119,6 +126,15 @@ mod macos_native {
let _: () = msg_send![ns_app, setDelegate:delegate];
}
add_log("✅ macOS delegate registered early".to_string());
}
pub fn register_open_file_handler(app: &AppHandle<tauri::Wry>) {
add_log("🔧 Connecting app handle to file handler...".to_string());
// Store the app handle
*APP_HANDLE.lock().unwrap() = Some(app.clone());
// Process any files that were opened before app was ready
let pending_files = {
let mut pending = PENDING_FILES.lock().unwrap();
@ -133,6 +149,6 @@ mod macos_native {
let _ = app.emit("macos://open-file", file_path);
}
add_log("✅ macOS native file handler registered successfully".to_string());
add_log("✅ macOS file handler connected successfully".to_string());
}
}

View File

@ -9,6 +9,9 @@ use utils::{add_log, get_tauri_logs};
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
// Initialize file handler early for macOS
file_handler::early_init();
tauri::Builder::default()
.plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_fs::init())