# airbuild-xcode

> شغّل xcodebuild install أو archive أو test داخل سكربت بناء AirBuild، مع إعدادات AirBuild الافتراضية للتهيئة والوجهة والتوقيع وذاكرات التخزين المؤقت.

Source: https://air.build/ar/docs/cli/airbuild-xcode/

يستدعي `airbuild-xcode` الأمر `xcodebuild` مرة واحدة، بإجراء واحد، ويضيف إعدادات AirBuild الافتراضية لكل ما لم تمرّره. لا يوجد إلا داخل السكربتات التي يشغّلها `runbuild` و`runtest` و`runmacos` (بما فيها السكربتات التي تستدعيها)، على جهاز بناء سحابي بنظام macOS أو على جهاز Mac الخاص بفريق Mac. لا يُثبَّت في أي مكان آخر، ولا يوجد على أجهزة بناء Linux.

استخدمه بدلًا من `xcodebuild` لـ `install` و`archive` و`test` و`-showBuildSettings`. ولأي عملية Xcode أخرى، استدعِ `xcodebuild` مباشرة.

## الصيغة

```bash
airbuild-xcode install|archive|test|-showBuildSettings [xcodebuild options and build settings]
airbuild-xcode --help
```

يجب أن يأتي الإجراء أولًا. كل وسيط آخر يُمرَّر إلى `xcodebuild` دون تغيير، ويخرج `airbuild-xcode` برمز خروج `xcodebuild`.

## الإجراءات

| الإجراء | الغرض منه | التخزين المؤقت |
| --- | --- | --- |
| `install` | البناء اليومي: يبني `xcodebuild install` أهداف Archive في المخطط داخل `DSTROOT`، تزايديًا. ضعه في `build.script`. | في البناء السحابي، أول `install` في التشغيل يعيد مجلد DerivedData الخاص بالمشروع. |
| `archive` | الأرشيف الذي يُصنع منه ملف `.ipa` موقَّع أو حزمة أجهزة غير موقَّعة. ضعه في `release.script`. | لا شيء: الأرشفة تبدأ من الصفر في كل تشغيل. |
| `test` | تشغيل الاختبارات. | في البناء السحابي، أول `test` في التشغيل يعيد مجلد DerivedData الخاص بالمشروع (نسخة منفصلة عن نسخة `install`). |
| `-showBuildSettings` | طباعة إعدادات البناء بالقيم الافتراضية نفسها التي يحصل عليها البناء. | — |

ترفض عمليات البناء الموقَّعة وبناء الأجهزة `install`: فهي تصدّر أرشيفًا، ولذا تشغّل وصفة `release:`.

## القيم الافتراضية

يتبع `install` و`archive` و`-showBuildSettings` قيمة `AIRBUILD_SIGN` (الافتراضية `0`)، التي يضبطها `runbuild`:

| البناء | التهيئة | الوجهة | التوقيع |
| --- | --- | --- | --- |
| عادي (`AIRBUILD_SIGN=0`) | `Debug` | `generic/platform=iOS Simulator` | `CODE_SIGN_IDENTITY=-`؛ وتُحفظ إعدادات التوقيع الأخرى في المشروع |
| حزمة أجهزة (`AIRBUILD_SIGN=0`، `AIRBUILD_DEVICE=1`): `runbuild --unsigned` أو **Install on Device** دون توقيع مُدار | `Release` | `generic/platform=iOS` | توقيع ad-hoc باستحقاقات المشروع، دون فريق أو ملف تعريف. تُحذف قيم `-destination` و`-sdk` الخاصة بالمحاكي. |
| موقَّع (`AIRBUILD_SIGN=1`): `runbuild --sign` | `Release` | `generic/platform=iOS` | توقيع مُدار يجهّزه AirBuild |

يستخدم `test` افتراضيًا محاكي iPhone على أحدث بيئة تشغيل iOS فيها iPhone عادي (غير قابل للطي)، ويفضّل محاكيًا مُشغَّلًا مسبقًا، مع `CODE_SIGN_IDENTITY=-` و`-collect-test-diagnostics never`. لا ينشئ محاكيات.

## ما يمكنك تجاوزه

- تحلّ القيم الصريحة لـ `-configuration` و`-destination` (أكثر من واحدة للاختبارات)، ولعمليات البناء العادية والاختبارات `CODE_SIGN_IDENTITY=…`، محلّ القيم الافتراضية.
- يعيد `-collect-test-diagnostics on-failure` تفعيل تشخيصات المحاكي لـ `test`.
- تتغلب `ARCHS` و`COMPILATION_CACHE_*` و`SWIFT_ENABLE_PREFIX_MAPPING` و`CLANG_ENABLE_PREFIX_MAPPING` في سطر الأوامر على إعدادات المنصة في جهاز البناء. على جهاز البناء، تكون عمليات بناء المحاكي وmacOS بمعمارية arm64 فقط ما لم تمرّر `ARCHS`.
- يتجاوز التوقيع المُدار إعدادات التوقيع في المشروع وفي `-xcconfig` وفي سطر الأوامر: `CODE_SIGNING_ALLOWED` و`CODE_SIGNING_REQUIRED` و`CODE_SIGN_IDENTITY` و`CODE_SIGN_STYLE` و`DEVELOPMENT_TEAM` و`PROVISIONING_PROFILE` و`PROVISIONING_PROFILE_SPECIFIER` و`OTHER_CODE_SIGN_FLAGS`. أما `CODE_SIGN_ENTITLEMENTS` فيُحتفظ به.

