out parameter repoter "Use of unassigned local variable 'vrmb62'" when build xcode project, but fine in editor. here is test code: Code (CSharp): public string SourcrFile = @"R:\M99o6kLkDRA0_a4U8nF_HngQnk8-eDKJzLL5OlMk1VQ.vrm"; void Start() { Debug.Assert(GenerateSHA256(SourcrFile, out byte[] vrmb64, out string vrmb62));//Error on iOS build, good on Editor //bool succeed = GenerateSHA256(SourcrFile, out byte[] vrmb64, out string vrmb62);//good on iOS build, good on Editor //Debug.Assert(succeed); Debug.Log(vrmb62); } public static bool GenerateSHA256(string filePath, out byte[] b64, out string b62) { if (!File.Exists(filePath)) { Debug.LogError("GenerateSHA256:File doesn't exist"); b64 = null; b62 = null; return false; } using (SHA256Managed sha256 = new SHA256Managed()) { using (FileStream fileStream = File.OpenRead(filePath)) { b64 = sha256.ComputeHash(fileStream); b62 = UrlBase64.Encode(b64); return true; } } } public enum PaddingPolicy { Discard, Preserve, } public static class UrlBase64 { private static readonly char[] TwoPads = { '=', '=' }; public static string Encode(byte[] bytes, PaddingPolicy padding = PaddingPolicy.Discard) { var encoded = Convert.ToBase64String(bytes).Replace('+', '-').Replace('/', '_'); if (padding == PaddingPolicy.Discard) { encoded = encoded.TrimEnd('='); } return encoded; } public static byte[] Decode(string encoded) { var chars = new List<char>(encoded.ToCharArray()); for (int i = 0; i < chars.Count; ++i) { if (chars[i] == '_') { chars[i] = '/'; } else if (chars[i] == '-') { chars[i] = '+'; } } switch (encoded.Length % 4) { case 2: chars.AddRange(TwoPads); break; case 3: chars.Add('='); break; } var array = chars.ToArray(); return Convert.FromBase64CharArray(array, 0, array.Length); } }
This seemed to be the correct behavior. Assertions(Debug.Assert) will be removed during compilation if you build in Release mode (which is the default mode when exporting). Because of the removal, the only line remaining in that function would be the Debug.Log, and thus your function is now exiting the scope without fully assigning the out parameter, and thus the error. The correct way to do the assertion in your case is the commented out lines.