> For the complete documentation index, see [llms.txt](https://docs.roboflow.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.roboflow.com/roboflow/roboflow-hi/deploy/sdks/ios-sdk.md).

# iOS SDK

Roboflow Mobile iOS SDK एक बेहतरीन विकल्प है यदि आप ऐसा iOS application विकसित कर रहे हैं जहाँ edge (iPad या iPhone) पर model का चलना तेज़ inference के लिए या features, capabilities, और use cases के एक नए suite को unlock करने के लिए आवश्यक हो (जैसे augmented reality)।

इनमें embedded custom computer vision models वाले native mobile applications developers को अपने apps को देखने की क्षमता देने में सक्षम बनाते हैं।

## Task Support

Hosted API द्वारा निम्नलिखित task प्रकार समर्थित हैं:

| Task Type             | iOS SDK Deployment द्वारा समर्थित |
| --------------------- | --------------------------------- |
| Object Detection      | ✅                                 |
| Classification        |                                   |
| Instance Segmentation | ✅ (iOS 18 या उससे उच्चतर)         |
| Semantic Segmentation |                                   |

### CoreML Export संगतता

निम्नलिखित model architectures CoreML (`.mlpackage`) export को on-device deployment के लिए support करती हैं:

| Model                 | CoreML Export |
| --------------------- | ------------- |
| RF-DETR               | ✅             |
| YoloLite              | ✅             |
| Classification models | ✅             |

## किसी Model को iOS Device पर Deploy करें

### समर्थित हार्डवेयर और सॉफ़्टवेयर

सभी iOS devices on-device inference का समर्थन करते हैं, लेकिन iPhone 8 (A11 Bionic Processor) से पुराने devices कम energy-efficient gpu engine पर fall back करेंगे।

Roboflow को न्यूनतम iOS version 15.4 (instance segmentation models के लिए 18.0) की आवश्यकता है।

## Prototyping

आप इसके साथ develop कर सकते हैं [Roboflow Serverless Hosted API](https://docs.roboflow.com/deploy/serverless)। यह on-device inference के समान प्रशिक्षित models का उपयोग करता है।

## Installation

* Install [CocoaPods](https://guides.cocoapods.org/using/getting-started.html) | [Troubleshooting Guide](https://guides.cocoapods.org/using/troubleshooting#installing-cocoapods)

"CocoaPods Ruby के साथ built है और यह macOS पर उपलब्ध default Ruby के साथ install किया जा सकता है। आप Ruby Version manager का उपयोग कर सकते हैं, हालांकि हम अनुशंसा करते हैं कि आप macOS पर उपलब्ध standard Ruby का उपयोग करें, जब तक कि आपको पता न हो कि आप क्या कर रहे हैं। Default Ruby install का उपयोग करने पर gems install करते समय आपको sudo का उपयोग करना होगा। (हालाँकि यह केवल gem installation की अवधि के लिए ही एक issue है.)" - `sudo` का उपयोग करते समय। (हालाँकि यह केवल gem installation की अवधि के लिए ही एक issue है.)" - [CocoaPods](https://guides.cocoapods.org/using/getting-started.html)

"Sudo-less" installation एक विकल्प है, यदि आप इस प्रक्रिया के लिए RubyGems admin privileges नहीं देना चाहते। हालांकि, ध्यान दें कि `sudo` installation अधिक सामान्य है।

यह जाँचें कि CocoaPods सफलतापूर्वक installed है, इसके लिए दर्ज करें `pod --version` अपने Terminal में।

### Roboflow CocoaPod को Install करना

सबसे पहले, चलाएँ `pod init` अपने project directory में।

सुनिश्चित करें कि `Podfile` में निर्दिष्ट है `platform :ios, '15.4'`

फिर, जोड़ें `pod 'Roboflow'` अपने `Podfile`.

यदि आपके पास XCode Command Line Tools installed नहीं हैं, तो चलाएँ `xcode-select --install` अपने Terminal में।

यह आउटपुट देगा: `xcode-select: error: command line tools पहले से installed हैं, updates install करने के लिए "Software Update" का उपयोग करें` यदि Command Line Tools पहले से आपके system पर मौजूद हैं।

अंत में, चलाएँ `pod install` और generated `.xcworkspace` file को [XCode](https://developer.apple.com/xcode/).

![Podfile की सफल installation के बाद Terminal](/files/94c165ccd861d6183591a51d792c2f07826779ba)

![Podfile की सफल installation के बाद project directory](/files/235f29fa3d79dc0d89359ec138ba56ff1b37d269)

* यदि यह यह error लौटाता है: "आपको Ruby interpreter या extension libraries में bug का सामना करना पड़ा हो सकता है," तो पहले चलाएँ `brew install cocoapods`और फिर चलाएँ `pod install` और generated `.xcworkspace` XCode में file.
  * यह जाँचें कि CocoaPods सफलतापूर्वक installed है, इसके लिए दर्ज करें `pod --version` अपने Terminal में।

### Swift में Roboflow का उपयोग

पर जाएँ `.xcworkspace` XCode में file.

![](/files/9fc9d3a8efd2281597d8dee2d184eebaddf8daad)

इसके बाद, जोड़कर Roboflow import करें `import Roboflow`. को `.xcworkspace` file.

फिर, निम्न के साथ Roboflow API का एक instance बनाएँ `let rf = Roboflow(apiKey: "API_KEY")`. For `modelVersion`, बदलें `YOUR-MODEL-VERSION-#` को आपके model के version number के integer value से।

#### अपने Project Information का पता लगाना

**Completion Handler का उपयोग:**

```swift
import Roboflow
...
// अपने API Key के साथ initialize करें
let rf = RoboflowMobile(apiKey: "API_KEY")
var model: RFModel?
...

//model आपके model का project name है
rf.load(model: "YOUR-MODEL-ID", modelVersion: YOUR-MODEL-VERSION-#) { [self] model, error, modelName, modelType in
    if error != nil {
        print(error?.localizedDescription as Any)
    } else {
        model?.configure(threshold: threshold, overlap: overlap, maxObjects: maxObjects
                            processingMode: .performance or .balanced or .quality, // instance seg
                            maxNumberPoints: mask processing points की अधिकतम संख्या) // instance seg
        self.model = model
    }
    
}
...

//model?.detect एक UIImage लेता है और उस पर inference चलाता है
let img = UIImage(named: "example.jpeg") // या CVPixelBuffer
model?.detect(image: img!) { predictions, error in
    if error != nil {
        print(error)
    } else {
        print(predictions)
    }
}
```

**Asynchronous Usage:**

Asynchronously उपयोग करने के लिए, आपको अपने Roboflow model को एक asynchronous block के भीतर invoke करना होगा।

```swift
import Roboflow
...
// अपने API Key के साथ initialize करें
let rf = RoboflowMobile(apiKey: "API_KEY")
...

//model आपके model का project name है
let (model, loadingError, modelName, modelType) = await rf.load(model: "YOUR-MODEL-ID", modelVersion: YOUR-MODEL-VERSION-#)
model!.configure(threshold: threshold, overlap: overlap, maxObjects: maxObjects)
...

//model?.detect एक UIImage लेता है और उस पर inference चलाता है
let img = UIImage(named: "example.jpeg")
let (predictions, predictionError) = await model!.detect(image: img!)
print(predictions)
```

**Predictions Format:**

```
x:Float // वस्तु का x केंद्र
y:Float // वस्तु का y केंद्र
width:Float
height:Float
className:String
confidence:Float
color:UIColor
box:CGRect
points:[CGPoint] // केवल instance segmentation models के लिए
```

[CGRect](https://developer.apple.com/documentation/corefoundation/cgrect)

### Native Swift Example

यह [roboflow-ios-starter](https://github.com/roboflow/roboflow-ios-starter) app roboflow models के साथ एक realtime iOS app बनाने के लिए एक शानदार शुरुआती बिंदु है। इसमें camera setup, model loading और processing, तथा object-detection और instance segmentation models दोनों के लिए output drawing code शामिल है।

### React Native Expo App Example

हम यहाँ React Native के साथ इस SDK को एक expo app में integrate करने का एक example भी प्रदान करते हैं। अपनी downstream application बनाने पर विचार करते समय आपको यह उपयोगी लग सकता है।

सुनिश्चित करें कि आपके पास दोनों हों [Expo](https://docs.expo.dev/) और [CocoaPods](https://guides.cocoapods.org/using/getting-started.html) installed.

* `expo-cli` निम्नलिखित Node.js versions का समर्थन करता है: `>=12.13.0 <15.0.0` (Maintenance LTS) और `>=16.0.0 <17.0.0` (Active LTS)
* Node.js के लिए yarn package installed होना चाहिए (`npm install -g yarn`)

{% embed url="<https://github.com/roboflow-ai/RoboflowExpoExample>" %}

### उदाहरण iOS application - CashCounter

Download [CashCounter](https://apps.apple.com/app/roboflow-cash-counter/id1633812788)हमारा उदाहरण iOS app जो US coins और bills गिनता है, इस उदाहरण के रूप में कि आप किसी computer vision model को iPhone पर कैसे deploy कर सकते हैं। आपको bounding boxes, FPS, object counting, image upload, और अधिक को visualise करने के examples देखने को मिलेंगे।


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.roboflow.com/roboflow/roboflow-hi/deploy/sdks/ios-sdk.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
