iOS: optional code fragments for debug builds

后端 未结 2 1656
小蘑菇
小蘑菇 2020-12-28 16:54

for my App I\'d like to have a debug view that I want to have only in debug-builds and not in release builds. I don\'t want to change my code though. Thats why i am wonderin

2条回答
  •  抹茶落季
    2020-12-28 17:12

    Check your projects build settings for debug to ensure that 'DEBUG' is being set - Apple gives you this for free - do this by selecting the project and clicking on the build settings tab. Search for 'DEBUG' and look to see if indeed DEBUG is being set.

    Build Settings tab of my project settings

    then conditionally code for DEBUG in your source files

    #ifdef DEBUG
    
    // Something to log your data here or even add a whole subview to see it on the device
    
    #else
    
    // 
    
    #endif
    

提交回复
热议问题