xcode-project-setup

โดย firebase

ปรับเปลี่ยนโปรเจกต์ Xcode (.pbxproj) อย่างปลอดภัยเพื่อเพิ่ม Swift Packages และเชื่อมโยงไฟล์ ใช้สกิลนี้เมื่อโปรเจกต์ iOS ต้องการติดตั้ง dependencies (เช่น…)

npx skills add https://github.com/firebase/agent-skills --skill xcode-project-setup

Xcode Project Setup

⛔️ CRITICAL RULES & ENVIRONMENT CHECKS

Before performing any Xcode setup or file manipulation, you MUST adhere to the following rules. A hefty fee will be applied if you violate them.

1. The Anti-Ruby Mandate

You are strictly forbidden from using Ruby, Rails, or any Ruby gems (including the xcodeproj gem). Under no circumstances may you write or execute Ruby scripts.

2. Modern Xcode Folder Synchronization

Modern Xcode projects support folder synchronization. When adding new source code (.swift) or resource files, simply write them to the correct directory on disk. They will be automatically included in the Xcode project. Never manually modify the .pbxproj file to add files.

3. Allowed Scripting Languages

If you absolutely must write a script to manipulate the project environment (e.g., configuring SPM packages beyond what the provided xcode_spm_setup script does), you must use Swift. Only as an absolute last resort, if Swift is completely unviable, may you use Node.js or TypeScript.

4. Toolchain Verification

Because this skill relies entirely on a native Swift script, you must verify the environment:

  • Run swift --version before proceeding.
  • If the Swift command is not found, you must stop and recommend the user install the Swift toolchain (e.g., via xcode-select --install on macOS), or ask if you can attempt to install it for them. Do not attempt to proceed without Swift.

5. Mandatory Linker Flags for Static Frameworks (Firebase)

When setting up SPM dependencies that heavily rely on internal Objective-C categories and +load methods (such as the Firebase iOS SDK suite), the Apple linker will aggressively strip these methods out if they are linked statically.

This causes fatal runtime crashes (e.g., FirebaseAuth/Auth.swift:167: Fatal error: Unexpectedly found nil).

The provided xcode_spm_setup Swift script automatically injects the -ObjC flag to OTHER_LDFLAGS when adding Firebase products. However, you should still verify it is present in the build settings if you encounter issues.

  • Failing to include this flag when adding Firebase dependencies is a critical error.

Empty Directory Workflow

If you are asked to build an iOS app or configure Xcode dependencies but no .xcodeproj or .xcworkspace exists, you MUST ask the user to create the project first:

"No Xcode project found in this directory. Please create an empty Xcode project manually and let me know when you are ready to proceed."

Wait for the user to confirm they have created the .xcodeproj via Xcode, then proceed with the Standard Xcode Workflow below.


Standard Xcode Workflow

Do not use raw text parsing, sed, or Ruby scripts to modify .pbxproj files directly.

Instead, execute the Swift configuration package bundled with this skill (scripts/xcode_spm_setup) to securely install SPM packages and link optional config files (like GoogleService-Info.plist).

CRITICAL: Always Use Latest SDK Version

To ensure access to the latest features and security fixes, always use the most recent version of the Firebase iOS SDK. Check for the latest release version at https://github.com/firebase/firebase-ios-sdk/releases.

  • Use the most recent version number (e.g., 11.x.y) in your commands instead of hardcoded placeholders.

Understanding the Script's Actions

