Search Unity

DirectoryNotFoundException in iOS

Discussion in 'iOS and tvOS' started by alexman, Feb 24, 2014.

  1. alexman

    alexman

    Joined:
    Jul 11, 2012
    Posts:
    17
    Hi,

    I have a data file in XML format that contains game object positions, my game read from this file to create game objects and put them in the corresponding Vector3 location.

    The file is saved in /Assets/Resources/Map and I am using the following line to load the XMLDocument :

    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.Load (Application.dataPath + "/Resources/Maps/Map_01.xml");

    which works fine when i test it in Unity, however when I export the game to iPhone I got this DirectoryNotFoundException :

    2014-02-24 18:16:38.882 Test[9453:907] -> registered mono modules 0x1704d20
    -> applicationDidFinishLaunching()
    -> applicationDidBecomeActive()
    Mono path[0] = '/var/mobile/Applications/384EE6A4-CED7-4DAB-AAF2-6E79016CE45E/Test.app/Data/Managed'
    Mono config path = '/var/mobile/Applications/384EE6A4-CED7-4DAB-AAF2-6E79016CE45E/Test.app/Data/Managed'
    Renderer: PowerVR SGX 543
    Vendor: Imagination Technologies
    Version: OpenGL ES 2.0 IMGSGX543-73.16
    GL_OES_depth_texture GL_OES_depth24 GL_OES_element_index_uint GL_OES_fbo_render_mipmap GL_OES_mapbuffer GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_OES_standard_derivatives GL_OES_texture_float GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_vertex_array_object GL_EXT_blend_minmax GL_EXT_color_buffer_half_float GL_EXT_debug_label GL_EXT_debug_marker GL_EXT_discard_framebuffer GL_EXT_map_buffer_range GL_EXT_occlusion_query_boolean GL_EXT_read_format_bgra GL_EXT_separate_shader_objects GL_EXT_shader_framebuffer_fetch GL_EXT_shader_texture_lod GL_EXT_shadow_samplers GL_EXT_texture_filter_anisotropic GL_EXT_texture_rg GL_EXT_texture_storage GL_APPLE_copy_texture_levels GL_APPLE_framebuffer_multisample GL_APPLE_rgb_422 GL_APPLE_sync GL_APPLE_texture_format_BGRA8888 GL_APPLE_texture_max_level GL_IMG_read_format GL_IMG_texture_compression_pvrtc
    Creating OpenGLES2.0 graphics device
    Initialize engine version: 4.3.4f1 (e444f76e01cd)
    Begin MonoManager ReloadAssembly
    Platform assembly: /var/mobile/Applications/384EE6A4-CED7-4DAB-AAF2-6E79016CE45E/Test.app/Data/Managed/UnityEngine.dll (this message is harmless)
    Loading /var/mobile/Applications/384EE6A4-CED7-4DAB-AAF2-6E79016CE45E/Test.app/Data/Managed/UnityEngine.dll into Unity Child Domain
    Platform assembly: /var/mobile/Applications/384EE6A4-CED7-4DAB-AAF2-6E79016CE45E/Test.app/Data/Managed/Assembly-CSharp.dll (this message is harmless)
    Loading /var/mobile/Applications/384EE6A4-CED7-4DAB-AAF2-6E79016CE45E/Test.app/Data/Managed/Assembly-CSharp.dll into Unity Child Domain
    Non platform assembly: /private/var/mobile/Applications/384EE6A4-CED7-4DAB-AAF2-6E79016CE45E/Test.app/Data/Managed/System.Xml.dll (this message is harmless)
    Non platform assembly: /private/var/mobile/Applications/384EE6A4-CED7-4DAB-AAF2-6E79016CE45E/Test.app/Data/Managed/System.dll (this message is harmless)
    Non platform assembly: /private/var/mobile/Applications/384EE6A4-CED7-4DAB-AAF2-6E79016CE45E/Test.app/Data/Managed/Mono.Security.dll (this message is harmless)
    Non platform assembly: /private/var/mobile/Applications/384EE6A4-CED7-4DAB-AAF2-6E79016CE45E/Test.app/Data/Managed/System.Configuration.dll (this message is harmless)
    Non platform assembly: /private/var/mobile/Applications/384EE6A4-CED7-4DAB-AAF2-6E79016CE45E/Test.app/Data/Managed/System.Security.dll (this message is harmless)
    Platform assembly: /var/mobile/Applications/384EE6A4-CED7-4DAB-AAF2-6E79016CE45E/Test.app/Data/Managed/Assembly-UnityScript.dll (this message is harmless)
    Loading /var/mobile/Applications/384EE6A4-CED7-4DAB-AAF2-6E79016CE45E/Test.app/Data/Managed/Assembly-UnityScript.dll into Unity Child Domain
    Non platform assembly: /private/var/mobile/Applications/384EE6A4-CED7-4DAB-AAF2-6E79016CE45E/Test.app/Data/Managed/Boo.Lang.dll (this message is harmless)
    - Completed reload, in 0.090 seconds
    DirectoryNotFoundException: Could not find a part of the path "/var/mobile/Applications/384EE6A4-CED7-4DAB-AAF2-6E79016CE45E/Test.app/Data/Resources/Maps/Map_01.xml".
    at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x00000] in <filename unknown>:0
    at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share) [0x00000] in <filename unknown>:0
    at System.Xml.XmlUrlResolver.GetEntity (System.Uri absoluteUri, System.String role, System.Type ofObjectToReturn) [0x00000] in <filename unknown>:0
    at Mono.Xml2.XmlTextReader.GetStreamFromUrl (System.String url, System.String absoluteUriString) [0x00000] in <filename unknown>:0
    at Mono.Xml2.XmlTextReader..ctor (System.String url, System.Xml.XmlNameTable nt) [0x00000] in <filename unknown>:0
    at System.Xml.XmlTextReader..ctor (System.String url, System.Xml.XmlNameTable nt) [0x00000] in <filename unknown>:0
    at System.Xml.XmlDocument.Load (System.String filename) [0x00000] in <filename unknown>:0
    at Map.loadMap () [0x00000] in <filename unknown>:0
    at Map.Awake () [0x00000] in <filename unknown>:0

    (Filename: Line: -1)

    I had a look in the XCode and cannot find the XML file, what is the correct way to include XML data file in iOS? Thank you very much.

    Regards,
    Alex
     
  2. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,624
  3. alexman

    alexman

    Joined:
    Jul 11, 2012
    Posts:
    17
    Fantastic, it works, thank you Alexey