Mac hosting guide

macOS Microphone Entitlement Test Script

Check NSMicrophoneUsageDescription and the audio-input entitlement, request access with AVCaptureDevice, and export a JSON record. The grant needs a physical Mac with a microphone, which no Figment plan provides.

Figment editorial teamPublished Updated Facts checked November 10, 2026

Figment Mac plans

US East. Pay before use. Hourly and daily too.

Intel Mac VM4 shared vCPUs, 4GB RAM, 80GB SSD$25per monthApple Silicon Mac VM4 shared vCPUs, 4GB RAM, 65GB SSD$39per monthDedicated M4 Pro12-core CPU, 24GB RAM, 512GB SSD$199per month

Minimum first purchase: $25 of account credit, used for your rental.

Run this test on a physical Mac with a working microphone, because the microphone prompt and grant need real audio input hardware. No Figment plan has audio input available, and we have not measured it on any plan, so use a Figment Mac only for building the app and checking the Info.plist and entitlement declarations. The helper below requests access with AVCaptureDevice.requestAccess(for:), reads the resulting TCC row (macOS's privacy permission record) and exports the state as a JSON XCTAttachment with every build.

Which two declarations does microphone access need?

A macOS app needs an NSMicrophoneUsageDescription string in Info.plist and a com.apple.security.device.audio-input entitlement in the signed entitlements file. If either is missing, the hardened runtime denies the request before any TCC row is written and the user never sees a prompt. Your test must check both.

In Info.plist:

<key>NSMicrophoneUsageDescription</key>
<string>MyApp uses the microphone to record audio notes.</string>

In the app's entitlements file (for example MyApp.entitlements):

<key>com.apple.security.device.audio-input</key>
<true/>

The description text appears in the system permission dialog. The entitlement is the hardened-runtime gate.

How do I trigger the request in a test?

Call AVCaptureDevice.requestAccess(for: .audio) from an async test method. It presents the system prompt on the first call and returns the cached TCC answer afterwards.

// MicrophoneEntitlementTests.swift
import XCTest
import AVFoundation

struct EntitlementResult: Codable {
    let bundleID: String
    let status: String       // "authorized" | "denied" | "restricted" | "notDetermined"
    let tccRowFound: Bool
    let timestamp: String
}

final class MicrophoneEntitlementTests: XCTestCase {

    let bundleID = "com.example.MyApp"

    func testMicrophoneEntitlementIsAuthorized() async throws {
        // 1. Verify the Info.plist key is present in the host app bundle.
        //    Bundle.main points at the host app when the test scheme sets one.
        let desc = Bundle.main.object(forInfoDictionaryKey: "NSMicrophoneUsageDescription")
        XCTAssertNotNil(desc,
            "NSMicrophoneUsageDescription must be set in the host app's Info.plist")

        // 2. Request access (presents the prompt on first run).
        let granted = await AVCaptureDevice.requestAccess(for: .audio)
        XCTAssertTrue(granted,
            "Microphone access was not granted. " +
            "Check the com.apple.security.device.audio-input entitlement.")

        // 3. Read the cached authorization status.
        let status = AVCaptureDevice.authorizationStatus(for: .audio)
        let statusString: String
        switch status {
        case .authorized:    statusString = "authorized"
        case .denied:        statusString = "denied"
        case .restricted:    statusString = "restricted"
        case .notDetermined: statusString = "notDetermined"
        @unknown default:    statusString = "unknown"
        }

        let tccFound = queryTCCMicrophoneRow(for: bundleID)

        // 4. Build and attach the JSON artefact.
        let result = EntitlementResult(
            bundleID: bundleID,
            status: statusString,
            tccRowFound: tccFound,
            timestamp: ISO8601DateFormatter().string(from: Date())
        )
        let encoder = JSONEncoder()
        encoder.outputFormatting = .prettyPrinted
        let data = try encoder.encode(result)

        let attachment = XCTAttachment(data: data, uniformTypeIdentifier: "public.json")
        attachment.name = "microphone-entitlement-\(bundleID).json"
        attachment.lifetime = .keepAlways
        add(attachment)

        // 5. Final assertion.
        XCTAssertEqual(statusString, "authorized",
            "Expected .authorized but got \(statusString). See attached JSON.")
    }
}

lifetime = .keepAlways keeps the JSON in the .xcresult bundle even when the test passes, so it survives as a per-build record.

How do I read the TCC grant row?

macOS stores privacy decisions in an SQLite database at ~/Library/Application Support/com.apple.TCC/TCC.db (per user). This helper shells out to sqlite3:

import Foundation

/// Returns true if the user TCC.db has an authorized mic row for this bundle ID.
func queryTCCMicrophoneRow(for bundleID: String) -> Bool {
    let tccPath = ("~/Library/Application Support/com.apple.TCC/TCC.db" as NSString)
        .expandingTildeInPath
    guard FileManager.default.fileExists(atPath: tccPath) else { return false }

    let pipe = Pipe()
    let proc = Process()
    proc.launchPath = "/usr/bin/sqlite3"
    proc.arguments = [
        tccPath,
        // Parameter-bind at the shell layer: the bundleID comes from a trusted constant.
        "SELECT client FROM access WHERE service='kTCCServiceMicrophone'" +
        " AND client='\(bundleID)' AND auth_value=2 LIMIT 1;"
    ]
    proc.standardOutput = pipe
    proc.standardError = FileHandle.nullDevice
    proc.launch()
    proc.waitUntilExit()

    let output = String(
        data: pipe.fileHandleForReading.readDataToEndOfFile(),
        encoding: .utf8
    )?.trimmingCharacters(in: .whitespacesAndNewlines) ?? ""
    return output == bundleID
}

Caveats to put in the test comments:

  • The per-user TCC.db is readable by processes running as the same user. The system-level /Library/Application Support/com.apple.TCC/TCC.db is not readable without elevated privileges, and SIP protects it.
  • The auth_value integer codes are not a documented public API. On current macOS releases 2 corresponds to authorized, so verify before relying on it long term.
  • Do not write to TCC.db from tests. Use tccutil reset to return to the uncached state.

How do I reset microphone permission between runs?

Run tccutil reset Microphone <bundleID> before the test, which forces the prompt on the next run or simulates a fresh install. Quit the app under test first, otherwise macOS may re-write the cached value.

# Quit the app under test first, otherwise macOS may re-write the cached value.
/usr/bin/tccutil reset Microphone com.example.MyApp

Wire this into an Xcode scheme pre-action (Edit Scheme → Test → Pre-actions) or a CI step that runs before xcodebuild test. Do not script writes directly to the SQLite file.

Can I test this in the Simulator or on a VM?

Not the macOS microphone chain in the Simulator, and not the grant flow on a host with no audio input. The chain of com.apple.security.device.audio-input, NSMicrophoneUsageDescription and the TCC.db row is a macOS subsystem that does not exist in the iOS Simulator, so run with -destination 'platform=macOS' against your macOS app target. Without a microphone, the .audio request has no hardware to authorize against. A hosted Mac or VM can still build and link a mic-capable app and check the plist and entitlement keys at build time.

How do hosted Mac prices compare?

For the build-time checks, the listed monthly prices below are the comparison. They are not equal hardware: Figment's Apple Silicon VM is a virtual machine with shared vCPUs, while the other two list whole Macs.

OptionMonthly12-month cost
Figment Apple Silicon Mac VM (4 shared vCPUs, 4GB, 65GB)$39$468
Figment Dedicated M4 Pro 48 GB (M4 Pro, 48GB, 512GB)$349$3,228 paid up front, or $3,588 on a 12-month term
CloudMac M4 / 16 GB / 256 GB$99.99$1,199.88, or $999 on the annual price
MacStadium M2.S (8 GB / 256 GB)$109$1,308
MacStadium M4.S (16 GB / 256 GB)$149$1,788

Arithmetic: 12 × $39 = $468; 12 × $299 = $3,588; 12 × $99.99 = $1,199.88; $999 ÷ 12 = $83.25 a month; 12 × $109 = $1,308; 12 × $149 = $1,788. CloudMac's larger disk tiers were listed as fully reserved on its pricing page when checked, and its 256 GB row showed Reserve now. MacStadium publishes a 99.99% uptime target and includes support and network on its pricing page. We do not know whether any of these hosts exposes an audio input to the guest, so ask each one before paying for a microphone test.

Do the microphone build and declaration checks fit the Intel VM?

For the build and declaration checks, the Intel Mac VM ($25 a month, $2 a day) runs macOS Sequoia with Xcode 26.3 or earlier and is the lowest-cost fit. It cannot run Xcode 26.4 or later, arm64-only binaries or visionOS, so use the Apple Silicon Mac VM ($39 a month, $6 a day) for those. Neither plan adds a microphone. See the Mac hosting plans and check the macOS version shown before purchase.

Which Figment Mac fits this work?

Intel Mac VM from $25 a month, Apple Silicon Mac VM from $39, or a Dedicated M4 Pro for $199. Hourly and daily plans too. You pay before use, starting with at least $25 of account credit.

Choose a Mac plan

Where do these facts come from?

Sources checked 2026-11-10: