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

4.6.2p2 iOS Arc Restrictions compiler error

Discussion in 'iOS and tvOS' started by ziggyeye, Feb 13, 2015.

  1. ziggyeye

    ziggyeye

    Joined:
    May 22, 2013
    Posts:
    5
    Using 4.6.2p2 iOS build in Xcode gives a compiler error in UnityRendering.h
    ARC Restrictions
    ARC forbids Objective-C objects in struct
     
  2. Drowning-Monkeys

    Drowning-Monkeys

    Joined:
    Mar 6, 2013
    Posts:
    328
  3. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,602
    well - compiler error cannot happen in header file - so please drop the whole message from clang
    anyway, comparing code to 5.0 where we have arc fully enabled tells me you should try this:
    in UnityRendering.h look for
    START_STRUCT(UnityDisplaySurfaceGLES, UnityDisplaySurfaceBase)

    change

    CAEAGLLayer* layer;
    EAGLContext* context;

    to

    OBJC_OBJECT_PTR CAEAGLLayer* layer;
    OBJC_OBJECT_PTR EAGLContext* context;

    and please post here if it helps
     
    paradizIsCool likes this.
  4. Drowning-Monkeys

    Drowning-Monkeys

    Joined:
    Mar 6, 2013
    Posts:
    328
    In UnityRendering.h:

    Code (csharp):
    1.  
    2. // GLES display surface
    3. START_STRUCT(UnityDisplaySurfaceGLES, UnityDisplaySurfaceBase)
    4.     CAEAGLLayer*    layer;
    5.     EAGLContext*    context;
    6.  
    Causes the error mentioned above.
     
  5. Drowning-Monkeys

    Drowning-Monkeys

    Joined:
    Mar 6, 2013
    Posts:
    328
    oh, and that worked by the way, thanks!!!
     
  6. akasurreal

    akasurreal

    Joined:
    Jul 17, 2009
    Posts:
    441
    +1 fixed my same exact issue
     
  7. paradizIsCool

    paradizIsCool

    Joined:
    Jul 10, 2014
    Posts:
    177
    Any idea how to fix this when using command line build ?
    It works when I build manually and edit file each time, but I can't find a way to edit UnityRendering.h once for all ?

    - FOUND Unity ▸ Contents ▸ PlaybackEngines ▸ iossupport ▸ Trampoline ▸ Classes ▸ Unity ▸ UnityRendering.h and edited, it works
     
    Last edited: Feb 16, 2015
  8. Deleted User

    Deleted User

    Guest

    This worked for me, after changing that code itself I can build the projects without getting that error every time.
     
  9. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,602
    >>Any idea how to fix this when using command line build ?
    4.6.3 will have it fixed no worries
     
  10. andypoptacular

    andypoptacular

    Joined:
    Oct 28, 2014
    Posts:
    1
    This bug makes you wonder... did the QA team even try building an iOS project?
     
  11. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,602
    >>This bug makes you wonder... did the QA team even try building an iOS project?
    and that made me wonder - if people are actually trying to understand things and read? this bug is triggered only if you have objc (not objc++) plugin forcibly built with ARC - this cant be considered quite common situation
     
  12. Bill-Robinson

    Bill-Robinson

    Joined:
    Sep 21, 2012
    Posts:
    6
    We had the same problem. Maybe it's because we were using the https://github.com/playgameservices/play-games-plugin-for-unity

    I added this fugly piece of code to our build pipeline.

    Code (CSharp):
    1.             {
    2.                 var renderingFile = Path.Combine(xCodeDir, "Classes/Unity/UnityRendering.h");
    3.                 var r = new Regex(@"^(\s*)(CAEAGLLayer\*\s*layer|EAGLContext\*\s*context)\;\s*$");
    4.                 File.WriteAllLines(renderingFile, File.ReadAllLines(renderingFile).Select(line => r.Replace(line, "$1OBJC_OBJECT_PTR $2;")).ToArray());
    5.             }
    6.