Search Unity

Release: Editor plugin to fix iOS builds for TestFlight

Discussion in 'Editor & General Support' started by kevindena, Dec 23, 2014.

  1. kevindena

    kevindena

    Joined:
    Jan 16, 2014
    Posts:
    4
    These errors have been driving me nuts! http://stackoverflow.com/questions/26497863/xcode-6-1-error-while-building-ipa-using-testflight-app

    So I created a post-processing script that does the fix for me! It's short enough that I've pasted the code below as well as attached it. Put it in Assets/Editor/FixResourceRules.cs. Warning: it's not very smart and may break in the future. I've used it on three projects so far.

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEditor;
    3. using UnityEditor.Callbacks;
    4. using System.IO;
    5. using System.Collections.Generic;
    6.  
    7. public static class FixResourceRules {
    8.  
    9.     [PostProcessBuild]
    10.     public static void OnPostprocessBuild(BuildTarget target, string pathToBuildProject) {
    11.         var pbxPath = pathToBuildProject + "/Unity-iPhone.xcodeproj/project.pbxproj";
    12.         // Debug.Log(pbxPath);
    13.  
    14.         if (!File.Exists(pbxPath)) {
    15.             Debug.LogError("Bailing, unable to open pbpxproj at path " + pbxPath);
    16.             return;
    17.         }
    18.  
    19.         var ls = File.ReadAllLines(pbxPath);
    20.         var lines = new List<string>(ls);
    21.         var output = new List<string>();
    22.         var i = 0;
    23.  
    24.         foreach (var line in lines) {
    25.             output.Add(line);
    26.  
    27.             if (line.Contains("CLANG_CXX_LIBRARY = \"libstdc++\";")) {
    28.                 Debug.Log("FixResourceRules adding CODE_SIGN_RESOURCE_RULES_PATH = \"$(SDKROOT)/ResourceRules.plist\"; after line " + i + ": " + line);
    29.                 output.Add("                 CODE_SIGN_RESOURCE_RULES_PATH = \"$(SDKROOT)/ResourceRules.plist\";");
    30.             }
    31.  
    32.             i++;
    33.         }
    34.  
    35.         File.WriteAllLines(pbxPath, output.ToArray());
    36.     }
    37. }
     

    Attached Files:

  2. shaderop

    shaderop

    Joined:
    Nov 24, 2010
    Posts:
    942
    I got bit by this issue a couple of days back and it cost me a few grey hairs to get it all sorted out. So well done on you for making your fix available to the public!