apple / apple/python-apple-fm-sdk

Build fails with Command Line Tools only — Xcode.app should not be required

Ouverte Adaptée aux débutants
#6 2 commentaires 3 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Python
Étoiles
1.2k
Forks
74
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

## Summary

`pip install` (and `pip install -e .`) fails on systems that have **Command Line Tools** installed but not the full **Xcode.app**. The build backend explicitly rejects Command Line Tools and requires `xcodebuild`, but the actual build only uses `swift build` via Swift Package Manager — which works fine with just Command Line Tools.

## Environment

- macOS 26.3 (Tahoe), Apple M3 Max
- Swift 6.2.3 (from Command Line Tools)
- `xcode-select -p` → `/Library/Developer/CommandLineTools`
- Xcode.app **not installed**

## Error

Running `pip install -e .` produces:

```
SwiftToolingError: The active developer directory is set to Command Line Tools
(/Library/Developer/CommandLineTools), but a full Xcode installation is required.
Please install Xcode. Then open Xcode at least once to accept the license agreement
and install the Swift SDKs.
```

## Root Cause

In [`build_backend.py`](https://github.com/apple/python-apple-fm-sdk/blob/main/build_backend.py), `_build_c_bindings()` performs three checks that require Xcode.app:

1. **`xcode-select -p` path check** — rejects if path contains `CommandLineTools`
2. **`xcodebuild` existence check** — `xcodebuild` binary exists in PATH but fails with: `"tool 'xcodebuild' requires Xcode, but active developer directory is a command line tools instance"`
3. **`xcodebuild -version` parse** — requires Xcode version >= 26.0

However, the actual compilation (lines 74-81) only uses:
```python
subprocess.run(["swift", "build", "-c", swift_build_config], ...)
```

This is a pure Swift Package Manager build — it does not invoke `xcodebuild` at all. The Swift toolchain from Command Line Tools is sufficient.

## Workaround

Removing the Xcode checks from `build_backend.py` (lines 71-131 in the original) allows the build to succeed:

```python
# Replace the xcode-select + xcodebuild checks with just:
# (swift is already checked above)
```

After this change, `pip install -e .` completes successfully and the SDK works correctly (text generation, streaming, guided generation, tool calling all verified).

## Suggested Fix

Either:
- **Remove the Xcode.app requirement entirely**, since `swift build` doesn't need it
- **Make it a warning instead of an error**, so users with Command Line Tools can still proceed
- **Check for Swift SDK availability directly** (e.g., `swift sdk list` or check for the macOS SDK) rather than using Xcode.app as a proxy

The macOS version check and `swift` executable check should remain — those are genuine requirements.

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Piste de recherche

Commencez dans build_backend.py, en particulier avec _build_c_bindings() et les vérifications de Xcode décrites autour des lignes 71-131 ; comparez-les avec l’invocation de swift build autour des lignes 74-81. Vérifiez le build en utilisant uniquement Command Line Tools avec pip install et pip install -e ., et confirmez que les exigences macOS et Swift échouent toujours comme prévu tandis que le build pris en charge réussit.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python, swift
Domaine
build-system
Type d'issue
Bug
Difficulté
2/5
Temps estimé
1-3 heures
Activité
Calme
Clarté
Clairement spécifiée
Accessibilité débutants
72/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.