## أرقام الإصدار

الأرشيف الخاص بالأجهزة أو بالتوقيع المُدار الذي بدأه شخص من تطبيق AirBuild يُرفع إلى الحد الأدنى لإصدار المشروع: لا تُتجاوز `MARKETING_VERSION` و`CURRENT_PROJECT_VERSION` إلا حيث يذكر المصدر قيمة أقل. أما البناء الذي يبدؤه وكيل فلا يُرفع أبدًا: اضبط رقم البناء في المشروع بنفسك.

## المخرجات

قبل أن يشغّل `xcodebuild`، يطبع `airbuild-xcode` ما اختاره على الخطأ القياسي (stderr):

```text
[airbuild-xcode] sign=0; configuration=Debug (default); destination=generic/platform=iOS\ Simulator (default).
[airbuild-xcode] CODE_SIGN_IDENTITY=default (-); project signing settings are preserved.
```

```text
[airbuild-xcode] default test device: iPhone 17 (iOS 26.1).
airbuild-xcode: skipping simulator diagnostics collection (simctl diagnose waits 600 s on Xcode 27); pass -collect-test-diagnostics on-failure to collect them.
[airbuild-xcode] action=test; destination=id=<UDID> (default); CODE_SIGN_IDENTITY=default (-).
```

أسطر أخرى قد تراها:

| السطر | المعنى |
| --- | --- |
| `[airbuild-xcode] archive starts over every run and keeps no cache; …` | بناء عادي يُجري أرشفة. استخدم `install` في `build:` وأبقِ `archive` في `release:` لعمليات بناء تزايدية. يكرر `runbuild` هذا كتحذير بجانب نتيجته. |
| `[airbuild-xcode] device build: dropped -destination …` | أُزيلت وجهة محاكي أو SDK من بناء أجهزة. |
| `[airbuild-xcode] device build: ad-hoc signed, no team or profile; CODE_SIGN_ENTITLEMENTS is preserved.` | بناء حزمة أجهزة. |
| `[airbuild-xcode] Managed signing overrides via XCODE_XCCONFIG_FILE: …` | بناء موقَّع. |
| `[airbuild-xcode] command-line ARCHS=… kept over the platform build settings.` | تغلّب إعدادك على إعداد جهاز البناء. |
| `[airbuild-xcode] version floor: raised …` / `nothing raised.` | خطوة الحد الأدنى للإصدار في بناء بدأ من التطبيق. |

## رموز الخروج والأخطاء

يخرج `airbuild-xcode` برمز خروج `xcodebuild`. ويتوقف بالرمز `64` قبل تشغيل `xcodebuild` في الحالات التالية:

| الرسالة | ما العمل |
| --- | --- |
| `airbuild-xcode: start with install, archive, test or -showBuildSettings; use xcodebuild directly for other operations.` | ضع الإجراء أولًا، أو استدعِ `xcodebuild`. |
| `airbuild-xcode: use one leading action; run other Xcode operations separately.` | احذف `-list` و`-version` و`-show…` و`-exportArchive` و`-resolvePackageDependencies` وما شابهها؛ وشغّلها بـ `xcodebuild`. (`-showBuildTimingSummary` مسموح.) |
| `airbuild-xcode: -configuration requires a value.` (أو `-destination`) | أعطِ القيمة. |
| `airbuild-xcode: a signed or device build exports an archive; put airbuild-xcode archive in the release: recipe of airbuild.yaml …` | أضف وصفة `release:` تشغّل `airbuild-xcode archive`. |
| `airbuild-xcode: no available iOS simulator could be selected. Install an iOS simulator runtime and device in Xcode, or pass -destination explicitly.` | مرّر `-destination`، أو ثبّت بيئة تشغيل للمحاكي. |
| `airbuild-xcode: AIRBUILD_SIGN must be 0 or 1. Start managed signing through AirBuild.` | لا تضبط `AIRBUILD_SIGN` بنفسك؛ استخدم `runbuild --sign`. |
| `airbuild-xcode: signing preparation is incomplete. Start signing through AirBuild again.` | شغّل `runbuild --sign` من جديد. |

## أمثلة

```bash
# build.script: the everyday, incremental build
airbuild-xcode install -workspace App.xcworkspace -scheme App \
  DSTROOT="$PWD/.airbuild/artifacts/install"
```

```bash
# release.script: the archive for --sign and --unsigned
rm -rf .airbuild/artifacts/App.xcarchive
airbuild-xcode archive -workspace App.xcworkspace -scheme App \
  -archivePath .airbuild/artifacts/App.xcarchive
```

```bash
# A test entry, with runtest's --additional-options
airbuild-xcode test -workspace App.xcworkspace -scheme App \
  -resultBundlePath .airbuild/artifacts/Tests.xcresult $additional_options
```
