# AddAppExtension(PBXProject, string, string, string, string)

> Creates an app extension.

## Definition

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

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

### Parameters

**** (\[PBXProject]\(/engine/6000.6/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 app to.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The name of the app extension.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The bundle ID of the app extension. The bundle ID must be prefixed with the parent app bundle ID.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Path to the app extension Info.plist document.

### Returns

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

### Examples

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

public class ScriptBatch : MonoBehaviour
{
    [PostProcessBuild]
    private static void PostProcessBuild_iOS(BuildTarget target, string buildPath)
    {

	    Directory.CreateDirectory(buildPath + "/appext");

        File.Copy("Assets/extension/TodayViewController.h", buildPath + "/appext/TodayViewController.h");
        File.Copy("Assets/extension/TodayViewController.m", buildPath + "/appext/TodayViewController.m");

        PBXProject proj = new PBXProject();
        string projPath = PBXProject.GetPBXProjectPath(buildPath);
        proj.ReadFromFile(projPath);

        string targetGuid = proj.GetUnityFrameworkTargetGuid();

        string newTarget = proj.AddAppExtension(targetGuid, "appext", "com.unity3d.product.appext", "appext/Info.plist");
        proj.AddFileToBuild(newTarget, proj.AddFile(buildPath + "/appext/TodayViewController.h", "appext/TodayViewController.h"));
        proj.AddFileToBuild(newTarget, proj.AddFile(buildPath + "/appext/TodayViewController.m", "appext/TodayViewController.m"));
        proj.AddFrameworkToProject(newTarget, "NotificationCenter.framework", true);
        proj.WriteToFile(projPath);
    }
}
```
