developer tip

Xcode에서“To Do”주석을 표시하려면 어떻게해야합니까?

optionbox 2020. 8. 6. 08:16
반응형

Xcode에서“To Do”주석을 표시하려면 어떻게해야합니까?


현재 iOS 기반 이미지 조작 작업을하고 있습니다.

문제:

다른 모듈에서 일하고 있습니다. 따라서 나중에 모듈에 무언가를 추가 해야하는 경우 To do 메모로 표시하고 싶습니다. Xcode에서 메모를 추가 할 다른 매크로 또는 유사한 것이 있습니까?

나는 시도했다 :

이를 위해 현재 다음 #pragma과 같이 사용 하고 있습니다 :

#pragma mark -
#pragma mark To do: Add the Image processing methods.

나는 얻었다 :

그러나 방법 섹션에는 다음과 같이 나열됩니다.

할 것

내가 실제로 필요한 것 :

문제는 메소드 목록에 나열되어 있기 때문에 때로는 섹션에서 이것을 제거하는 것을 잊어 버렸고 전체 소스 코드에서 찾기가 매우 어렵다는 것입니다. (#pragma 결과를 검색하여 전체 목록 표시)

기술적 세부 사항:

Xcode 버전 4.6.2를 사용하고 있습니다.


// TODO: the thing todo

작업 관리 작업을 표시하는 방법입니다.


알았어

다음과 같은 의견 쓰기 :

// TODO: Do something

트릭을 할 것입니다.

나는 다음과 같은 것을 얻었다 :

할 것


Also there is a lot of options like:

  1. // FIXME: Midhun

  2. // ???: Midhun

  3. // !!!: Midhun

  4. // MARK: Midhun

Using the

//TODO: some thing here

works if all you want to do is to look at the list of todos in the drop down

If you want to be intrusive you can use #warning marks instead:

#warning this will create a compiler warning.

And when you build the app you will get a compiler warning (a yellow triangle, not a compiler error) which is a little more "in your face" about reminding you of things you need to do.


With the script below your can see all required tags like warnings.

  1. Select your project in the Project Navigator
  2. Open the target in the sidebar and move to the "Build Phases" tab
  3. Click on "+" sign
  4. Select "New Run Script Build Phase" 스크립트 추가
  5. Add below script to "Run Script" 준비 스크립트 The script:

    KEYWORDS="TODO:|FIXME:|DevTeam:|XXX:"
    find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/ warning: \$1/"
    

여기에 이미지 설명을 입력하십시오

Original answer was taken from Here

Another alternative is XToDo plugin for Xcode.


You can use XToDo plugin

https://github.com/trawor/XToDo

ctrl + t를 사용하여 목록 창을 켜거나 끕니다.

use ctrl+t to trigger the List Window on/off

툴바 예제

Easy install with alcatraz use ctrl+t to trigger the List Window on/off


I started with

// TODO: Implement bubble sort.

Then I joined a large project and sometimes I needed a todo to live longer than a WIP commit and so to distinguish my todos from my peers I name spaced my todo with my initials:

// TODO: SM: Implement bubble sort

Sometimes I wanted more visibility so I started to use pragma warnings in some places.

#warning Implement bubble sort

One day I decided to turn on hard mode by adding -Werror to my cflags. Unfortunately this makes pragma warnings useless because they prevent compilation. And so I went back to using // TODO: until Jeff Nadeau told me that I can put

-Wno-error=#warnings

in my cflags so as to not treat pragma warnings as errors. So now #warning and -Werror can live along side each other.


I tend to write exactly //TODO: Blah blah blah

Then I just do a COMMAND-SHIFT-F and look for "//TODO".

Using the file outline drop down will only show you TODOs for the current file, but I tend to want to see my project's TODO status.

Rough solution, but it does it's job.


I split up the recognized tokens into Warnings and Errors for my own use, thought I would share it here:

KEYWORDS="STUB:|WARNING:|TODO:|FIXME:|DevTeam:|\?\?\?:" 
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -not -path "${SRCROOT}/Pods/*" -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/1: warning: \$1/"

KEYWORDS="ERROR:|XXX:|\!\!\!:" 
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -not -path "${SRCROOT}/Pods/*" -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/1: error: \$1/"
ERROR_OUTPUT=`find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -not -path "${SRCROOT}/Pods/*" -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/1: error: \$1/"`

exit ${#ERROR_OUTPUT}

Another simple method, slightly outside the box, if you don't want to clutter up the methods listing bar, is to use a convention within comments like //Todo: and when you want to address them en-masse, simply select the Find Navigator, match case and search for //Todo:

spagetti-code처럼 보이는 메소드 드롭 다운이 마음에 들지 않기 때문에 이것을 선호합니다. 그리고 네, 나는 종종 Todo : 's;)를 많이 가지고 있습니다.


#error

#warning

C 프로그래밍에도 사용됩니다

참고 URL : https://stackoverflow.com/questions/16913055/how-can-i-mark-to-do-comments-in-xcode

반응형