When adding a Swift Package to an Xcode project, two distinct steps must occur:

  1. Adding the package repository dependency (e.g., https://github.com/Alamofire/Alamofire).
  2. Selecting the target (e.g., MyApp), navigating to General > Frameworks, Libraries, and Embedded Content, and hitting the + button to explicitly link the specific product modules (e.g., Alamofire).

The provided xcode_spm_setup Swift script automatically handles BOTH of these steps for you. By passing the list of modules as arguments, it safely injects the package dependency and automatically wires those modules to the main target's Frameworks build phase. You do not need to do any manual linking.

Usage

  1. Locate the package path: Find the absolute path to this skill's scripts/xcode_spm_setup directory on disk.
  2. Execute: Run the native swift run command using the signature below:
swift run --package-path <PATH_TO_SKILL>/scripts/xcode_spm_setup xcode_spm_setup <ProjectPath.xcodeproj> <RepoURL> <VersionRequirement> [--plist <Optional/Path/To/Config.plist>] <Product1> [Product2 ...]

Example 1: Generic Package (e.g., Alamofire)

Adding Alamofire to a standard Xcode project. Notice there is no --plist flag.

swift run --package-path /Users/foo/.agents/skills/xcode-project-setup/scripts/xcode_spm_setup xcode_spm_setup MyApp.xcodeproj https://github.com/Alamofire/Alamofire 5.8.1 Alamofire

Example 2: Firebase (Requires Plist)

Adding Firebase and linking the GoogleService-Info.plist to the resources build phase automatically. Note: Replace 11.0.0 with the actual latest version from the releases page.

swift run --package-path /Users/foo/.agents/skills/xcode-project-setup/scripts/xcode_spm_setup xcode_spm_setup MyApp.xcodeproj https://github.com/firebase/firebase-ios-sdk 11.0.0 --plist MyApp/GoogleService-Info.plist FirebaseCore FirebaseAuth FirebaseFirestore

Note: The script is idempotent. It will automatically skip linking files or packages that are already present in the project.

Skills เพิ่มเติมจาก firebase

firebase-remote-config-basics
firebase
คู่มือที่ครอบคลุมสำหรับ Firebase Remote Config รวมถึงการจัดการเทมเพลตและการใช้งาน SDK ใช้ทักษะนี้เมื่อผู้ใช้ต้องการความช่วยเหลือในการตั้งค่า Remote Config จัดการฟีเจอร์แฟล็ก หรืออัปเดตพฤติกรรมของแอปแบบไดนามิก
officialdevelopmentapi
developing-genkit-dart
firebase
Unified AI SDK สำหรับ Dart ที่รองรับการสร้างโค้ด, ผลลัพธ์ที่มีโครงสร้าง, เครื่องมือ, โฟลว์, และเอเจนต์ ให้ API หลักสำหรับการสร้าง, การกำหนดเครื่องมือ, การจัดระเบียบโฟลว์, การฝังข้อมูล, และการสตรีมด้วยอินเทอร์เฟซเดียว รวมถึงปลั๊กอิน 8+ ตัวสำหรับผู้ให้บริการ LLM (Google Gemini, Anthropic Claude, OpenAI GPT), Firebase AI, Model Context Protocol, การรวมเบราว์เซอร์ Chrome, และการโฮสต์เซิร์ฟเวอร์ HTTP ผ่าน Shelf มี CLI ในตัวพร้อม UI สำหรับการพัฒนาในเครื่องสำหรับการดำเนินการโฟลว์, การติดตาม, การทดลองโมเดล, และ...
official
developing-genkit-go
firebase
พัฒนาแอปพลิเคชันที่ขับเคลื่อนด้วย AI โดยใช้ Genkit ใน Go ใช้เมื่อผู้ใช้ขอให้สร้างฟีเจอร์ AI, เอเจนต์, โฟลว์ หรือเครื่องมือใน Go โดยใช้ Genkit หรือเมื่อทำงาน...
official
developing-genkit-js
firebase
สร้างแอปพลิเคชัน Node.js/TypeScript ที่ขับเคลื่อนด้วย AI ด้วย Genkit flows, tools และการรองรับหลายโมเดล Genkit ไม่ยึดติดกับผู้ให้บริการ รองรับ Google AI, OpenAI, Anthropic, Ollama และผู้ให้บริการ LLM อื่นๆ ผ่านปลั๊กอิน กำหนด flows ด้วยสคีมาที่ปลอดภัยชนิดข้อมูลโดยใช้ Zod ดำเนินการสร้างคำขอ และประกอบเวิร์กโฟลว์ AI แบบหลายขั้นตอนใน TypeScript ต้องใช้ Genkit CLI v1.29.0+ การเปลี่ยนแปลง API หลักเมื่อเร็วๆ นี้หมายความว่าคุณต้องปรึกษา genkit docs:read และ common-errors.md สำหรับรูปแบบปัจจุบัน ไม่ใช่ความรู้เดิม...
official
developing-genkit-python
firebase
พัฒนาแอปพลิเคชันที่ขับเคลื่อนด้วย AI โดยใช้ Genkit ใน Python ใช้เมื่อผู้ใช้ถามเกี่ยวกับ Genkit, เอเจนต์ AI, โฟลว์ หรือเครื่องมือใน Python หรือเมื่อพบ Genkit…
official
firebase-ai-logic
firebase
การผสานรวม Gemini ฝั่งไคลเอ็นต์สำหรับเว็บแอปพลิเคชัน รองรับการอนุมานแบบหลายรูปแบบ การสตรีม และการทำงานแบบไฮบริดบนอุปกรณ์ รองรับอินพุตแบบข้อความเท่านั้นและแบบหลายรูปแบบ (รูปภาพ เสียง วิดีโอ PDF) ไฟล์ที่เกิน 20 MB จะถูกส่งผ่าน Cloud Storage รวมถึงเซสชันแชทที่มีประวัติอัตโนมัติ การตอบสนองแบบสตรีมสำหรับการแสดงผลแบบเรียลไทม์ และการบังคับใช้เอาต์พุต JSON ที่มีโครงสร้าง รองรับการอนุมานแบบไฮบริดบนอุปกรณ์ผ่าน Gemini Nano ใน Chrome โดยจะเปลี่ยนไปใช้การทำงานบนคลาวด์โดยอัตโนมัติ ต้องใช้ App Check สำหรับการใช้งานจริง...
official
firebase-ai-logic-basics
firebase
ทักษะอย่างเป็นทางการสำหรับการรวม Firebase AI Logic (Gemini API) เข้ากับเว็บแอปพลิเคชัน ครอบคลุมการตั้งค่า การอนุมานแบบหลายรูปแบบ ผลลัพธ์ที่มีโครงสร้าง และความปลอดภัย
official
firebase-app-hosting-basics
firebase
ปรับใช้และจัดการเว็บแอปแบบฟูลสแต็กด้วย Firebase App Hosting โดยใช้ Next.js, Angular และเฟรมเวิร์กอื่นๆ ที่รองรับ ต้องมีโปรเจกต์ Firebase ในแผนราคา Blaze รองรับการทำงาน Server-Side Rendering (SSR) และ Incremental Static Regeneration (ISR) ปรับใช้ผ่านการกำหนดค่า firebase.json พร้อม apphosting.yaml สำหรับตั้งค่าแบ็กเอนด์ หรือเปิดใช้งาน "git push to deploy" อัตโนมัติผ่าน GitHub รวมถึงการจัดการความลับผ่านคำสั่ง CLI เพื่อการเข้าถึงคีย์ที่ละเอียดอ่อนอย่างปลอดภัย...
official