{"record":{"id":"b1bf586a144d7fb8","repo":"ruvnet/RuView","slug":"failed-to-compile-macos-wifi-utility-e-stderr-de","errorCode":null,"errorMessage":"Failed to compile macOS WiFi utility: {e.stderr.decode('utf-8')}","messagePattern":"Failed to compile macOS WiFi utility: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"archive/v1/src/sensing/rssi_collector.py","lineNumber":676,"sourceCode":"\n    # -- public API ----------------------------------------------------------\n\n    @property\n    def sample_rate_hz(self) -> float:\n        return self._rate\n\n    def start(self) -> None:\n        if self._running:\n            return\n        \n        # Ensure binary exists\n        import os\n        if not os.path.exists(self.swift_bin):\n            logger.info(\"Compiling mac_wifi.swift to %s\", self.swift_bin)\n            try:\n                subprocess.run([\"swiftc\", \"-O\", \"-o\", self.swift_bin, self.swift_src], check=True, capture_output=True)\n            except subprocess.CalledProcessError as e:\n                raise RuntimeError(f\"Failed to compile macOS WiFi utility: {e.stderr.decode('utf-8')}\")\n            except FileNotFoundError:\n                raise RuntimeError(\"swiftc is not installed. Please install Xcode Command Line Tools to use native macOS WiFi sensing.\")\n\n        self._running = True\n        self._thread = threading.Thread(\n            target=self._sample_loop, daemon=True, name=\"mac-rssi-collector\"\n        )\n        self._thread.start()\n        logger.info(\"MacosWifiCollector started at %.1f Hz\", self._rate)\n\n    def stop(self) -> None:\n        self._running = False\n        if self._process:\n            self._process.terminate()\n            try:\n                self._process.wait(timeout=1.0)\n            except subprocess.TimeoutExpired:\n                self._process.kill()","sourceCodeStart":658,"sourceCodeEnd":694,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/archive/v1/src/sensing/rssi_collector.py#L658-L694","documentation":"MacosWifiCollector.start() lazily compiles the bundled mac_wifi.swift helper with 'swiftc -O' the first time it runs. swiftc executed but exited nonzero (subprocess.CalledProcessError), and the collector surfaces the compiler's stderr verbatim. This means Xcode tools are installed but the Swift source failed to build against the current SDK, typically after a macOS/Xcode update changed CoreWLAN APIs, or the cached source/binary state is inconsistent.","triggerScenarios":"First start of MacosWifiCollector on a machine where the swift_bin binary does not yet exist and the swiftc invocation fails: macOS or Xcode Command Line Tools upgraded to a version whose CoreWLAN/AirPort API differs from what mac_wifi.swift uses; Swift language-mode changes rejecting the source; a truncated or missing mac_wifi.swift resource.","commonSituations":"After yearly macOS/Xcode updates; after switching Xcode versions with xcode-select; moving or repackaging the app so the swift source path resolves but content is stale; CI runners with beta Xcode toolchains.","solutions":["Reproduce manually to see the full error: run 'swiftc -O -o /tmp/mac_wifi <repo>/.../mac_wifi.swift' and read the diagnostics (the raised message already embeds stderr).","Update Xcode Command Line Tools to the latest for your macOS ('softwareupdate --install \"Command Line Tools\"') and clear the stale compiled binary so it rebuilds.","If the source uses a changed API, patch mac_wifi.swift for the current CoreWLAN surface or pin the Xcode version that matches the source.","Delete the cached swift_bin path so the next start() recompiles cleanly after fixes."],"exampleFix":"# before\ncollector = MacosWifiCollector(rate=2.0)\ncollector.start()  # RuntimeError: Failed to compile macOS WiFi utility: <swiftc stderr>\n\n# after\nimport subprocess, pathlib\nsrc = pathlib.Path('src/sensing/mac_wifi.swift')\nsubprocess.run(['swiftc', '-O', '-o', '/tmp/mac_wifi', str(src)], check=True)  # surface real diagnostics\ncollector = MacosWifiCollector(rate=2.0)\ncollector.start()","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    collector.start()\nexcept RuntimeError as exc:\n    if 'Failed to compile' in str(exc):\n        logger.error('swift compile failed; run swiftc manually for diagnostics: %s', exc)\n        # optionally fall back to rebuilding after clearing the cached binary\n        raise","preventionTips":["Pin the macOS/Xcode version in CI so mac_wifi.swift compiles against a known CoreWLAN surface.","Run the swiftc compile step during image build instead of first start(), so failures surface at build time.","Keep the compiled binary path stable and pre-warmed; recompile deliberately after Xcode upgrades, not lazily in production start()."],"tags":["macos","swift","build","xcode","toolchain"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}