Move code shortcuts

Move up and down

Up: Command + option + [Down: Command + option +] Left: Command + [right: Command +]Copy the code

Replace variable names in variable scope

The cursor needs to hover over the variable name

command + control + e  
Copy the code

Reformat code

Control + I for all of them

control + i
Copy the code

Common Mac commands

  • Mac is based on Unix system, so there is no CD disk concept (iOS also), so support Unix instructions
PWD: view the directory where the current file resides ls: View the list of files in the folder CD + XXX: enter the 'XXX' file mkdir + XXX: create a specified folder rmdir + XXX: delete the specified folder CD.. Cat + File name: view the file rm + xx.xx: Delete the fileCopy the code
  • Fixed an issue where MacOs could not open XXX because the developer could not be verified
Sudo SPCTL --master-disableCopy the code

How Xcode works

Xcode is executed using the LLVM compiler (the virtual machine ClANG front end is designed to compile code (translate code)).

Link to our own code: the cc file name combines its own code with the system and other dependent code groups to produce an executable file

You can also run the preceding command to separate multiple files with Spaces eg: cc -c main.c jk.

The following is an example:

  • Create a main.c file
#include<stdio.h>
int main(a) {
    printf("say hello\n");
    return 0;
}
Copy the code
  • Enter a command on the terminal
cat main.c
Copy the code
  • The output is as follows:
#include<stdio.h>
int main() {
    printf("say hello\n");
    return 0;
}
Copy the code
  • Next, simulate Xcode to compile and execute instructions
Cc -c main.c ---- main. I // Replace all preprocessing commands (such as macros) in the file ---- main.s // compile ---- main.o // binary filesCopy the code
  • A binary file main.o is generated

支那

  • Execute the command
cc main.o
Copy the code

Link your own binary file main.o with the binary of the dependent file to generate an exec icon!Executable file ‘a.out’

  • Execute the command
./a.out The following output is displayed: 'say hello'Copy the code

Show and hide files

The command

Display hidden files: Defaults Write com.apple.Finder AppleShowAllFiles YES; KillAll Finder does not show hidden files: defaults write com.apple.Finder AppleShowAllFiles NO; KillAll FinderCopy the code

shortcuts

command+shift+.
Copy the code