This project only provides a viable method and implements it. It may not be simple and elegant, but I still hope it will help you.
Quickly create Swift base projects for componentization using Ruby scripts and template projects.
This project simplifies many steps based on my personal habits and needs, so it doesn't look so flexible or even difficult to adapt to suit your needs. But don't worry, "Usage Method" introduces the easiest steps to use, and by reading the source code, I believe you can also quickly transform the project to meet your needs.
Having said that, it is necessary to mention "my personal habits":
-
All of my projects are written in Swift, so this project does not provide Objective-C template code.
-
For each component, I will almost always create two projects:
ExampleModule
andExampleModuleRouter
, -
I use the same
Workspace
to manage the above two projects and useCocoaPods
to manage dependencies. -
ExampleModuleRouter
depends on URLNavigator as the module's routing component. -
ExampleModule
will depend onExampleModuleRouter
. For details, please refer to Podfile file of this project.
fork
this project, then modify the template project according to your needs (remember to replace the git url of the template project in the fast_create_module.rb with the url after yourfork
)
def clone_template
# Change to your git url
`git clone -b develop https://github.com/rakuyoMo/FastModule.git`
end
-
On GitHub or other code repository hosts, create your component repo and clone it.
-
Open the command line and
cd
to the directory of the project cloned in the second step. -
ruby fast_create_module.rb
or other methods to execute this script.
After a while, you will get a configured base project.
For example, now I need a component called ExampleModule
:
-
fork
this project and modify the URL in the fast_create_module.rb. -
Clone the project locally, for example to the desktop:
/Users/rakuyo/Desktop
-
Open GitHub and create a project called
ExampleModule
with an url like this:https://github.com/rakuyoMo/ExampleModule.git
-
Clone this project to the local, the path is probably like this:
/Users/rakuyo/Desktop/ExampleModule
-
cd /Users/rakuyo/Desktop/ExampleModule
-
ruby /Users/rakuyo/Desktop/FastModule/fast_create_module.rb
When the script finishes executing, if everything goes well, the project directory of ExampleModule
will look like this:
.
βββ LICENSE
βββ ExampleModule
β βββ ExampleModule
β βββ ExampleModule.xcodeproj
β βββ ExampleModuleTests
β βββ ExampleModuleUITests
βββ ExampleModule.xcworkspace
βββ ExampleModuleRouter
β βββ ExampleModuleRouter
β βββ ExampleModuleRouter.xcodeproj
β βββ ExampleModuleRouterTests
βββ Podfile
βββ Podfile.lock
βββ Pods
β βββ Headers
β βββ Local\ Podspecs
β βββ URLNavigator
β βββ URLNavigator.xcodeproj
βββ README.md
Speaking of this, it is also the result of exploration... At first, there was no idea about this demand. Later I learned about CocoaPods open source Xcodeproj.
Initially, I plan to use Xcodeproj
to create two projects, then configure the project content and add it to Workspace
. After practice, it was found to be very complicated...
Later, referring to the implementation of pod lib create
, use the template project instead.
That's it, I didn't use Xcodeproj
in the end, but the script has already been written, and that's it...
I'm just an iOS developer. I've barely touched Ruby except for some basic CocoaPods operations, so this project may have a lot of deficiencies.
If you find something wrong, or have any comments or suggestions, please feel free to give me issues
.
Finally, I sincerely hope that this project can help you.