# AddWatchApp(PBXProject, string, string, string, string, string)

> Creates a watch application.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor.iOS.Xcode.Extensions](/engine/6000.3/script-reference/unityeditor/ios/xcode/extensions.md)
* **Assembly:** UnityEditor.iOS.Extensions.Xcode

```csharp
public static string AddWatchApp(this PBXProject proj, string mainTargetGuid, string watchExtensionTargetGuid, string name, string bundleId, string infoPlistPath)
```

### Parameters

**** (\[PBXProject]\(/engine/6000.3/script-reference/unityeditor/ios/xcode/pbxproject)): The implicit `this` parameter for the extension method.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The GUID of the main target to link the watch extension to.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The GUID of watch extension as returned by AddWatchExtension().**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The name of the watch app. It must the same as the name of the watch extension.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The bundle ID of the watch app.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Path to the watch app Info.plist document.

### Returns

| Type                                                           | Description                 |
| -------------------------------------------------------------- | --------------------------- |
| [string](https://learn.microsoft.com/dotnet/api/system.string) | The GUID of the new target. |

### Examples

```csharp
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using UnityEditor.iOS.Xcode.Extensions;
using UnityEngine;

public class SetupWatchExtension
{
    [PostProcessBuild]
    private static void PostProcessBuild_iOS(BuildTarget target, string buildPath)
    {
        PBXProject proj = new PBXProject();
        string projPath = PBXProject.GetPBXProjectPath(buildPath);
        proj.ReadFromFile(projPath);
        string targetGuid = proj.GetUnityFrameworkTargetGuid();
        string watchExtensionTargetGuid = PBXProjectExtensions.AddWatchExtension(proj, targetGuid, "watchtest Extension",
            "com.unity3d.watchtest.watchkitapp.watchkitextension",
            "watchtest Extension/Info.plist");
        string watchAppTargetGuid = PBXProjectExtensions.AddWatchApp(proj, targetGuid, watchExtensionTargetGuid,
            "watchtest", "com.unity3d.watchtest.watchkitapp", "watchtest/Info.plist");

        FileUtil.CopyFileOrDirectory("Assets/Plugins/iOSWatchAppFiles/watchtest", Path.Combine(buildPath, "watchtest"));
        FileUtil.CopyFileOrDirectory("Assets/Plugins/iOSWatchAppFiles/watchtest Extension", Path.Combine(buildPath, "watchtest Extension"));

        var filesToBuild = new List<string>
        {
            "watchtest/Interface.storyboard",
            "watchtest/Assets.xcassets",
        };

        foreach (var path in filesToBuild)
        {
            var fileGuid = proj.AddFile(path, path);
            proj.AddFileToBuild(watchAppTargetGuid, fileGuid);
        }

        filesToBuild = new List<string>
        {
            "watchtest Extension/Assets.xcassets",

            "watchtest Extension/ExtensionDelegate.h",
            "watchtest Extension/ExtensionDelegate.m",
            "watchtest Extension/InterfaceController.h",
            "watchtest Extension/InterfaceController.m",
            "watchtest Extension/NotificationController.h",
            "watchtest Extension/NotificationController.m",
        };

        foreach (var path in filesToBuild)
        {
            var fileGuid = proj.AddFile(path, path);
            proj.AddFileToBuild(watchExtensionTargetGuid, fileGuid);
        }

        var filesToAdd = new List<string>
        {
            "watchtest/Info.plist",
            "watchtest Extension/PushNotificationPayload.apns",
            "watchtest Extension/Info.plist",
        };

        foreach (var path in filesToAdd)
            proj.AddFile(path, path);

        proj.WriteToFile(projPath);
    }
}
```
