top of page

XCode Code Snippet


Hi friends,

Here is a little trick for XCode beginners.

Have you ever wonder how you can improve your coding speed? Here is a basic trick for speed up, code snippet.

For example you are developing an app with SwiftUI, actually it doesn't matter SwiftUI, Swift, Obj-c, etc. You can even use snippets as creating comment blocks.

Here are steps for creating snippets.

  • Write block which will use as snippet

struct CodeSnippetDemo: View {
    var body: some View {
        Text("Hello, World!")
    }


    @ViewBuilder
    private func <#func name#>() -> some View {


    }
}


struct CodeSnippetDemo_Previews: PreviewProvider {
    static var previews: some View {
        CodeSnippetDemo()
    }
}
  • Select whole block

  • Then use menu as "Editor -> Create Code Snippet"

  • You can change information as you want. Top block field is name of snippet. Below block is holding platform informations. Trick point is "Completion" field. Because when you type what you used in completion field, XCode will ask you to complete with "that" snippet.







Son Yazılar

Hepsini Gör

Comentarios


bottom of page