# Integrate with Flutter Project

### Flutter Unity Widget

{% embed url="<https://github.com/juicycleff/flutter-unity-view-widget>" %}

This is an open-source project that helps developers to easily integrate Flutter Project with Unity. It includes simple interface to send message to Unity, receive message from Unity, and embed Unity Widget as a component of Flutter Project

### Configuration

Following steps are required to embed Unity inside your Flutter project

1. Open the *<mark style="color:purple;">`ios/Runner.xcworkspace`</mark>* (workspace, not the project) file in Xcode, right-click on the Navigator (not on an item), go to **Add Files to "Runner"** and add the *<mark style="color:purple;">`ios/UnityLibrary/Unity-Iphone.xcodeproj`</mark>* file.

<figure><img src="https://774145129-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2YWEOtruEiKmcmCTpBsb%2Fuploads%2FGaJk8zQZGGGEcGW8vnjZ%2Fimage.png?alt=media&#x26;token=841cbce7-2cd9-46af-a30c-ff3566f5ba96" alt=""><figcaption><p>Unity-iPhone added</p></figcaption></figure>

2. Open the <mark style="color:purple;">`ios/Runner/AppDelegate.swift`</mark> file and change the following:

```swift
     import UIKit
     import Flutter
+    import flutter_unity_widget

     @UIApplicationMain
     @objc class AppDelegate: FlutterAppDelegate {
         override func application(
             _ application: UIApplication,
             didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
         ) -> Bool {
+            InitUnityIntegrationWithOptions(argc: CommandLine.argc, argv: CommandLine.unsafeArgv, launchOptions)

             GeneratedPluginRegistrant.register(with: self)
             return super.application(application, didFinishLaunchingWithOptions: launchOptions)
         }
     }
```

3. Add the <mark style="color:purple;">`UnityFramework.framework`</mark> file as a library to the Runner project

<figure><img src="https://774145129-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2YWEOtruEiKmcmCTpBsb%2Fuploads%2Fk9XOtpjul8YEOmdo6rdP%2Fimage.png?alt=media&#x26;token=a3e888f4-9bad-4df6-a56d-b2ee60f6e8a1" alt=""><figcaption><p>UnityFramework.framework added</p></figcaption></figure>

Even with these configurations, there might be a problem launching the application. Please refer to the section below to resolve problems.

{% content-ref url="trouble-shooting-flutter-integration" %}
[trouble-shooting-flutter-integration](https://myty.gitbook.io/products/sdk/for-ios-application/trouble-shooting-flutter-integration)
{% endcontent-ref %}

An example of Flutter-Unity integrated MYTY Avatar project can be found in the section below.

{% content-ref url="../flutter-example" %}
[flutter-example](https://myty.gitbook.io/products/sdk/flutter-example)
{% endcontent-ref %}
