Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Upgraded to Unity 4.5 (PRO)cannot build iOS App anymore

Discussion in 'iOS and tvOS' started by Landci, Jun 3, 2014.

  1. Landci

    Landci

    Joined:
    Aug 28, 2012
    Posts:
    33
    i am always getting this error:


    KeyNotFoundException: The given key was not present in the dictionary.
    System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (.TKey key) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150)
    UnityEditor.XCodeEditor.PBXResolver.ResolveName (System.String guid) (at Assets/Editor/XUPorter/PBX Editor/PBXParser.cs:49)
    UnityEditor.XCodeEditor.PBXResolver.ResolveName (System.String guid) (at Assets/Editor/XUPorter/PBX Editor/PBXParser.cs:53)
    UnityEditor.XCodeEditor.PBXParser.GUIDComment (System.String guid, System.Text.StringBuilder builder) (at Assets/Editor/XUPorter/PBX Editor/PBXParser.cs:218)
    UnityEditor.XCodeEditor.PBXParser.SerializeString (System.String aString, System.Text.StringBuilder builder, Boolean useQuotes, Boolean readable) (at Assets/Editor/XUPorter/PBX Editor/PBXParser.cs:546)
    UnityEditor.XCodeEditor.PBXParser.SerializeDictionary (System.Collections.Generic.Dictionary`2 dictionary, System.Text.StringBuilder builder, Boolean readable, Int32 indent) (at Assets/Editor/XUPorter/PBX Editor/PBXParser.cs:481)
    UnityEditor.XCodeEditor.PBXParser.SerializeValue (System.Object value, System.Text.StringBuilder builder, Boolean readable, Int32 indent) (at Assets/Editor/XUPorter/PBX Editor/PBXParser.cs:439)
    UnityEditor.XCodeEditor.PBXParser.SerializeDictionary (System.Collections.Generic.Dictionary`2 dictionary, System.Text.StringBuilder builder, Boolean readable, Int32 indent) (at Assets/Editor/XUPorter/PBX Editor/PBXParser.cs:489)
    UnityEditor.XCodeEditor.PBXParser.SerializeValue (System.Object value, System.Text.StringBuilder builder, Boolean readable, Int32 indent) (at Assets/Editor/XUPorter/PBX Editor/PBXParser.cs:439)
    UnityEditor.XCodeEditor.PBXParser.Encode (UnityEditor.XCodeEditor.PBXDictionary pbxData, Boolean readable) (at Assets/Editor/XUPorter/PBX Editor/PBXParser.cs:177)
    UnityEditor.XCodeEditor.XCProject.CreateNewProject (UnityEditor.XCodeEditor.PBXDictionary result, System.String path) (at Assets/Editor/XUPorter/XCProject.cs:608)
    UnityEditor.XCodeEditor.XCProject.Save () (at Assets/Editor/XUPorter/XCProject.cs:633)
    XCodePostProcess.OnPostProcessBuild (BuildTarget target, System.String path) (at Assets/Editor/XUPorter/XCodePostProcess.cs:28)
    UnityEditor.HostView:OnGUI()

    and

    Exception: Project file not found at file path



    i cannot even open the xcode Project,
     
  2. proandrius

    proandrius

    Unity Technologies

    Joined:
    Dec 4, 2012
    Posts:
    544
    Is this happens if you build to the new folder?
     
  3. Filippopotamus

    Filippopotamus

    Joined:
    Oct 26, 2011
    Posts:
    34
    I am running into the same problem, have you found a solution?
     
  4. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Are you guys using Xcode 5.1.1 latest?
     
  5. Juang3d

    Juang3d

    Joined:
    Sep 25, 2012
    Posts:
    87
    I had a similar problem, I was working with Vuforia, updating it solved my problem.

    Cheers.
     
  6. Magmic

    Magmic

    Joined:
    Sep 19, 2013
    Posts:
    2
    I've got exactly the same issue and exactly the same stack trace for the error. XUPorter, Unity 4.5, Xcode 5.1.1. The problem appears to have started after updating to Unity 4.5, but I have no idea what the source of the problem actually is.
     
  7. Graham-Dunnett

    Graham-Dunnett

    Unity Technologies

    Joined:
    Jun 2, 2009
    Posts:
    4,287
    Well, @Juang3d suggested it was caused by an old copy of Vuforia.
     
  8. dragonmaster193

    dragonmaster193

    Joined:
    Apr 30, 2014
    Posts:
    5
    I'm having the same problem and I don't use Vuforia.
     
  9. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Firstly what a **** poor post by the original poster.
    Can you at least mention operating system used.
    Xcode version and machine setup.
    Unity people / forum people cannot help with such a poor description.
    And When you run Unity are you clickin on BUILD or BUILD AND RUN!
     
  10. dragonmaster193

    dragonmaster193

    Joined:
    Apr 30, 2014
    Posts:
    5
    I'm on Mac OS X 10.9.3 and tried XCode 5.1.1 and the XCode6 beta. Unity 4.3.4 on another machine works fine, but not Unity 4.5. Both Build and Build & Run will result in the same error.

    It appears to be a problem with the XUPorter third party plugin (built on the XCodeEditor plugin). It's a fairly common plugin to include when doing iOS work that needs files/libraries/frameworks added to the XCode project (I see it in some popular plugins, I wouldn't be surprised if it was bundled in with Vuforia). It opens up the .pbxproj file and adds its extra stuff then saves it back out. This error seems to appear when it tries to do the final save. It fails, and results in an empty project file.
     
  11. alfarmer

    alfarmer

    Joined:
    Nov 16, 2012
    Posts:
    27
    I have the same problem and am using Xcode 5.1.1 and unity 4.5.0 on the latest Mac OS X.

    In my case my Assets/Editor folder contains a "XUPorter-master" folder, which contains a "PBX Editor" folder, which contains a "PBXParser.cs" file, which appears to contain the bug.

    I can build & run on Mac just fine, but here is the error/stack trace from my Unity console window when trying to build for iOS. Below that is the code for "PBXParser.cs".

    Is this something built into Unity or something that came with an add-on?


    ====================================================================
    KeyNotFoundException: The given key was not present in the dictionary.

    System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (.TKey key) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150)

    UnityEditor.XCodeEditor.PBXResolver.ResolveName (System.String guid) (at Assets/Editor/XUPorter-master/PBX Editor/PBXParser.cs:49)

    UnityEditor.XCodeEditor.PBXResolver.ResolveName (System.String guid) (at Assets/Editor/XUPorter-master/PBX Editor/PBXParser.cs:53)

    UnityEditor.XCodeEditor.PBXParser.GUIDComment (System.String guid, System.Text.StringBuilder builder) (at Assets/Editor/XUPorter-master/PBX Editor/PBXParser.cs:218)

    UnityEditor.XCodeEditor.PBXParser.SerializeString (System.String aString, System.Text.StringBuilder builder, Boolean useQuotes, Boolean readable) (at Assets/Editor/XUPorter-master/PBX Editor/PBXParser.cs:546)

    UnityEditor.XCodeEditor.PBXParser.SerializeDictionary (System.Collections.Generic.Dictionary`2 dictionary, System.Text.StringBuilder builder, Boolean readable, Int32 indent) (at Assets/Editor/XUPorter-master/PBX Editor/PBXParser.cs:481)

    UnityEditor.XCodeEditor.PBXParser.SerializeValue (System.Object value, System.Text.StringBuilder builder, Boolean readable, Int32 indent) (at Assets/Editor/XUPorter-master/PBX Editor/PBXParser.cs:439)

    UnityEditor.XCodeEditor.PBXParser.SerializeDictionary (System.Collections.Generic.Dictionary`2 dictionary, System.Text.StringBuilder builder, Boolean readable, Int32 indent) (at Assets/Editor/XUPorter-master/PBX Editor/PBXParser.cs:489)

    UnityEditor.XCodeEditor.PBXParser.SerializeValue (System.Object value, System.Text.StringBuilder builder, Boolean readable, Int32 indent) (at Assets/Editor/XUPorter-master/PBX Editor/PBXParser.cs:439)

    UnityEditor.XCodeEditor.PBXParser.Encode (UnityEditor.XCodeEditor.PBXDictionary pbxData, Boolean readable) (at Assets/Editor/XUPorter-master/PBX Editor/PBXParser.cs:177)

    UnityEditor.XCodeEditor.XCProject.CreateNewProject (UnityEditor.XCodeEditor.PBXDictionary result, System.String path) (at Assets/Editor/XUPorter-master/XCProject.cs:612)

    UnityEditor.XCodeEditor.XCProject.Save () (at Assets/Editor/XUPorter-master/XCProject.cs:637)

    XCodePostProcess.OnPostProcessBuild (BuildTarget target, System.String path) (at Assets/Editor/XUPorter-master/XCodePostProcess.cs:28)

    UnityEditor.HostView:OnGUI()
    ====================================================================

    Code (CSharp):
    1. using UnityEngine;
    2. using System;
    3. using System.Collections;
    4. using System.Collections.Generic;
    5. using System.Text;
    6. using System.Text.RegularExpressions;
    7.  
    8.  
    9. namespace UnityEditor.XCodeEditor
    10. {
    11.     public class PBXResolver
    12.     {
    13.         private class PBXResolverReverseIndex : Dictionary<string, string> {}
    14.  
    15.         private PBXDictionary objects;
    16.         private string rootObject;
    17.         private PBXResolverReverseIndex index;
    18.  
    19.         public PBXResolver( PBXDictionary pbxData ) {
    20.             this.objects = (PBXDictionary)pbxData[ "objects" ];
    21.             this.index = new PBXResolverReverseIndex();
    22.             this.rootObject = (string)pbxData[ "rootObject" ];
    23.             BuildReverseIndex();
    24.         }
    25.  
    26.         private void BuildReverseIndex()
    27.         {
    28.             foreach( KeyValuePair<string, object> pair in this.objects )
    29.             {
    30.                 if( pair.Value is PBXBuildPhase )
    31.                 {
    32.                     foreach( string guid in ((PBXBuildPhase)pair.Value).files )
    33.                     {
    34.                         index[ guid ] = pair.Key;
    35.                     }
    36.                 }
    37.                 else if( pair.Value is PBXGroup )
    38.                 {
    39.                     foreach( string guid in ((PBXGroup)pair.Value).children )
    40.                     {
    41.                         index[ guid ] = pair.Key;
    42.                     }
    43.                 }
    44.             }
    45.         }
    46.  
    47.         public string ResolveName( string guid )
    48.         {
    49.             object entity = this.objects[ guid ];
    50.  
    51.             if( entity is PBXBuildFile )
    52.             {
    53.                 return ResolveName( ((PBXBuildFile)entity).fileRef );
    54.             }
    55.             else if( entity is PBXFileReference )
    56.             {
    57.                 PBXFileReference casted = (PBXFileReference)entity;
    58.                 return casted.name != null ? casted.name : casted.path;
    59.             }
    60.             else if( entity is PBXGroup )
    61.             {
    62.                 PBXGroup casted = (PBXGroup)entity;
    63.                 return casted.name != null ? casted.name : casted.path;
    64.             }
    65.             else if( entity is PBXProject || guid == this.rootObject )
    66.             {
    67.                 return "Project object";
    68.             }
    69.             else if( entity is PBXFrameworksBuildPhase )
    70.             {
    71.                 return "Frameworks";
    72.             }
    73.             else if( entity is PBXResourcesBuildPhase )
    74.             {
    75.                 return "Resources";
    76.             }
    77.             else if( entity is PBXShellScriptBuildPhase )
    78.             {
    79.                 return "ShellScript";
    80.             }
    81.             else if( entity is PBXSourcesBuildPhase )
    82.             {
    83.                 return "Sources";
    84.             }
    85.             else if( entity is PBXCopyFilesBuildPhase )
    86.             {
    87.                 return "CopyFiles";
    88.             }
    89.             else if( entity is PBXObject )
    90.             {
    91.                 PBXObject obj = (PBXObject)entity;
    92.  
    93.                 if( obj.ContainsKey( "name" ) )
    94.                     return (string)obj.data[ "name" ];
    95.             }
    96.  
    97.             //return "UNRESOLVED GUID:" + guid;
    98.             return null;
    99.         }
    100.  
    101.         public string ResolveBuildPhaseNameForFile( string guid )
    102.         {
    103.             if( this.objects.ContainsKey( guid ) )
    104.             {
    105.                 object obj = this.objects[ guid ];
    106.  
    107.                 if( obj is PBXObject )
    108.                 {
    109.                     PBXObject entity = (PBXObject)obj;
    110.  
    111.                     if( this.index.ContainsKey( entity.guid ) )
    112.                     {
    113.                         string parent_guid = this.index[ entity.guid ];
    114.  
    115.                         if( this.objects.ContainsKey( parent_guid ) )
    116.                         {
    117.                             object parent = this.objects[ parent_guid ];
    118.  
    119.                             if( parent is PBXBuildPhase )
    120.                                 return ResolveName( ((PBXBuildPhase)parent).guid );
    121.                         }
    122.                     }
    123.                 }
    124.             }
    125.  
    126.             return null;
    127.         }
    128.  
    129.     }
    130.  
    131.     public class PBXParser
    132.     {
    133.         public const string PBX_HEADER_TOKEN = "// !$*UTF8*$!\n";
    134.         public const char WHITESPACE_SPACE = ' ';
    135.         public const char WHITESPACE_TAB = '\t';
    136.         public const char WHITESPACE_NEWLINE = '\n';
    137.         public const char WHITESPACE_CARRIAGE_RETURN = '\r';
    138.         public const char ARRAY_BEGIN_TOKEN = '(';
    139.         public const char ARRAY_END_TOKEN = ')';
    140.         public const char ARRAY_ITEM_DELIMITER_TOKEN = ',';
    141.         public const char DICTIONARY_BEGIN_TOKEN = '{';
    142.         public const char DICTIONARY_END_TOKEN = '}';
    143.         public const char DICTIONARY_ASSIGN_TOKEN = '=';
    144.         public const char DICTIONARY_ITEM_DELIMITER_TOKEN = ';';
    145.         public const char QUOTEDSTRING_BEGIN_TOKEN = '"';
    146.         public const char QUOTEDSTRING_END_TOKEN = '"';
    147.         public const char QUOTEDSTRING_ESCAPE_TOKEN = '\\';
    148.         public const char END_OF_FILE = (char)0x1A;
    149.         public const string COMMENT_BEGIN_TOKEN = "/*";
    150.         public const string COMMENT_END_TOKEN = "*/";
    151.         public const string COMMENT_LINE_TOKEN = "//";
    152.         private const int BUILDER_CAPACITY = 20000;
    153.  
    154.         private char[] data;
    155.         private int index;
    156.         private PBXResolver resolver;
    157.  
    158.         public PBXDictionary Decode( string data )
    159.         {
    160.             if( !data.StartsWith( PBX_HEADER_TOKEN ) ) {
    161.                 Debug.Log( "Wrong file format." );
    162.                 return null;
    163.             }
    164.  
    165.             data = data.Substring( 13 );
    166.             this.data = data.ToCharArray();
    167.             index = 0;
    168.  
    169.             return (PBXDictionary)ParseValue();
    170.         }
    171.  
    172.         public string Encode( PBXDictionary pbxData, bool readable = false )
    173.         {
    174.             this.resolver = new PBXResolver( pbxData );
    175.             StringBuilder builder = new StringBuilder( PBX_HEADER_TOKEN, BUILDER_CAPACITY );
    176.  
    177.             bool success = SerializeValue( pbxData, builder, readable );
    178.             this.resolver = null;
    179.  
    180.             // Xcode adds newline at the end of file
    181.             builder.Append( "\n" );
    182.  
    183.             return ( success ? builder.ToString() : null );
    184.         }
    185.  
    186.         #region Pretty Print
    187.  
    188.         private void Indent( StringBuilder builder, int deep )
    189.         {
    190.             builder.Append( "".PadLeft( deep, '\t' ) );
    191.         }
    192.  
    193.         private void Endline( StringBuilder builder, bool useSpace = false )
    194.         {
    195.             builder.Append( useSpace ? " " : "\n" );
    196.         }
    197.  
    198.         private string marker = null;
    199.         private void MarkSection( StringBuilder builder, string name )
    200.         {
    201.             if( marker == null && name == null ) return;
    202.  
    203.             if( marker != null && name != marker )
    204.             {
    205.                 builder.Append( String.Format( "/* End {0} section */\n", marker ) );
    206.             }
    207.  
    208.             if( name != null && name != marker )
    209.             {
    210.                 builder.Append( String.Format( "\n/* Begin {0} section */\n", name ) );
    211.             }
    212.  
    213.             marker = name;
    214.         }
    215.  
    216.         private bool GUIDComment( string guid, StringBuilder builder )
    217.         {
    218.             string filename = this.resolver.ResolveName( guid );
    219.             string location = this.resolver.ResolveBuildPhaseNameForFile( guid );
    220.  
    221.             //Debug.Log( "RESOLVE " + guid + ": " + filename + " in " + location );
    222.  
    223.             if( filename != null ) {
    224.                 if( location != null )
    225.                     builder.Append( String.Format( " /* {0} in {1} */", filename, location ) );
    226.                 else
    227.                     builder.Append( String.Format( " /* {0} */", filename) );
    228.  
    229.                 return true;
    230.             }
    231.  
    232.             return false;
    233.         }
    234.  
    235.         #endregion
    236.  
    237.         #region Move
    238.  
    239.         private char NextToken()
    240.         {
    241.             SkipWhitespaces();
    242.             return StepForeward();
    243.         }
    244.  
    245.         private string Peek( int step = 1 )
    246.         {
    247.             string sneak = string.Empty;
    248.             for( int i = 1; i <= step; i++ ) {
    249.                 if( data.Length - 1 < index + i ) {
    250.                     break;
    251.                 }
    252.                 sneak += data[ index + i ];
    253.             }
    254.             return sneak;
    255.         }
    256.  
    257.         private bool SkipWhitespaces()
    258.         {
    259.             bool whitespace = false;
    260.             while( Regex.IsMatch( StepForeward().ToString(), @"\s" ) )
    261.                 whitespace = true;
    262.  
    263.             StepBackward();
    264.  
    265.             if( SkipComments() ) {
    266.                 whitespace = true;
    267.                 SkipWhitespaces();
    268.             }
    269.  
    270.             return whitespace;
    271.         }
    272.  
    273.         private bool SkipComments()
    274.         {
    275.             string s = string.Empty;
    276.             string tag = Peek( 2 );
    277.             switch( tag ) {
    278.                 case COMMENT_BEGIN_TOKEN: {
    279.                         while( Peek( 2 ).CompareTo( COMMENT_END_TOKEN ) != 0 ) {
    280.                             s += StepForeward();
    281.                         }
    282.                         s += StepForeward( 2 );
    283.                         break;
    284.                     }
    285.                 case COMMENT_LINE_TOKEN: {
    286.                         while( !Regex.IsMatch( StepForeward().ToString(), @"\n" ) )
    287.                             continue;
    288.  
    289.                         break;
    290.                     }
    291.                 default:
    292.                     return false;
    293.             }
    294.             return true;
    295.         }
    296.  
    297.         private char StepForeward( int step = 1 )
    298.         {
    299.             index = Math.Min( data.Length, index + step );
    300.             return data[ index ];
    301.         }
    302.  
    303.         private char StepBackward( int step = 1 )
    304.         {
    305.             index = Math.Max( 0, index - step );
    306.             return data[ index ];
    307.         }
    308.  
    309.         #endregion
    310.         #region Parse
    311.  
    312.         private object ParseValue()
    313.         {
    314.             switch( NextToken() ) {
    315.                 case END_OF_FILE:
    316.                     Debug.Log( "End of file" );
    317.                     return null;
    318.                 case DICTIONARY_BEGIN_TOKEN:
    319.                     return ParseDictionary();
    320.                 case ARRAY_BEGIN_TOKEN:
    321.                     return ParseArray();
    322.                 case QUOTEDSTRING_BEGIN_TOKEN:
    323.                     return ParseString();
    324.                 default:
    325.                     StepBackward();
    326.                     return ParseEntity();
    327.             }
    328.         }
    329.  
    330.         private PBXDictionary ParseDictionary()
    331.         {
    332.             SkipWhitespaces();
    333.             PBXDictionary dictionary = new PBXDictionary();
    334.             string keyString = string.Empty;
    335.             object valueObject = null;
    336.  
    337.             bool complete = false;
    338.             while( !complete ) {
    339.                 switch( NextToken() ) {
    340.                     case END_OF_FILE:
    341.                         Debug.Log( "Error: reached end of file inside a dictionary: " + index );
    342.                         complete = true;
    343.                         break;
    344.  
    345.                     case DICTIONARY_ITEM_DELIMITER_TOKEN:
    346.                         keyString = string.Empty;
    347.                         valueObject = null;
    348.                         break;
    349.  
    350.                     case DICTIONARY_END_TOKEN:
    351.                         keyString = string.Empty;
    352.                         valueObject = null;
    353.                         complete = true;
    354.                         break;
    355.  
    356.                     case DICTIONARY_ASSIGN_TOKEN:
    357.                         valueObject = ParseValue();
    358.                         if (!dictionary.ContainsKey(keyString)) {
    359.                             dictionary.Add( keyString, valueObject );
    360.                         }
    361.                         break;
    362.  
    363.                     default:
    364.                         StepBackward();
    365.                         keyString = ParseValue() as string;
    366.                         break;
    367.                 }
    368.             }
    369.             return dictionary;
    370.         }
    371.  
    372.         private PBXList ParseArray()
    373.         {
    374.             PBXList list = new PBXList();
    375.             bool complete = false;
    376.             while( !complete ) {
    377.                 switch( NextToken() ) {
    378.                     case END_OF_FILE:
    379.                         Debug.Log( "Error: Reached end of file inside a list: " + list );
    380.                         complete = true;
    381.                         break;
    382.                     case ARRAY_END_TOKEN:
    383.                         complete = true;
    384.                         break;
    385.                     case ARRAY_ITEM_DELIMITER_TOKEN:
    386.                         break;
    387.                     default:
    388.                         StepBackward();
    389.                         list.Add( ParseValue() );
    390.                         break;
    391.                 }
    392.             }
    393.             return list;
    394.         }
    395.  
    396.         private object ParseString()
    397.         {
    398.             string s = string.Empty;
    399.             char c = StepForeward();
    400.             while( c != QUOTEDSTRING_END_TOKEN ) {
    401.                 s += c;
    402.  
    403.                 if( c == QUOTEDSTRING_ESCAPE_TOKEN )
    404.                     s += StepForeward();
    405.  
    406.                 c = StepForeward();
    407.             }
    408.  
    409.             return s;
    410.         }
    411.  
    412.         private object ParseEntity()
    413.         {
    414.             string word = string.Empty;
    415.  
    416.             while( !Regex.IsMatch( Peek(), @"[;,\s=]" ) ) {
    417.                 word += StepForeward();
    418.             }
    419.  
    420.             if( word.Length != 24 && Regex.IsMatch( word, @"^\d+$" ) ) {
    421.                 return Int32.Parse( word );
    422.             }
    423.  
    424.             return word;
    425.         }
    426.  
    427.         #endregion
    428.         #region Serialize
    429.  
    430.         private bool SerializeValue( object value, StringBuilder builder, bool readable = false, int indent = 0 )
    431.         {
    432.             if( value == null ) {
    433.                 builder.Append( "null" );
    434.             }
    435.             else if( value is PBXObject ) {
    436.                 SerializeDictionary( ((PBXObject)value).data, builder, readable, indent );
    437.             }
    438.             else if( value is Dictionary<string, object> ) {
    439.                 SerializeDictionary( (Dictionary<string, object>)value, builder, readable, indent );
    440.             }
    441.             else if( value.GetType().IsArray ) {
    442.                 SerializeArray( new ArrayList( (ICollection)value ), builder, readable, indent );
    443.             }
    444.             else if( value is ArrayList ) {
    445.                 SerializeArray( (ArrayList)value, builder, readable, indent );
    446.             }
    447.             else if( value is string ) {
    448.                 SerializeString( (string)value, builder, false, readable );
    449.             }
    450.             else if( value is Char ) {
    451.                 SerializeString( Convert.ToString( (char)value ), builder, false, readable );
    452.             }
    453.             else if( value is bool ) {
    454.                 builder.Append( Convert.ToInt32( value ).ToString() );
    455.             }
    456.             else if( value.GetType().IsPrimitive ) {
    457.                 builder.Append( Convert.ToString( value ) );
    458.             }
    459.             else {
    460.                 Debug.LogWarning( "Error: unknown object of type " + value.GetType().Name );
    461.                 return false;
    462.             }
    463.  
    464.             return true;
    465.         }
    466.  
    467.         private bool SerializeDictionary( Dictionary<string, object> dictionary, StringBuilder builder, bool readable = false, int indent = 0 )
    468.         {
    469.             builder.Append( DICTIONARY_BEGIN_TOKEN );
    470.             if( readable ) Endline( builder );
    471.  
    472.             foreach( KeyValuePair<string, object> pair in dictionary )
    473.             {
    474.                 // output section banner if necessary
    475.                 if( readable && indent == 1 ) MarkSection( builder, pair.Value.GetType().Name );
    476.  
    477.                 // indent KEY
    478.                 if( readable ) Indent( builder, indent + 1 );
    479.  
    480.                 // KEY
    481.                 SerializeString( pair.Key, builder, false, readable );
    482.  
    483.                 // =
    484.                 // FIX ME: cannot resolve mode because readable = false for PBXBuildFile/Reference sections
    485.                 builder.Append( String.Format( " {0} ", DICTIONARY_ASSIGN_TOKEN ) );
    486.  
    487.                 // VALUE
    488.                 // do not pretty-print PBXBuildFile or PBXFileReference as Xcode does
    489.                 SerializeValue( pair.Value, builder, ( readable &&
    490.                     ( pair.Value.GetType() != typeof( PBXBuildFile ) ) &&
    491.                     ( pair.Value.GetType() != typeof( PBXFileReference ) )
    492.                 ), indent + 1 );
    493.  
    494.                 // end statement
    495.                 builder.Append( DICTIONARY_ITEM_DELIMITER_TOKEN );
    496.  
    497.                 // FIX ME: negative readable in favor of nice output for PBXBuildFile/Reference sections
    498.                 Endline( builder, !readable );
    499.             }
    500.  
    501.             // output last section banner
    502.             if( readable && indent == 1 ) MarkSection( builder, null );
    503.  
    504.             // indent }
    505.             if( readable ) Indent( builder, indent );
    506.  
    507.             builder.Append( DICTIONARY_END_TOKEN );
    508.  
    509.             return true;
    510.         }
    511.  
    512.         private bool SerializeArray( ArrayList anArray, StringBuilder builder, bool readable = false, int indent = 0 )
    513.         {
    514.             builder.Append( ARRAY_BEGIN_TOKEN );
    515.             if( readable ) Endline( builder );
    516.  
    517.             for( int i = 0; i < anArray.Count; i++ )
    518.             {
    519.                 object value = anArray[i];
    520.  
    521.                 if( readable ) Indent( builder, indent + 1 );
    522.  
    523.                 if( !SerializeValue( value, builder, readable, indent + 1 ) )
    524.                 {
    525.                     return false;
    526.                 }
    527.  
    528.                 builder.Append( ARRAY_ITEM_DELIMITER_TOKEN );
    529.  
    530.                 // FIX ME: negative readable in favor of nice output for PBXBuildFile/Reference sections
    531.                 Endline( builder, !readable );
    532.             }
    533.  
    534.             if( readable ) Indent( builder, indent );
    535.             builder.Append( ARRAY_END_TOKEN );
    536.  
    537.             return true;
    538.         }
    539.  
    540.         private bool SerializeString( string aString, StringBuilder builder, bool useQuotes = false, bool readable = false )
    541.         {
    542.             // Is a GUID?
    543.             // Note: Unity3d generates mixed-case GUIDs, Xcode use uppercase GUIDs only.
    544.             if( Regex.IsMatch( aString, @"^[A-Fa-f0-9]{24}$" ) ) {
    545.                 builder.Append( aString );
    546.                 GUIDComment( aString, builder );
    547.                 return true;
    548.             }
    549.  
    550.             // Is an empty string?
    551.             if( string.IsNullOrEmpty( aString ) ) {
    552.                 builder.Append( QUOTEDSTRING_BEGIN_TOKEN );
    553.                 builder.Append( QUOTEDSTRING_END_TOKEN );
    554.                 return true;
    555.             }
    556.  
    557.             // FIX ME: Original regexp was: @"^[A-Za-z0-9_.]+$", we use modified regexp with '/-' allowed
    558.             //           to workaround Unity bug when all PNGs had "Libraries/" (group name) added to their paths after append
    559.             if( !Regex.IsMatch( aString, @"^[A-Za-z0-9_./-]+$" ) ) {
    560.                 useQuotes = true;
    561.             }
    562.  
    563.             if( useQuotes )
    564.                 builder.Append( QUOTEDSTRING_BEGIN_TOKEN );
    565.  
    566.             builder.Append( aString );
    567.  
    568.             if( useQuotes )
    569.                 builder.Append( QUOTEDSTRING_END_TOKEN );
    570.  
    571.             return true;
    572.         }
    573.  
    574.         #endregion
    575.     }
    576. }
     
  12. Graham-Dunnett

    Graham-Dunnett

    Unity Technologies

    Joined:
    Jun 2, 2009
    Posts:
    4,287
    Not something that comes from Unity.
     
  13. dragonmaster193

    dragonmaster193

    Joined:
    Apr 30, 2014
    Posts:
    5
    I dug into the XUPorter code and found a solution. The key that's missing is part of a PBXVariantGroup region of the pbxproj file (specifically, the InfoPlist.strings). In the 'consolidate' method XUPorter grabs all the pieces of an Xcode project file and puts it all together, except that it's missing a few pieces (this being one of them). You can add the piece yourself or use MrTact's pull request from the XUPorter GitHub and get some additional functionality: https://github.com/onevcat/XUPorter/pull/30

    After that, there'll be a couple more errors. The other pieces to add are: PBXTargetDependency and PBXContainerItemProxy. After that you should be good to go.

    All these pieces seem related to the Tests target in the Xcode project that gets generated by Unity. I guess this was something that changed in Unity 4.5.
     
  14. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,614
    I downloaded the XUPorter Master Zip file from github today, dropped it into Assets/Editor in an empty Unity project and tried building.

    I get a null exception because mod.compiler_flags is null in ApplyMod at line 594 (XCProject.cs).

    I'm not familiar with Git, so please tell me if there's a working version elsewhere that I haven't spotted.

    I'm using Unity 4.5.1.

     
  15. dragonmaster193

    dragonmaster193

    Joined:
    Apr 30, 2014
    Posts:
    5
    I think it grabs the compiler flags from your .projmods file. Try setting it to an empty list.
     
  16. PDZ

    PDZ

    Joined:
    Sep 12, 2013
    Posts:
    18
    Also have the same issue as andymads having downloaded the branch from github. I have no linker flags specified in the mod.
     
  17. Landci

    Landci

    Joined:
    Aug 28, 2012
    Posts:
    33
    i am getting the same error using Unity 4.5.3f and Xcode 5.1.1 this error seems to happen because i updated a project from a Version <4.5.3f

    Any clues where this XUPorter comes from?


    found a solution for anybody dealing with the same issue:

    https://github.com/onevcat/XUPorter/issues/33

    i used the files of josh-ruis, and was able to build again
     
    Last edited: Aug 30, 2014
  18. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    508
    Hi,

    I still have this issue :

    KeyNotFoundException: The given key was not present in the dictionary. System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (.TKey key) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150) UnityEditor.XCodeEditor.XCProject..ctor (System.String filePath) (at Assets/Facebook/Editor/iOS/third_party/XCodeEditor-for-Unity/XCProject.cs:95) UnityEditor.FacebookEditor.XCodePostProcess.OnPostProcessBuild (BuildTarget target, System.String path) (at Assets/Facebook/Editor/FacebookPostprocess.cs:25) UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()

    AND

    KeyNotFoundException: The given key was not present in the dictionary. System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (.TKey key) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150) Everyplay.XCodeEditor.XCProject..ctor (System.String filePath) (at Assets/Editor/Everyplay/XCodeEditor/XCProject.cs:93) EveryplayPostprocessor.ProcessXCodeProject (System.String path) (at Assets/Editor/Everyplay/Scripts/EveryplayPostprocessor.cs:124) EveryplayPostprocessor.PostProcessBuild_iOS (System.String path, System.String clientId) (at Assets/Editor/Everyplay/Scripts/EveryplayPostprocessor.cs:76) EveryplayPostprocessor.OnPostProcessBuild (BuildTarget target, System.String path) (at Assets/Editor/Everyplay/Scripts/EveryplayPostprocessor.cs:24) UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()

    I'm losing my mind .... 1 week on it :'(

    Thanks a lot for your help !!

    (I'm using Chartboost 5.0, Facebook 6.0 and Everyplay)

    Thanks !
     
  19. pmjo

    pmjo

    Unity Technologies

    Joined:
    Sep 17, 2013
    Posts:
    240
    Upgrading to Chartboost 5.0.2 should solve this problem.
     
  20. ababab5

    ababab5

    Joined:
    Apr 15, 2014
    Posts:
    508
    you're right, thanks !