How to add code in Xcode 4?

I could not find a way to put a bookmark inside the code in Xcode 4. I know about #pragma mark , but this is not what I am looking for. I need something that I can place and remove with a mouse click and move between next and previous, as in VS.

Is there something I am missing?

+50
xcode4 bookmarks
Mar 29 '11 at 13:22
source share
9 answers

The bookmarks seem to have gone the way of the dinosaur in Xcode 4. It wouldn’t be so bad if the pop-up window with the add-on above the editor didn’t disappear in previous versions either. The best replacement at the moment is the use of control points (of course, disabled separately) and navigation using Breakpoint Navigator.

Shortcut for breakpoints Cmmd + 7 . When using the arrow keys

Print a bug report at http://bugreporter.apple.com if you feel that something like this needs to be returned.

+51
Mar 29 '11 at 13:32
source share

Write a comment below in the source file that you want to bookmark.

  //<##> 

And you can go to next / previous with: ' ^ / ' or ' ^? ''

  • <##> means "code snippet placeholder"
  • ^ / means go to next placeholder
  • ^? means go to previous placeholder.

thank

+51
Jul 21 2018-12-12T00:
source share

Another option if someone is still interested. The following directives will trigger a compiler warning, which you can use as a bookmark:

 #pragma message "<# message #>" 

or

 #warning <# message #> 

If you want to place bookmarks with the mouse: create a code snippet with one of the two directives above. Drag it to the line of the source file that you want to tag.

Go to next / previous with: Cmd- and Cmd-Shift -

+16
Jan 21 2018-12-12T00:
source share

In Xcode 4.4, if you leave a comment in this format:

 // TODO: Your text here 

it will be added as a list in the transition bar next to the list of methods in your current file, and then you can go directly to this comment from this menu.

+8
Aug 08
source share

The easiest way is to use the comment added by // TODO and then search, which allows you to navigate to problems from the navigator. It is quite difficult to defeat this technique.

I personally don’t like using breakpoints for bookmarks, because entering notes is not easy. I use breakpoints as breakpoints and prefer not to mix them with bookmarks.

Anyway, if you want to participate a bit, you can get xcode to generate warnings // TODO: some message or // FIXME: some message that can be moved in the problem navigator. I took the instructions below this site :

Instruction manual

Go to the project element in the Project Navigator (usually at the top) Find your goal in the list of goals on the left, select it Go to the "Build phases" tab. Click "Add Build Phase" in the lower right corner of the screen. In the editor that appears, paste the bash script shown below. Now just create and you will see all your // TODO: and // FIXME: comments have become warnings. I like this technique, it may not be so for everyone, but I hope this helps someone. Bash script For “Run Script” Build Phase

KEYWORDS = "TODO: | FIXME: |? \\ \ ?: | !!!:" find "$ {SRCROOT}" (-name ".h" -or -name ".m") -print0 | xargs -0 egrep --with-filename -line-number -only-matching "($ KEYWORDS). * \ $" | perl -p -e "s / ($ KEYWORDS) / warning: \ $ 1 /" You can also click each of the warnings in the problem navigator to go to the file and specify the code in which you left the original // TODO: or // FIXME: Extra tip: make sure you use phrases to describe your // TODO: comments, such as // TODO: handle this error and the like. Phrases will appear in the problem list next to each warning. Credit for a little tidbit should go to Tim on the Cocos2D forums (found after Googling for a bit), I believe that its solution was originally intended for Xcode 3 and did not work if you had spaces along your path, my script is not here of these restrictions, but he should get full credit here from his original message .

+2
Apr 16 '14 at 19:44
source share

As npellow answer this my question, the appCode from JetBrains also made this possible. Thus, this may be another reason to use appCode instead of Xcode4, except that it will not be free later.

0
Apr 13 2018-11-11T00:
source share

My method:

enter the grammar error code in the previous line .....

After changing anything in another place, I can return to the previous place, because the grammar error line will show a red line in the right scroll bar. He indicates the place.

This is not elegant, but if there is a bookmark function, I am currently using

0
Mar 12 '14 at 6:04
source share

You can install the Xcode plugin called "XBookmark".

This plugin provides the following functions:

  • Toggle Bookmark
  • Show bookmarks
  • Next bookmark
  • Previous bookmark

How to install XBookmark:

  • Install Alcatraz.
  • Find XBookmark from the window-> Package Manager and click Install.
  • Restart Xcode.

Now you can see the bookmarked menu in the edit menu.

PS: This plugin is open source.

0
09 Oct '15 at 10:20
source share

Double-click the line number. It adds and disables the breakpoint, which you can find later in Breakpoint Navigator. Do not listen to the answers here that want you to change the code for this.

0
Jan 10 '17 at 7:45
source share



All Articles