import AppKit // Before macOS 26 the system draws the supplied silhouette as it is; unlike iOS // it does not mask an opaque master. Derive the Mac's rounded tile on Apple's // 824-on-1024 grid from the full-bleed square master, the iPhone's. Not from // Resources/AppIcon.png: that one is already rounded onto the grid, and // drawing it into the grid again left the artwork at 664 of 1024, small in the // Dock beside every other app. macOS 26 and later use Assets.car instead // (bundle-mac.py), where the system applies the mask. let native = URL(fileURLWithPath: #filePath).standardizedFileURL .deletingLastPathComponent().deletingLastPathComponent() let resources = native.appendingPathComponent("apple/Sources/CallsMac/Resources") let master = native.appendingPathComponent("ios/Assets.xcassets/AppIcon.appiconset/AppIcon.png") guard let source = NSImage(contentsOf: master), let bitmap = NSBitmapImageRep(bitmapDataPlanes: nil, pixelsWide: 1024, pixelsHigh: 1024, bitsPerSample: 8, samplesPerPixel: 4, hasAlpha: true, isPlanar: false, colorSpaceName: .deviceRGB, bytesPerRow: 0, bitsPerPixel: 0), let context = NSGraphicsContext(bitmapImageRep: bitmap) else { fatalError("Cannot load or render Calls's icon") } NSGraphicsContext.saveGraphicsState() NSGraphicsContext.current = context context.imageInterpolation = .high let tile = NSRect(x: 100, y: 100, width: 824, height: 824) NSBezierPath(roundedRect: tile, xRadius: 184, yRadius: 184).addClip() source.draw(in: tile, from: .zero, operation: .copy, fraction: 1) NSGraphicsContext.restoreGraphicsState() guard let png = bitmap.representation(using: .png, properties: [:]) else { fatalError("Cannot encode Calls's icon") } try png.write(to: resources.appendingPathComponent("MacIcon.png"))