Search Unity

Xcode build Error : 'UnityFramework/UnityFramework.h' file not found

Discussion in 'iOS and tvOS' started by U_Raizada, Mar 1, 2020.

  1. U_Raizada

    U_Raizada

    Joined:
    Feb 21, 2020
    Posts:
    1
    When I am trying to build the Xcode project, it is saying that my main.mm can not find the UnityFramework.h file. Which I checked is not missing in the Project. Can anyone give me some advice on what to do?
    Screenshot 2020-03-01 at 3.52.53 PM.png
     
  2. austerlitz10

    austerlitz10

    Joined:
    Aug 22, 2016
    Posts:
    3
    I have the same error. Not sure what to do.
     
  3. kaarloew

    kaarloew

    Joined:
    Nov 1, 2018
    Posts:
    360
    This is known issue with Helpshift plugin (and with all plugins that use OLD mod_pbxproj). You can fix this by modifying mod_pbxproj.py file by adding
    Code (CSharp):
    1. ('PBXHeadersBuildPhase', True),
    to line 1349 (or near it, depending about the mod_pbxproj version)
     
    MagicMiikka and austerlitz10 like this.
  4. Kaiymu_

    Kaiymu_

    Joined:
    Jun 1, 2016
    Posts:
    47
    Hello everyone,

    I don't have any mod_pbxproj.py in my project, so I have to update the main.mm manually. Is there any other way to change that ? (I just update the path so!)

    Thank you !
     
  5. kaarloew

    kaarloew

    Joined:
    Nov 1, 2018
    Posts:
    360
    You can create post process script that modifies the file manually. Something like
    Code (CSharp):
    1.  
    2.     [PostProcessBuild]
    3.     public static void ChangeXcodePlist(BuildTarget buildTarget, string path)
    4.     {
    5.         if (buildTarget == BuildTarget.iOS)
    6.         {
    7.             // Ugly fix for missing UnityFramework.h Xcode issue
    8.             string mainAppPath = Path.Combine(path, "MainApp", "main.mm");
    9.             string mainContent = File.ReadAllText(mainAppPath);
    10.             UnityEngine.Debug.Log(mainContent);
    11.             string newContent = mainContent.Replace("#include <UnityFramework/UnityFramework.h>", @"#include ""../UnityFramework/UnityFramework.h""");
    12.             File.WriteAllText(mainAppPath, newContent)
    13.          }
    14. }
    15.  
     
    m4d, sarebots2, il-k-goto and 3 others like this.
  6. Kaiymu_

    Kaiymu_

    Joined:
    Jun 1, 2016
    Posts:
    47
    Hello Kaarloew !
    Thanks for the reply :).

    I don't have access to my mac OS machine, but I'm totally going to do that! I started modifying the file by hand and I was close the getting it to work!

    Thank you for your help!
     
  7. YHX2000

    YHX2000

    Joined:
    Aug 2, 2015
    Posts:
    29
    Hello @kaarloew where I can read more info how to implement such script in my unity project ? I mean is it just writing script and then I run build in Unity ?
     
  8. kaarloew

    kaarloew

    Joined:
    Nov 1, 2018
    Posts:
    360
    YHX2000 likes this.
  9. KimLysgaardAndersen

    KimLysgaardAndersen

    Joined:
    Jul 4, 2016
    Posts:
    2
    I have the same error. It started after I cleaned the project in xcode. I have spent all day on that error please help!!! :)
     
  10. KimLysgaardAndersen

    KimLysgaardAndersen

    Joined:
    Jul 4, 2016
    Posts:
    2
    Ok I finally got it! You can change the code in main.mm by hand. I changed it from <UnityFramwork/UnityFramwork.h> To "../UnityFramwork/UnityFramwork.h"
     
  11. kunalxigxag

    kunalxigxag

    Joined:
    Aug 7, 2014
    Posts:
    9
    Dude, its framework not framwork -
    Code (CSharp):
    1. #include "../UnityFramework/UnityFramework.h"
     
    sarebots2 likes this.
  12. Danoli3

    Danoli3

    Joined:
    Sep 12, 2017
    Posts:
    14
    Dude, UnityFramwork for days.

     
  13. christianlong99

    christianlong99

    Joined:
    Aug 20, 2018
    Posts:
    3
    This worked for me!! After 9-10 hours of searching for a solution to this error: 'defines.h' file not found
    Probably will use the post process script for new builds, but changing the main.mm file in xcode was simple enough to test it.
     
    Christin2015 likes this.
  14. MaxAtEclipse

    MaxAtEclipse

    Joined:
    Feb 25, 2020
    Posts:
    6
    I can't explain exactly why this happened, nor why my solution worked, but I found that in my Products folder, there were multiple folders. One was "ReleaseForRunning-iphoneos" - that's the one from which Xcode was building. That one didn't contain the UnityFramework folder, but another - "ReleaseForRunning-iphonesimulator" did. I copied that folder over (it's all for the same app after all, right?) and the build succeeded.
     
  15. bigbrainz

    bigbrainz

    Joined:
    Jul 21, 2015
    Posts:
    177
    After fiddling with this same problem for an hour or two, I solved by just clearing the build folder. o_O
     
  16. robin_pcity

    robin_pcity

    Joined:
    Jun 26, 2020
    Posts:
    28
    where is this file located?
     
  17. Sai_Nishanth

    Sai_Nishanth

    Joined:
    Dec 8, 2022
    Posts:
    1
    After fixing this issue I have another issue with unityappcontroller.h file is not found.
     
  18. arpanmehtaevontech

    arpanmehtaevontech

    Joined:
    Feb 28, 2023
    Posts:
    3
    i am getting this error while include this ->
    #include <UnityFramework/UnityFramework.h>

    Error ->UnityFramework/UnityFramework.h' file not found..

    Please Help me out
     
  19. Baldrekr

    Baldrekr

    Joined:
    Jul 15, 2018
    Posts:
    12
    A recent version of Unity (2022.3.18 onwards) broke IOS builds if using IOS Project Builder. Also broken in the current Unity version. I am posting the error below (for anyone searching the internet for a solution to this problem) and the fix below that.

    In file included from .\MainApp\main.mm:1:
    .\UnityFramework/UnityFramework.h(4,9): fatal error: 'UnityFramework/UnityAppController.h' file not found
    #import <UnityFramework/UnityAppController.h>
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1 error generated.
    + [arm64] Linking <my app name>...
    ld64.lld: error: cannot open build/Release-iphoneos/iPhone-target/arm64/./MainApp/main.mm.obj: no such file or directory
    ld64.lld: error: undefined symbol: main

    To fix, add this code in a file like Editor/PostProcessBuildClass.cs:

    Code (CSharp):
    1. static class PostProcessBuildClass {
    2.   [PostProcessBuild]
    3.   public static void ChangeXcodePlist(BuildTarget buildTarget, string path) {
    4.     Debug.Log("Post process build ChangeXcodePlist");
    5.     if (buildTarget == BuildTarget.iOS) {
    6.       string mainAppPath = Path.Combine(path, "UnityFramework", "UnityFramework.h");
    7.       string mainContent = File.ReadAllText(mainAppPath);
    8.       string newContent = mainContent.Replace("#import <UnityFramework/UnityAppController.h>", "#import <Classes/UnityAppController.h>");
    9.       File.WriteAllText(mainAppPath, newContent);
    10.     }
    11.   }
    12. }
    13.  
     
    chadfind, m4d and marting_unity like this.
  20. marting_unity

    marting_unity

    Joined:
    Feb 13, 2024
    Posts:
    1
    I'm my scenario, for some reason using Unity 2022.3.20f1 I had to ad both patches.
    The main.mm and UnityFramework.h
     
    m4d likes this.
  21. chadfind

    chadfind

    Joined:
    Sep 27, 2017
    Posts:
    1
    Baldrekr - thank you - just recently upgraded unity and ran into this - your fix worked perfectly. Just hope I remember to remove it after I update to a fixed unity or ios build tool!