Skip to content

Commit

Permalink
Update macOS build
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben2776 committed Dec 26, 2024
1 parent e922f2e commit cec2ebc
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 32 deletions.
63 changes: 35 additions & 28 deletions .github/workflows/BuildMacOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,34 +39,41 @@ jobs:

- name: Prepare and Sign arm64 App Bundle
run: |
# Create entitlements file
cat > entitlements.plist << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
</dict>
</plist>
EOF
# Sign all dylibs and binaries
find "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64/PicView.app" -type f -name "*.dylib" -o -name "PicView.Avalonia.MacOS" | while read file; do
codesign --force --options runtime --sign - --entitlements entitlements.plist "$file"
done
# Sign the app bundle
codesign --force --options runtime --sign - --entitlements entitlements.plist "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64/PicView.app"
# Step 5: Create DMG for arm64
- name: Create DMG for arm64
run: |
hdiutil create -volname "PicView" -srcfolder "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64/PicView.app" -ov -format UDZO "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64.dmg"
# Create entitlements file
cat > entitlements.plist << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
</dict>
</plist>
EOF
APP_PATH="${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64/PicView.app"
# Verify bundle structure
if [ ! -f "$APP_PATH/Contents/Info.plist" ]; then
echo "Error: Info.plist not found in the expected location"
exit 1
fi
# Sign all dylibs and binaries
find "$APP_PATH/Contents/MacOS" -type f \( -name "*.dylib" -o -name "PicView.Avalonia.MacOS" \) | while read file; do
codesign --force --options runtime --sign - --entitlements entitlements.plist "$file"
done
# Sign the app bundle
codesign --force --options runtime --sign - --entitlements entitlements.plist "$APP_PATH"
# Step 5: Create DMG for arm64
- name: Create DMG for arm64
run: |
hdiutil create -volname "PicView" -srcfolder "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64/PicView.app" -ov -format UDZO "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64.dmg"
# Step 6: Upload arm64 artifacts
Expand Down
5 changes: 4 additions & 1 deletion Build/Build Avalonia.MacOS.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ New-Item -ItemType Directory -Force -Path $macOSPath
New-Item -ItemType Directory -Force -Path $resourcesPath

# Create Info.plist
$infoPlistPath = Join-Path -Path $contentsPath -ChildPath "Info.plist" # Add this line to specify the correct path
$infoPlistContent = @"
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
Expand All @@ -78,7 +79,7 @@ $infoPlistContent = @"
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleExecutable</key>
<string>PicView.Avalonia.MacOS</string>
<string>PicView</string>
<key>CFBundleIconFile</key>
<string>AppIcon.icns</string>
<key>CFBundleShortVersionString</key>
Expand All @@ -97,6 +98,8 @@ $infoPlistContent = @"
</array>
<key>NSRequiresAquaSystemAppearance</key>
<false/>
<key>LSApplicationCategoryType</key>
<string>public.app-category.graphics-design</string>
</dict>
</plist>
"@
Expand Down
5 changes: 2 additions & 3 deletions src/PicView.Avalonia.MacOS/PicView.Avalonia.MacOS.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<!--If you are willing to use Windows/MacOS native APIs you will need to create 3 projects.
One for Windows with net7.0-windows TFM, one for MacOS with net7.0-macos and one with net7.0 TFM for Linux.-->
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Platforms>x64;arm64</Platforms>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
Expand All @@ -20,6 +18,7 @@
<Copyright>© Ruben Hyldgaard Negendahl</Copyright>
<ImplicitUsings>enable</ImplicitUsings>
<Product>PicView</Product>
<AssemblyName>PicView</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>none</DebugType>
Expand Down

0 comments on commit cec2ebc

Please sign in to comment.