fix(mac): migrate UDP discovery to Network.framework to trigger local… #12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build macOS App | |
| on: | |
| push: | |
| branches: [ "main", "master" ] | |
| workflow_dispatch: # 允许手动触发打包 | |
| jobs: | |
| build: | |
| runs-on: macos-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Build macOS App | |
| working-directory: ./Mac | |
| run: | | |
| # 1. 创建标准的 .app 目录结构 | |
| mkdir -p dist/CarpeCast.app/Contents/MacOS | |
| mkdir -p dist/CarpeCast.app/Contents/Resources | |
| # 2. 生成原生图标 (处理可能的出错) | |
| mkdir icon.iconset | |
| sips -z 256 256 ../Windows/Assets/CarpeCast-logo.png --out icon.iconset/icon_256x256.png || true | |
| iconutil -c icns icon.iconset -o dist/CarpeCast.app/Contents/Resources/icon.icns || true | |
| # 3. 动态生成 Info.plist 配置文件,声明所需权限 | |
| cat <<EOF > dist/CarpeCast.app/Contents/Info.plist | |
| <?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>CFBundleExecutable</key> | |
| <string>CarpeCast</string> | |
| <key>CFBundleIdentifier</key> | |
| <string>com.carpecast.macsender</string> | |
| <key>CFBundleName</key> | |
| <string>CarpeCast</string> | |
| <key>CFBundleIconFile</key> | |
| <string>icon</string> | |
| <key>CFBundlePackageType</key> | |
| <string>APPL</string> | |
| <key>LSMinimumSystemVersion</key> | |
| <string>11.0</string> | |
| <key>NSLocalNetworkUsageDescription</key> | |
| <string>CarpeCast 需要访问局域网以发现 Windows 接收端设备。</string> | |
| <key>NSAppleEventsUsageDescription</key> | |
| <string>CarpeCast 需要访问音乐应用以同步播放状态。</string> | |
| </dict> | |
| </plist> | |
| EOF | |
| # 4. 极速编译单文件 SwiftUI 应用 (-O 开启优化) | |
| swiftc CarpeCastApp.swift -parse-as-library -o dist/CarpeCast.app/Contents/MacOS/CarpeCast -O | |
| # 5. 压缩为标准 ZIP 防止权限丢失 | |
| cd dist | |
| zip -ry CarpeCast-Mac.zip CarpeCast.app | |
| - name: Upload Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: CarpeCast-Mac | |
| path: Mac/dist/CarpeCast-Mac.zip |