Cloud build - IPA - Asset validation failed - Invalid bundle

Hello. I have issues at releasing the app on App Store: Xcode 15.2(Experimental), Unity 2020.3.37f1
Asset validation failed Invalid Bundle.
contains disallowed file ‘Frameworks’
Upload IPA to Appstore Connect failed

I have tried adding this file also trying to disable/enable the embed swift libraries but it doesn’t seem to work:

using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;

namespace Editor
{
    public static class XcodeSwiftVersionPostProcess
    {
        [PostProcessBuild(999)]
        public static void OnPostProcessBuild(BuildTarget buildTarget, string path)
        {
            if (buildTarget == BuildTarget.iOS)
            {
                ModifyFrameworks(path);
            }
        }

        private static void ModifyFrameworks(string path)
        {
            string projPath = PBXProject.GetPBXProjectPath(path);

            var project = new PBXProject();
            project.ReadFromFile(projPath);

            string mainTargetGuid = project.GetUnityMainTargetGuid();

            foreach (var targetGuid in new[] { mainTargetGuid, project.GetUnityFrameworkTargetGuid() })
            {
                project.SetBuildProperty(targetGuid, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "NO");
            }

            project.SetBuildProperty(mainTargetGuid, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "YES");
            string target = project.GetUnityMainTargetGuid();
            project.SetBuildProperty(target, "ENABLE_BITCODE", "NO");

            //Unity Tests
            target = project.TargetGuidByName(PBXProject.GetUnityTestTargetName());
            project.SetBuildProperty(target, "ENABLE_BITCODE", "NO");

            //Unity Framework
            target = project.GetUnityFrameworkTargetGuid();
            project.SetBuildProperty(target, "ENABLE_BITCODE", "NO");

            project.WriteToFile(projPath);
        }
    }
}

I have also a post build bash
#!/bin/bash
echo “Uploading IPA to Appstore Connect…”
#Path is “/BUILD_PATH/<ORG_ID>.<PROJECT_ID>.<BUILD_TARGET_ID>/.build/last/<BUILD_TARGET_ID>/build.ipa”
path=“$WORKSPACE/.build/last/$TARGET_NAME/build.ipa”
if xcrun altool --upload-app -t ios -f $path -u $ITUNES_USERNAME -p $ITUNES_PASSWORD ; then
echo “Upload IPA to Appstore Connect finished with success”
else
echo “Upload IPA to Appstore Connect failed”
fi

Anyone has solution to this problem?
Thanks

I recommend using fastlane to do the upload rather than using custom tooling. I also highly recommend using UNITY_PLAYER_PATH environment variable over WORKSPACE. If we change the output path to something else then your scripts would break. To use fastlane you would create a custom fastlane.json and fastfile that would get called after building the .ipa. This is part of the advanced settings of your target configuration

https://docs.fastlane.tools/actions/upload_to_app_store/

example fastlane.json for uploading to test flight

{
    "fastfile": "fastlane/Fastfile",
    "lanes": {
        "post_build": "testflight_upload"
    }
}

and then the example Fastfile contents:

lane :testflight_upload do |options|
    upload_to_testflight(
        skip_submission:true,
        skip_waiting_for_build_processing:true,
        apple_id:"",
        itc_provider: ""
    )
end

Thanks for the advice. I also have a major problem, when I want to release the app it gives me this error: Asset validation failed Invalid Bundle. contains disallowed file ‘Frameworks’. In my post I have writed about the solutions I have tried but nothing works for now. Can you give me a solutions to this problem?