wrld3d / unity-api

Issue tracking for the WRLD Unity SDK
28 stars 8 forks source link

Troubleshooting iOS App Store Submission #45

Closed johnbell84 closed 3 years ago

johnbell84 commented 7 years ago

We've recently had some reports of problems submitting apps that use WRLD to the iOS App Store. A fix for this is coming up in our next release, but in the meantime the steps below should allow you to work around this problem and submit your app.

Background

Our SDK contains a core binary component alongside the managed C# that gets exposed in Unity. This library has been pre-compiled separately for our various platforms (OSX, iOS, Windows & Android), but it looks like Unity is detecting the presence of the OSX bundle and deciding it needs to be copied into the Xcode project it creates during an iOS build. Unfortunately, as this bundle is designed for OSX, rather than iOS, it can create problems later in the build and submission process.

Workaround

If you have a folder called "Wrld" under the Frameworks directory in Xcode's Project Navigator, deleting it and all its children (and selecting Move to Trash) should resolve the problem. At that point you should be able to archive your project again and upload it to the App Store.

Fix

For future SDK updates, we have added the code below (between “NEW CODE BEGINS” and “NEW CODE ENDS”) at around line 27 in OnPostProcessBuild in Wrld/Editor/XcodeProjectUpdater.cs. If you apply this change locally it should prevent the problem from cropping up when you next build from Unity.

[PostProcessBuild]
public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
{
    if (buildTarget == BuildTarget.iOS)
    {
        string projectPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
        PBXProject project = new PBXProject();
        project.ReadFromString(File.ReadAllText(projectPath));
        string target = project.TargetGuidByName("Unity-iPhone");
        AddFrameworks(project, target);
        AddDylibs(project, target);
        project.SetBuildProperty(target, "ENABLE_BITCODE", "false");

        // !!! NEW CODE BEGINS !!!

        // Unity will find and copy this x86_64 bundle into the project as a framework, if 
        // it is allowed, preventing it from archiving correctly.  As we're on iOS in this 
        // case we don't need it and can remove it.
        string osxBundleGuid = project.FindFileGuidByProjectPath("Frameworks/Wrld/Plugins/x86_64/StreamAlpha.bundle");

        if (osxBundleGuid != null)
        {
            project.RemoveFile(osxBundleGuid);
        }

        // !!! NEW CODE ENDS !!!

        File.WriteAllText(projectPath, project.WriteToString());
    }
}
ghost commented 3 years ago

Fixed in v0.8