gpt4 book ai didi

c# - 统一云构建 : post export method

转载 作者:可可西里 更新时间:2023-11-01 06:17:10 25 4
gpt4 key购买 nike

问题:

我似乎无法找出 Unity 云构建的后期导出方法的正确签名。根据文档:

The fully-qualified name of a public static method you want us to call after we finish the Unity build process (but before Xcode). For example: ClassName.CoolMethod or NameSpace.ClassName.CoolMethod. No trailing parenthesis, and it can't have the same name as your Pre-Export method! This method must accept a string parameter, which will receive the path to the exported Unity player (or Xcode project in the case of iOS).

这是我的代码:

 public static void OnPostprocessDevBuildIOS(string ExportPath)
{
var projPath = ExportPath + "/Unity-iPhone.xcodeproj/project.pbxproj";

var proj = new PBXProject();
var nativeTarget =
proj.TargetGuidByName(PBXProject.GetUnityTargetName());
var testTarget =
proj.TargetGuidByName(PBXProject.GetUnityTestTargetName());
string[] buildTargets = {nativeTarget, testTarget};

proj.ReadFromString(File.ReadAllText(projPath));
proj.SetBuildProperty(buildTargets, "ENABLE_BITCODE", "NO");
File.WriteAllText(projPath, proj.WriteToString());
}

这里是错误:

enter image description here

我已经尝试了多种测试方法签名,但似乎无法正常工作。我什至只尝试了一种注销路径的方法。

附加信息:

  • Unity 版本:5.3.1f
  • Unity 云构建:5.3.1f
  • 目标:iOS 8.0+

此外,我的云build设置脚本根据需要位于编辑器文件夹中。

enter image description here

好的,所以我得到了 bitCode 禁用后处理以使用以下代码,但仅当我手动构建时。当我从云构建构建时,应用程序没有错误地卡住在初始屏幕上。当我从我的本地机器构建时,应用程序运行得很好。

[PostProcessBuild]
public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
{
if (buildTarget == BuildTarget.iOS)
{
string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";
PBXProject proj = new PBXProject();
proj.ReadFromString(File.ReadAllText(projPath));

string nativeTarget = proj.TargetGuidByName(PBXProject.GetUnityTargetName());
string testTarget = proj.TargetGuidByName(PBXProject.GetUnityTestTargetName());
string[] buildTargets = new string[]{nativeTarget, testTarget};

proj.SetBuildProperty(buildTargets, "ENABLE_BITCODE", "NO");
File.WriteAllText(projPath, proj.WriteToString());
}
}

最佳答案

启动后我也遇到了同样的问题“启动画面卡住”....我解决了这个问题。请使用以下代码。在 Unity 5.4.1p2 和 Xcode 7.3 中测试。

using UnityEngine;
using System.Collections;
using UnityEditor;
using System.IO;
using UnityEditor.Callbacks;
#if UNITY_IOS
using UnityEditor.iOS.Xcode;
#endif

public class Postprocessor : AssetPostprocessor
{
#if UNITY_IOS
[PostProcessBuild]
public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
{
if (buildTarget == BuildTarget.iOS)
{
string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj";

PBXProject proj = new PBXProject();
proj.ReadFromString(File.ReadAllText(projPath));

string target = proj.TargetGuidByName("Unity-iPhone");

proj.SetBuildProperty(target, "ENABLE_BITCODE", "false");

File.WriteAllText(projPath, proj.WriteToString());



// Add url schema to plist file
string plistPath = path + "/Info.plist";
PlistDocument plist = new PlistDocument();
plist.ReadFromString(File.ReadAllText(plistPath));

// Get root
PlistElementDict rootDict = plist.root;
rootDict.SetBoolean("UIRequiresFullScreen",true);
plist.WriteToFile(plistPath);
}
}
#endif
}

关于c# - 统一云构建 : post export method,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35210801/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com