# V2Ray iOS Setup

### Podfile

Open ios/Podfile and set the platform to iOS 15

```
# Uncomment this line to define a global platform for your project
platform :ios, '15.0'
```

```
flutter clean
rm -rf ios/Pods ios/Podfile.lock
flutter pub get
pod install --repo-update
cd ..
```

### Xcode Setup

* Open Runner.xcworkspace with Xcode.

#### Runner target

* Set the Minimum Deployment Target to iOS 15.
* Go to the Signing & Capabilities tab.
* Add the App Group capability.
* Add the Network Extension capability and activate Packet Tunnel.

<div data-full-width="true"><figure><img src="/files/y1wZko4bI7RhYCr5axyl" alt=""><figcaption></figcaption></figure></div>

#### XrayTunnel target

* Add a Network Extension Target with the name **XrayTunnel**
* Set the Minimum Deployment Target to iOS 15.
* Add the App Group capability.
* Add the Network Extension capability and activate Packet Tunnel.

<figure><img src="/files/XikbNhwuqZu4Sn3SZBuF" alt=""><figcaption></figcaption></figure>

**Add XrayTunnel dependencies**

* Open the Runner project and go to the Package Dependencies tab.
* Add <https://github.com/blueboy-tm/Tun2SocksKit> to the XrayTunnel Target.
* Open the **General** tab of the **XrayTunnel** Target.
* Add **XRay.xcframework** to Frameworks and Libraries.
* Add **libresolv.tbd** to Frameworks and Libraries.

<figure><img src="/files/UzxPt5we0mQkZAvXD3hf" alt=""><figcaption></figcaption></figure>

* Open ios/XrayTunnel/PacketTunnelProvider.swift.
* Paste the content of [this file](https://github.com/flutter-v2ray/flutter_v2ray_mobile/blob/master/example/ios/XrayTunnel/PacketTunnelProvider.swift).
* Open the Runner Target > Build Phases tab.
* Move **Embed Foundation Extensions** to the bottom of **Copy Bundle Resources**.

<figure><img src="/files/EvLo0VTkRq608t1N41b9" alt=""><figcaption></figcaption></figure>

### flutter Code:

Pass the providerBundleIdentifier and groupIdentifier to the initializeV2Ray function:

```
await flutterV2ray.initializeV2Ray(
    providerBundleIdentifier: "IOS Provider bundle indentifier",
    groupIdentifier: "IOS Group Identifier",
);
```

<div data-full-width="true"><figure><img src="/files/6FLk0soZlqzBVt4Hf3to" alt=""><figcaption></figcaption></figure></div>


---

# Agent Instructions: 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:

```
GET https://orban-tech.gitbook.io/v2ray-vpn/app-guide/v2ray-ios-setup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
