Search Unity

Error "unknown type name __declspec" after Xcode 7.3 upgrade

Discussion in 'iOS and tvOS' started by megasweet, Mar 22, 2016.

  1. megasweet

    megasweet

    Joined:
    Nov 10, 2015
    Posts:
    5
    Hi,

    I have a project in Unity 4.6.9p4. This evening I updated my iphone to iOS 9.3, which necessitated an Xcode update to 7.3. After the upgrade, my project that previously compiled just fine is now throwing the error "unknown type name __declspec" whenever I try to compile in Xcode. I double checked this by opening, cleaning, and building a previously-built Xcode project, one that worked fine on my phone. Same error. It throws the error on the first line of this code:

    Code (CSharp):
    1. NORETURN static void il2cpp_codegen_raise_exception (Il2CppCodeGenException *ex)
    2. {
    3.     il2cpp::vm::Exception::Raise ((Il2CppException*)ex);
    4. #if __has_builtin(__builtin_unreachable)
    5.     __builtin_unreachable();
    6. #endif
    7. }
    Any idea what can be done to avoid this? I am currently downloading the previous version of Xcode but this is going to be a problem for me pretty soon. Thank you for looking!
     
  2. megasweet

    megasweet

    Joined:
    Nov 10, 2015
    Posts:
    5
    Ok embarrassing.

    As soon as I posted I saw the banner flash by up top saying there's a new version of Unity that supports Xcode 7.3. I will grab that and give it a shot. Apologies for the spam.
     
  3. rai_arpit

    rai_arpit

    Joined:
    Feb 28, 2015
    Posts:
    3
    hi @megasweet, we are facing the exact issue. We are on 5.2.4. Can you please let me know which version did you upgrade to resolve this issue?
    The thing is, we initially tried upgrading to 5.3 when it came out but had a bunch of issues. Hence we reverted to 5.2.4. I was hoping to not upgrade to 5.3.x to get around this hence wanted to know how you resolved it.
     
  4. megasweet

    megasweet

    Joined:
    Nov 10, 2015
    Posts:
    5
    Hi @rai_arpit, I am still on Unity 4.x so I downloaded Unity 4.7.1 last night, which should support iOS 9.3. I ran out of time to install and try it last night but I'm confident it will work. Worst case I can roll back. I am at the end of a multi-year project so I was going a bit crazy and really shouldn't have upgraded at all.

    Apologies that I can't help you with Unity 5 issues as I am not going to upgrade my project to Unity 5. Best of luck resolving the issue!
     
  5. jkmn

    jkmn

    Joined:
    Mar 23, 2016
    Posts:
    1
    If you are like me and can't upgrade, I got it to "compile" by replacing
    #define NORETURN __declspec(noreturn)
    with
    #define NORETURN __attribute__((noreturn))
    in the il2cpp-config.h
     
  6. tuyoshi

    tuyoshi

    Joined:
    Jun 19, 2014
    Posts:
    7
    In my case, this can't solve problem. my env is Unity5.2.4 XCode7.3
     
  7. afrokick

    afrokick

    Joined:
    May 13, 2011
    Posts:
    6
    It has helped me:

    1) Remove 'NORETURN'
    2) Clean build
    3) Build it

    Like a hack:)

    XCode7.3, Unity5.2.2

    UPD: XCode7.3, Unity5.3.4f1 - no issue
     
    Last edited: Mar 24, 2016
  8. w5897093

    w5897093

    Joined:
    Mar 25, 2016
    Posts:
    3
  9. almo

    almo

    Joined:
    Jul 14, 2010
    Posts:
    83
    I can't upgrade to 5.3, because it renders UI.Text one line up, and breaks all my menus. That fix is slated for 5.4, which has been delayed. I can't even use 5.2, because it drops my 30 FPS iOS game to 12.
     
  10. almo

    almo

    Joined:
    Jul 14, 2010
    Posts:
    83
    I have a fix.

    Find the 3 files in the Unity application called il2cpp-codegen.h.

    /Applications/Unity5.1.4/Unity.app/Contents/PlaybackEngines/WebGLSupport/BuildTools/Libraries/libil2cpp/include/codegen/il2cpp-codegen.h
    /Applications/Unity5.1.4/Unity.app/Contents/PlaybackEngines/iossupport/il2cpp/libil2cpp/include/codegen/il2cpp-codegen.h
    /Applications/Unity5.1.4/Unity.app/Contents/Frameworks/il2cpp/libil2cpp/codegen/il2cpp-codegen.h

    Find this line in those:

    NORETURN static void il2cpp_codegen_raise_exception (Il2CppCodeGenException *ex)

    Delete the "NORETURN" from each, and save the files. It should work now.
     
    Abaobao, Shushustorm and nastasache like this.
  11. Alex_li

    Alex_li

    Joined:
    Nov 5, 2013
    Posts:
    1
    tks!It's helpful for me
     
  12. nastasache

    nastasache

    Joined:
    Jan 2, 2012
    Posts:
    74
    Thx, jkmn!
    Worked for me (Unity 5.3.1f1, Xcode 7.3)
     
  13. Addyarb

    Addyarb

    Joined:
    Mar 2, 2014
    Posts:
    43
    The 'Delete NORETURN' method works for me.

    To be clear to those who don't use Xcode for anything but to build to iOS:

    1. Click on the error in xCode (the red icon). The line should now be highlighted.
    2. Place your cursor in front of the word 'NORETURN' and backspace until it's gone.
    3. Go to "Product" and click "Clean."
    4. Rebuild project by clicking on the play button in the top left corner.

    Xcode Version 7.3 (7D175)
    Unity Version 5.3.1 (Latest Vuforia-Supported Version)
     
    Last edited: Mar 31, 2016
  14. -chris

    -chris

    Joined:
    Mar 1, 2012
    Posts:
    99
    For 5.2.4f1, as well as deleting NORETURN, also have to delete instances of IL2CPP_NO_INLINE.
     
    raydekk and almo like this.
  15. almo

    almo

    Joined:
    Jul 14, 2010
    Posts:
    83
    Really? I didn't have to do that...
     
  16. YangEGG

    YangEGG

    Joined:
    Oct 29, 2015
    Posts:
    6
    @jkmn
    Today I meet this problem too,but my Unity version is 4.6.3.Will it be solved if I use your mothod to do it?
    hope you can understand what i want to said.



    for Unity 4.6.3,it can be worked normally.
     
    Last edited: Apr 9, 2016
  17. YangEGG

    YangEGG

    Joined:
    Oct 29, 2015
    Posts:
    6
    for Unity 4.6.3,it can be worked normally.
     
  18. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Unity 4.6.3 is pretty old hence may not support xcode latest, I suggest trying upgrade to 4.7.1 as has newer xcode support or try the hack way.

    There will always be a issue as Apple releases new versions of Xcode, simply older versions of Unity not support the features.
     
  19. ksiUnity

    ksiUnity

    Joined:
    Mar 18, 2015
    Posts:
    2
    I had problems with Unity 4.6.2 while compiling with xcode 7.3. Just follow jkmn's answer. Works like a charm
     
  20. MarcusRLA

    MarcusRLA

    Joined:
    Jun 5, 2015
    Posts:
    2

    As someone who doesn't use Xcode for anything but to build to iOS, I really appreciate your post. It solved my problem.Thanks man
     
    Addyarb likes this.
  21. eldes

    eldes

    Joined:
    Apr 14, 2016
    Posts:
    1
    This worked for me. Thank you jkmn! You saved my life:)
     
  22. Sam_alonso

    Sam_alonso

    Joined:
    Dec 7, 2013
    Posts:
    4
    Yes. I tried this too but did not work and the release is going bad everytime I comment something.

    Do u know where to delete this?

    So I will try to update to 5.3.2 and see what happens.
     
  23. cdm89

    cdm89

    Joined:
    Mar 29, 2014
    Posts:
    3
    I cant find this line ANYWHERE i searched the entire project in xcode....where was this exactly? Thanks
     
  24. Addyarb

    Addyarb

    Joined:
    Mar 2, 2014
    Posts:
    43
    Do you have an error? You should have a red exclamation mark in your xCode project if this is the issue.
    If that is the case, then just click on the red error icon, and you should be taken to the line where you need to correct something.

    If you see a line reading "NORETURN" at the beginning, just delete "NORETURN" - click project, clean, and then press the play button to attempt to rebuild.

    With that being said;

    The main problem here seems to be caused by an out-of-date xCode version - or an out-of-date iOS device. Removing the "NORETURN" within the code seems to be circumventing the bug as mentioned. However, if you don't have a red exclamation mark error, this may not be the issue.

    Try:
    • Updating your xCode version to the latest version (supports iOS 9.3)
    • Updating your iOS device to iOS 9.3
    • Setting your build target to something lower/higher
    If you still can't figure it out, describe your error in more detail with your next post.

    Best of luck!
     
  25. fangfangYan

    fangfangYan

    Joined:
    Oct 27, 2016
    Posts:
    1
    This worked for me too.I use unity 5.2.3, xCode 8.2.1 and device to IOS 10.2
     
  26. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,620
    I just wanted to pop in and say thanks for the quick fix in this thread! Had to do a quick update to an old project and finding a simple answer quickly was nice. Cheers!