D
D
Dmitry Belousov2018-01-09 00:18:39
Objective-C
Dmitry Belousov, 2018-01-09 00:18:39

How to make a template for Xcode that will add a new class and integrate it into existing ones?

Let's say there is a factory class MyFabric and a self-written File Template for Xcode.
When creating a new file with class A from a template, I also want to supplement the existing factory so as not to write the same type of code like

class MyFabric {

   func createObjA() -> A {
      return A()
   }

   //etc.
}

I found only a solution to these problems separately:
  1. You can write your own File Template for Xcode, which allows you to create a NEW class or NEW classes related to each other, because. they are generated at the same time.
  2. You can write your own Project Template for Xcode, which allows you to set the initial structure of the project.
  3. You can write your own Snippets that allow you to substitute pieces of code after the cursor.

I also want to add my own templates to the already existing Stotyboard. The File Template only allows you to create an entire Storyboard.
Perhaps my problem can be somehow solved by creating a plugin for Xcode, but I'm not sure.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Statusgman, 2018-01-18
@Statusgman

What you want to do, Xcode most likely will not be able to do out of the box.
There is an option to generate an extension for the factory in the generated file, but this is not very flexible and visual.
You can also take a look at the Generamba project . This is a code generator that can create entire application modules using templates.

B
briahas, 2018-01-18
@briahas

In short - no way.
I, for myself, made an application on a poppy that generates / parses / adds what is needed - where it is needed. ¯\_(ツ)_/¯

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question