#pragma mark not showing in methods in Xcode 4.0

前端 未结 13 1878
死守一世寂寞
死守一世寂寞 2021-01-01 13:16

In Xcode Version 4.0 I notice that #pragma marks within methods are no longer showing up in the Jump Bar. The only #pragma marks that are showing up are those that are betwe

13条回答
  •  無奈伤痛
    2021-01-01 13:29

    Apparently there are some issues in the pragma parser in Xcode. In my case I could make the #pragmas re-appear by unificating their syntax to the new one.

    Instead of having not uniform and messy chunks of code with some pragmas in it:

    // Code ...
    #pragma mark -
    #pragma mark UITextViewDelegate Protocol
    
    // More code ...
    # pragma mark - Important stuff
    // Even more code ...
    

    I changed everything to:

    // Code ...
    
    #pragma mark - UITextViewDelegate Protocol
    
    // More code ...
    
    # pragma mark - Important stuff
    
    // Even more code ...
    

    Basically, I made sure...

    • there is one blank line before and after the #pragma line.
    • there is only one space before and another after the -.
    • the pragma line does not end with an space.

    UPDATE

    I've realized that sometimes above rules are not enough if the project is broken somewhere. ( I tried moving some sources to a new project and they showed correctly). So what I did is close my project, delete its derived data from the organizer and also delete these two folders

    MyProject.xcodeproj/project.xcworkspace/
    MyProject.xcodeproj/xcuserdata/
    

    So next time I open my project Xcode will re-generate them :)

    Now ALL my sources are OK again :)

提交回复
热议问题