Xcode tricks

Xcode

  1. Ctrl+ 6You can view the properties and methods of the current class, and you can also enter filters to quickly jump to the properties or methods you want

  2. Select menu Window-> Tile Window to Left/Right of Screenthis allows Xcode and the simulator to fill the left and right sides of the full screen, which can be adjusted for your own use, or you can let Xcode match other windows

    image-20210701180850789

  3. Cmd+ Ctrl+ Alt+ FFix all the following errors, instead of one by one

    image-20210630143915605

  4. Cmd+ Shift+ OSearch for the class or method you want, press returnto jump quickly, you can also add :and specify after the class name to 行数字jump to the specific line of the class

  5. Cmd+ Ctrl+ or Cmd+ Ctrl+ can switch classes/files accessed before and after

  6. Press and hold Cmd, move the mouse to {will highlight the matching }convenient check match

    Press and hold Cmd, click on the class name or method name, and the operation menu will pop up (jump to definition/help document/add comment/add parameter, etc.)image-20210628172613528

  7. ctrl+ Icode typesetting, you can cmd+ Aselect all and then ctrl+ Itypesetting

  8. Cmd+ [0~9] 1 ~ 9 toggle left navigation panel 0 show/hide panel

  9. Cmd+ Alt+ [0~3]1~3 toggle right navigation panel 0 show/hide panel

  10. Cmd+ Alt+ /Select method name or variable to quickly add documentation comments

  11. Cmd++ CtrlQuickly Erename variables

2021-06-30 10-06-24. 2021-06-30 10_12_25
  1. Alt+ ClickHold Altand click a class in the left panel, another class panel will open
  2. Cmd+ Alt+ JLocate to the filter input box at the bottom of the left, you can search for classes, click the alarm clock icon on the right to display the recently opened class files, and click the icon on the far right to display the class files that you have changed but have not yet submitted.
  3. Alt+ or Alt+ can move word by word in a line, plus Shiftit is selected
  4. Cmd+ or Cmd+ can move to the head or tail in a line, and Shiftit is selected when combined with
  5. Cmd+ LCall up the input box, enter the number of lines, press Enter, and jump directly to the specified line
  6. Cmd+ Shift+ JShow the project location where the class is located
  7. AltPress and hold Altto select different lines, you can edit multiple lines at the same time
2021-06-30 11-53-46. 2021-06-30 11_54_41
  1. Cmd+ TOpen a new Tab, you can separate different classes for easy switching

  2. Cmd+ Shift+ [or Cmd+ Shift+ ]Switch the class of the same Tab left and right

  3. Ctrl+ 2Show recently visited classes as a list

    image-20210701085608397

StoryBoard XIB

  1. AltSelect a view, hold down Altand move the mouse to view the margins around the view and other views

  2. ShiftYou can hold down Shift, select multiple views, and add constraint layouts at the same time

  3. Alt + Shift + Click 可以查看选中视图所在层级

  4. Cmd + Shift + L 打开视图库面板

  5. Alt 按住Alt 拖到视图时 视图库面板保持打开

  6. 可以通过如图设置All Properties,锁定不能更改

    image-20210630111104381
  7. Shift 添加约束的时候,如图按住Shift可以选择多个约束一起添加

    2021-07-01 08-47-46. 2021-07-01 08_48_09
  8. Cmd 当你想拖动一个视图A叠加到另一个视图的B上面,可以按住Cmd拖动,这样就会A在B上面而不是里面

调试

  1. Cmd + Shift + Y 显示/隐藏 控制台
  2. Cmd + Shift + C 光标切换到控制台
  3. Cmd + K 清空控制台
  4. Cmd + \ 增加/删除断点
  5. Cmd + Y 断点生效/失效
  6. Fn + 6 step over 跳过
  7. Fn + 7 step in 跳进
  8. Fn + 8 step out 跳出

View Debugging

  1. Shift + Cmd + D 选中一个View,按下Shift + Cmd + D,可以快速定位在左侧栏中

Swift Notes

  1. 使用 //MARK: - 区分开一个类的代码

image.png

  1. // FIXME: - // TODO: - 可以标记该方便待修复,或者是待实现,这个Xcode没有任何标记,只能通过搜索相关字符找到对应的待修复或者待实现方法

  2. #warning("Not actually yet.") Xcode会有相应的警告提示

image.png

  1. #error("Not actually yet") Xcode会有相应错误的提示,这时会编译错误

image.png

  1. @available(swift, deprecated: 5.3, message: "Hopefully it's fixed now?")

You can mark the class or method has been deprecated in Swift 5.3, Xcode just warns, this can be used according to the actualimage.png

  1. @available(swift, obsoleted: 5.3, message: "Hopefully it's fixed now?")

The same is deprecated, but Xcode prompts an errorimage.png

emulator

  1. Cmd+ Kpop-up keyboard
  2. Cmd+ Shift+ ACan switch light darkmodes
  3. Cmd+ Hhide
  4. Cmd+ Llock screen
  5. Cmd+ Shift+ HUnlock or go back to the home page, double-click Hto pop up the task list
  6. Cmd+ 1// 2resize 3screen
  7. Cmd+ / clockwise / counterclockwise rotation
  8. Cmd+ / Adjust the volume
  9. Cmd+ Sscreenshot
  10. Cmd+ Ctrl+ CScreenshot and copy
  11. Alt+ ShiftDrag gesture with mouse
  12. AltZoom with the mouse
  13. Cmd+ MMinimize to desktop menu bar

tool

  1. XcodeProjects

It can easily perform Pod operations, clear derived data, customize commands, etc., see more here

Mac

  1. Cmd+ Shift+ .Show hidden files

More

  1. Xcode Debug debugging summary
  2. www.hackingwithswift.com/articles/22…
  3. www.hackingwithswift.com/articles/17…

Guess you like

Origin juejin.im/post/6979772519070826504