Skip to content

Commit 278a84b

Browse files
authored
Merge pull request #232 from HarborWallet/macos-dylibs
gettext and other macos dylibs
2 parents 0e44ed5 + 30c0479 commit 278a84b

File tree

5 files changed

+105
-20
lines changed

5 files changed

+105
-20
lines changed

.github/workflows/ci.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: CI
22

33
on:
44
pull_request:
@@ -9,6 +9,8 @@ jobs:
99
permissions:
1010
id-token: "write"
1111
contents: "read"
12+
env:
13+
USE_VENDOR_FEATURE: "1"
1214
steps:
1315
- uses: actions/checkout@v4
1416
- uses: DeterminateSystems/nix-installer-action@main
@@ -24,5 +26,5 @@ jobs:
2426
run: nix develop --command bash -c "just format-check"
2527
- name: Run clippy
2628
run: nix develop --command bash -c "just clippy"
27-
- name: Run tests
29+
- name: Run tests
2830
run: nix develop --command bash -c "just test"

Cargo.lock

+13-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676

7777
devShell = pkgs.mkShell rec {
7878
packages = inputs ++ [
79+
pkgs.git
7980
pkgs.mesa
8081
pkgs.libglvnd # Adds EGL support
8182
pkgs.xorg.libX11

scripts/build-macos.sh

+75-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ rm -f "$APP_TEMPLATE_PLIST.tmp.bak"
3535
export MACOSX_DEPLOYMENT_TARGET="11.0"
3636

3737
echo "Building Harbor for Apple Silicon..."
38-
cd harbor-ui
39-
cargo build --release --target=aarch64-apple-darwin --features vendored
40-
cd ..
38+
# Build from the root directory and explicitly specify the package
39+
cargo build --release --target=aarch64-apple-darwin --features vendored -p harbor-ui
4140

4241
echo "Creating app bundle..."
4342
# build app
@@ -46,4 +45,77 @@ mkdir -p "$APP_EXTRAS_DIR"
4645
cp -fRp "$APP_TEMPLATE" "$APP_DIR"
4746
cp -fp "target/aarch64-apple-darwin/release/$TARGET" "$APP_BINARY_DIR/harbor"
4847
touch -r "target/aarch64-apple-darwin/release/$TARGET" "$APP_DIR/$APP_NAME"
48+
49+
# Bundle libintl.8.dylib with the app
50+
echo "Bundling and fixing libintl.8.dylib..."
51+
FRAMEWORKS_DIR="$APP_DIR/$APP_NAME/Contents/Frameworks"
52+
# Ensure directory exists with proper permissions
53+
mkdir -p "$FRAMEWORKS_DIR"
54+
chmod 755 "$FRAMEWORKS_DIR"
55+
56+
# Find libintl.8.dylib in nix store
57+
LIBINTL_PATH=$(find /nix/store -name "libintl.8.dylib" -type f | head -n 1)
58+
if [ -n "$LIBINTL_PATH" ]; then
59+
echo "Found libintl at: $LIBINTL_PATH"
60+
61+
# Copy to Frameworks directory with sudo if needed
62+
echo "Copying library to Frameworks..."
63+
if ! cp "$LIBINTL_PATH" "$FRAMEWORKS_DIR/"; then
64+
echo "Standard copy failed, trying with elevated permissions..."
65+
# Try with sudo if available
66+
if command -v sudo >/dev/null 2>&1; then
67+
sudo cp "$LIBINTL_PATH" "$FRAMEWORKS_DIR/"
68+
sudo chown $(whoami) "$FRAMEWORKS_DIR/libintl.8.dylib"
69+
sudo chmod 644 "$FRAMEWORKS_DIR/libintl.8.dylib"
70+
else
71+
echo "ERROR: Could not copy libintl.8.dylib to Frameworks directory"
72+
exit 1
73+
fi
74+
fi
75+
76+
# Update binary to reference the bundled library using @rpath
77+
echo "Fixing reference in binary..."
78+
install_name_tool -add_rpath "@executable_path/../Frameworks" "$APP_BINARY_DIR/harbor"
79+
install_name_tool -change "$LIBINTL_PATH" "@rpath/libintl.8.dylib" "$APP_BINARY_DIR/harbor"
80+
81+
# Check if there are any other dependencies of libintl.8.dylib
82+
SUB_DEPS=$(otool -L "$FRAMEWORKS_DIR/libintl.8.dylib" | grep -v "/System/" | grep -v "@rpath" | grep -v "@executable_path" | grep -v "/usr/lib/" | awk -F' ' '{print $1}')
83+
if [ -n "$SUB_DEPS" ]; then
84+
echo "Processing dependencies of libintl.8.dylib..."
85+
for SUB_DEP_PATH in $SUB_DEPS; do
86+
# Skip if it's referring to itself
87+
if [[ "$SUB_DEP_PATH" == *"libintl.8.dylib"* ]]; then
88+
continue
89+
fi
90+
91+
SUB_DEP_NAME=$(basename "$SUB_DEP_PATH")
92+
echo "Processing dependency: $SUB_DEP_NAME"
93+
94+
# Copy to Frameworks directory with sudo if needed
95+
if ! cp "$SUB_DEP_PATH" "$FRAMEWORKS_DIR/"; then
96+
echo "Standard copy failed for $SUB_DEP_NAME, trying with elevated permissions..."
97+
if command -v sudo >/dev/null 2>&1; then
98+
sudo cp "$SUB_DEP_PATH" "$FRAMEWORKS_DIR/"
99+
sudo chown $(whoami) "$FRAMEWORKS_DIR/$SUB_DEP_NAME"
100+
sudo chmod 644 "$FRAMEWORKS_DIR/$SUB_DEP_NAME"
101+
else
102+
echo "WARNING: Could not copy $SUB_DEP_NAME to Frameworks directory"
103+
continue
104+
fi
105+
fi
106+
107+
# Fix the reference in libintl
108+
install_name_tool -change "$SUB_DEP_PATH" "@rpath/$SUB_DEP_NAME" "$FRAMEWORKS_DIR/libintl.8.dylib"
109+
110+
# Set the ID
111+
install_name_tool -id "@rpath/$SUB_DEP_NAME" "$FRAMEWORKS_DIR/$SUB_DEP_NAME"
112+
done
113+
fi
114+
115+
# Fix the ID of libintl itself
116+
install_name_tool -id "@rpath/libintl.8.dylib" "$FRAMEWORKS_DIR/libintl.8.dylib"
117+
else
118+
echo "Warning: Could not find libintl.8.dylib in nix store!"
119+
fi
120+
49121
echo "✨ Created '$APP_NAME' in '$APP_DIR'"

scripts/sign-macos.sh

+12-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ RELEASE_DIR="target/release"
1717
APP_DIR="$RELEASE_DIR/macos"
1818
APP_NAME="Harbor.app"
1919
APP_PATH="$APP_DIR/$APP_NAME"
20+
FRAMEWORKS_DIR="$APP_PATH/Contents/Frameworks"
2021

2122
# Clean up any leftover files from previous runs
2223
rm -f certificate.p12 notarization.zip
@@ -82,8 +83,18 @@ echo "Checking for valid signing identities..."
8283
IDENTITIES=$(security find-identity -v -p codesigning build.keychain | grep -c "valid identities found")
8384
echo "Found $IDENTITIES valid signing identities"
8485

86+
# First sign any bundled libraries in the Frameworks directory
87+
if [ -d "$FRAMEWORKS_DIR" ]; then
88+
echo "Signing bundled libraries in Frameworks directory..."
89+
find "$FRAMEWORKS_DIR" -type f -name "*.dylib" | while read -r lib; do
90+
echo "Signing library: $(basename "$lib")"
91+
/usr/bin/codesign --force --timestamp --sign "$MACOS_CERTIFICATE_NAME" --options runtime "$lib"
92+
done
93+
fi
94+
8595
echo "Signing Harbor.app..."
86-
/usr/bin/codesign --force -s "$MACOS_CERTIFICATE_NAME" --options runtime "$APP_PATH" -v
96+
# Sign the app with deep option to handle all bundled components
97+
/usr/bin/codesign --force --deep --timestamp -s "$MACOS_CERTIFICATE_NAME" --options runtime "$APP_PATH" -v
8798

8899
echo "Creating keychain profile for notarization..."
89100
xcrun notarytool store-credentials "harbor-notary-profile" \

0 commit comments

Comments
 (0)