juicycleff / flutter-unity-view-widget

Embeddable unity game engine view for Flutter. Advance demo here https://github.com/juicycleff/flutter-unity-arkit-demo
BSD 3-Clause "New" or "Revised" License
2.13k stars 518 forks source link

Swift Compiler Error (Xcode): No such module 'UnityFramework' #833

Open ChurikiTenna opened 1 year ago

ChurikiTenna commented 1 year ago

Describe the bug Swift Compiler Error (Xcode): No such module 'UnityFramework' on flutter run. Also tried running from Xcode which didn't work.

To Reproduce Follow steps on here: https://pub.dev/packages/flutter_unity_widget#steps

Expected behavior Start the app.

Unity (please complete the following information):

Smartphone (please complete the following information):

Additional context I see UnityLibrary and UnityLibrary_BurstDebugInformation_DoNotShip created in flutter_project/ios/

What I tried:

Run UnityFramework scheme from Xcode

ebonovic2 commented 1 year ago

Seeing the same issue... and there is absolutely nothing I can figure out to get this fixed.

timbotimbo commented 1 year ago

Which Xcode and Unity versions did you use? (2022.2.0 looks like the plugin version)

VladyslavBilomeria commented 1 year ago

Try rechecking the flavors setting for "Unity-iPhone", it looks like they are reset to default on every export. In my case, the issue was caused by this.

hjoseph96 commented 3 months ago

Having this issue:

Screenshot 2024-06-08 at 5 11 16 PM

Unity 2022.3.31f Latest Plugin version

My xcode:

Screenshot 2024-06-08 at 5 13 22 PM

Same deal when using physical iPhone image

SilverCoder commented 3 months ago

I encountered this issue due to different build flavors. To address it, I wrote a small Node.js script that automatically patches the Unity-iPhone pbxproj file. Simply update the flavor names in the script and run it after exporting your Xcode project.

// patch-unity-pbxproj.js
const xcode = require("xcode");
const fs = require("fs");

const projectPath = process.env.UNITY_PROJECT_PATH ?? "app/ios/UnityLibrary/Unity-iPhone.xcodeproj/project.pbxproj";
const project = xcode.project(projectPath);
project.parse((err) => {
    if (err) {
        console.error(err);
        return;
    }

    const buildConfigurationSection = project.pbxXCBuildConfigurationSection();
    const configurationList = project.pbxXCConfigurationList();

    const configurations = Object.keys(configurationList).map((key) => {
        if (key.endsWith("_comment")) return undefined;
        return configurationList[key];
    }).filter(config => config !== undefined);

    const modes = ["Debug", "Release"];
    const flavors = ["development", "next", "production"];

    for (const configuration of configurations) {
        const buildConfigurations = configuration.buildConfigurations;

        for (const mode of modes) {
            for (const flavor of flavors) {
                const baseConfigurationId = buildConfigurations.find(entry => entry.comment === mode).value;
                const name = `${mode}-${flavor}`;

                if (buildConfigurations.find(entry => entry.comment === name) === undefined) {
                    console.log("Copy configuration", baseConfigurationId, name);
                    const buildConfiguration = buildConfigurationSection[baseConfigurationId];

                    const clonedBuildConfigurationId = project.generateUuid();
                    const clonedBuildConfiguration = { ...buildConfiguration, name };

                    buildConfigurationSection[`${clonedBuildConfigurationId}_comment`] = clonedBuildConfiguration.name;
                    buildConfigurationSection[clonedBuildConfigurationId] = clonedBuildConfiguration;
                    buildConfigurations.push({ value: clonedBuildConfigurationId, comment: name });
                }
            }
        }
    }

    fs.writeFileSync(projectPath, project.writeSync());
});