Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New configurator and project layout, Carthage, SPM #210

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fulldecent
Copy link
Collaborator

@fulldecent fulldecent commented Jun 25, 2017

Introduction

This PR entirely replaces pod-template with the current contents of https://github.com/fulldecent/swift3-module-template.

Please help test with:

pod lib create --verbose --template-url='https://github.com/fulldecent/swift5-module-template.git' MyNewPodsName

A note on wording here

  • pod-template -- this project
  • template module -- a Swift/Obj-C module (i.e. a Pod) that has a name like "__PROJECT__" to demonstrate the name can be modified during the vendoring process
  • vendored module -- a Swift/Obj-C module (i.e. a Pod) with an actual usable name like "XLSwipeViewController"

Fundamental changes

The build system is fundamentally new. Here is how you will update pod-template with this PR:

  1. Update the file RECIPE.md to explain exactly how a person can start /from scratch/ using Xcode to create a template module.
  2. Follow the instructions in the recipe and save the results to the __PROJECT_NAME__ folder.

Here is how vendoring works with this PR:

  1. Run ./configure (you can call it from pod lib create, see above)
  2. The configure script will ask you for your new module's name (and other stuff)
  3. The configure script performs SIMPLE FIND AND REPLACE to transform the template module into the vendored module.

That's it. It's dead simple.

New features

In addition to this simpler vendoring system, the actual templated module has lots of great new stuff.

BUILD SYSTEM

  • This project is reproducible and easier to maintain. Actually the only important file in this project is RECIPE.md and it is self-documenting. Therefore, anybody can follow the recipe and derive the contents of __PROJECT_NAME__.
  • The configure script is dead simple. I wrote it and I don't even know Ruby.

FUN TO USE

  • Your new pod works. After you run pod lib create ... you get a runnable project that is actually slightly useful.

BEST PRACTICES

The vendored module will now follow best practices curated from several Cocoa development leaders.

  • Ability to be used from Swift Package Manager, CocoaPods and Carthage
  • Clean folder structure
  • MIT license
  • Testing as a standard
  • Turnkey access to Travis CI
  • Semantic versioning and a CHANGELOG

@fulldecent fulldecent changed the title Merge in fulldecent/swift3-module-template New configurator and project layout, Carthage, SPM Jun 25, 2017
@fulldecent
Copy link
Collaborator Author

fulldecent commented Jun 25, 2017

A couple extra notes here.

  • A big part of this new ./configure is that you do not get to choose between different types of template modules. For example do you want view testing?. I defend this choice, even if just because the RECIPE improves this project so much. Now if users demand different types of templates (or if a an issue is opened here that we do not to implement for everyone) then this is not a problem! Just make a fork of this repository, make your own RECIPE and then have people use it with the --template-url option that CocoaPods already has!

  • Maybe the README.md should be updated for branding and to address the CocoaPod user audience rather than the wider Swift programmer audience I had originally written to. SUGGESTIONS WELCOME!

Copy link
Member

@orta orta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like where this is heading, blockers for me are:

  • Lack of direction on CocoaPods support
  • Folder structure after you run it still has template in it
  • Bit of tone stuff, but that's totally reasonable

@@ -1,40 +0,0 @@
# CocoaPods Code of Conduct
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you bring this file back please 👍


Copyright (c) 2013 - 2014 CocoaPods Dev Team
Copyright (c) 2016 William Entriken
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this one back, I'm happy to have this CP Dev Team, and William Entriken instead though


### Using CocoaPods to manage dependencies for your example app

You distribute an example app with your new Swift module to show that it works. You may also decide to add UI tests to your example app and some people like to use testing frameworks for those UI tests. If you would like to use CocoaPods to manage the dependencies of your example app, please see the discussion at https://github.com/fulldecent/swift3-module-template/issues/8.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This worries me that CP support is not something you can do out of the box. It feels like something I would expect using pod lib create that I can just define the dependencies and carry on. Perhaps it can be a question?

@@ -0,0 +1,34 @@
language: objective-c
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wary that this is considerably more complex than the previous travis file, understanding it requires a lot more knowledge about the shell and Travis CI. The majority of CocoaPods users probably don't know this stuff, can it be simplified?

pod lib lint;
fi

- CheckCocoaPodsQualityIndexes.rb __PROJECT_NAME__
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this just adds noise, it should probably go, most people are fine to check the website

// __PROJECT_NAME__Label.h
// __PROJECT_NAME__
//
// Created by Dmytro Zozulia on 23.06.17.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name sneaked in, and the real date ^

'__TODAYS_DATE__' => Date.today.strftime(Env.date_format_string),
'__TODAYS_YEAR__' => "#{Date.today.year}",
'__GITHUB_USERNAME__' => 'awesome_octocat'
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tone-wise this defaults will have to change too ;)

replace_variables_in_files(substitutions)
replace_variables_in_file_names(substitutions)

puts "DONE, your project is now ready to use in the OUTPUT/ folder"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance we can drop the OUTPUT folder to be their project name? I'd expect this to create the folder for the project, but not inside another folder - having an OUTPUT folder means you'll always have to move it somewhere.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just run this, it creates a really weird folder structure:

$ tree MyNewPodsName

MyNewPodsName/
├── LICENSE
├── OUTPUT
│   └── MyNewPodsName
│       ├── CHANGELOG.md
│       ├── CONTRIBUTING.md
│       ├── LICENSE
│       ├── MyNewPodsName.podspec
│       ├── MyNewPodsName.xcodeproj
│       │   ├── project.pbxproj
│       │   ├── project.xcworkspace
│       │   │   └── contents.xcworkspacedata
│       │   └── xcshareddata
│       │       └── xcschemes
│       │           └── MyNewPodsName.xcscheme
│       ├── MyNewPodsName.xcworkspace
│       │   └── contents.xcworkspacedata
│       ├── Package.swift
│       ├── README.md
│       ├── Resources
│       │   └── wk.png
│       ├── Source
│       │   ├── Info.plist
│       │   ├── MyNewPodsName.h
│       │   ├── MyNewPodsName.swift
│       │   ├── MyNewPodsNameLabel.h
│       │   └── MyNewPodsNameLabel.m
│       ├── Tests
│       │   ├── CheckCocoaPodsQualityIndexes.rb
│       │   ├── Info.plist
│       │   └── MyNewPodsNameTests.swift
│       └── iOS\ Example
│           ├── Source
│           │   ├── AppDelegate.swift
│           │   ├── Assets.xcassets
│           │   │   └── AppIcon.appiconset
│           │   │       └── Contents.json
│           │   ├── Base.lproj
│           │   │   ├── LaunchScreen.storyboard
│           │   │   └── Main.storyboard
│           │   ├── Info.plist
│           │   └── ViewController.swift
│           └── iOS\ Example.xcodeproj
│               ├── project.pbxproj
│               ├── project.xcworkspace
│               │   └── contents.xcworkspacedata
│               └── xcshareddata
│                   └── xcschemes
│                       └── iOS\ Example.xcscheme
├── Package.swift
├── README.md
├── Recipe.md
├── __PROJECT_NAME__
│   ├── CHANGELOG.md
│   ├── CONTRIBUTING.md
│   ├── LICENSE
│   ├── Package.swift
│   ├── README.md
│   ├── Resources
│   │   └── wk.png
│   ├── Source
│   │   ├── Info.plist
│   │   ├── __PROJECT_NAME__.h
│   │   ├── __PROJECT_NAME__.swift
│   │   ├── __PROJECT_NAME__Label.h
│   │   └── __PROJECT_NAME__Label.m
│   ├── Tests
│   │   ├── CheckCocoaPodsQualityIndexes.rb
│   │   ├── Info.plist
│   │   └── __PROJECT_NAME__Tests.swift
│   ├── __PROJECT_NAME__.podspec
│   ├── __PROJECT_NAME__.xcodeproj
│   │   ├── project.pbxproj
│   │   ├── project.xcworkspace
│   │   │   └── contents.xcworkspacedata
│   │   └── xcshareddata
│   │       └── xcschemes
│   │           └── __PROJECT_NAME__.xcscheme
│   ├── __PROJECT_NAME__.xcworkspace
│   │   └── contents.xcworkspacedata
│   └── iOS\ Example
│       ├── Source
│       │   ├── AppDelegate.swift
│       │   ├── Assets.xcassets
│       │   │   └── AppIcon.appiconset
│       │   │       └── Contents.json
│       │   ├── Base.lproj
│       │   │   ├── LaunchScreen.storyboard
│       │   │   └── Main.storyboard
│       │   ├── Info.plist
│       │   └── ViewController.swift
│       └── iOS\ Example.xcodeproj
│           ├── project.pbxproj
│           ├── project.xcworkspace
│           │   └── contents.xcworkspacedata
│           └── xcshareddata
│               └── xcschemes
│                   └── iOS\ Example.xcscheme
└── configure

37 directories, 61 files

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Template should clean up after itself ideally, the rest of those files are an implementation detail.

'__AUTHOR NAME__' => 'Mr McAwesome',
'__TODAYS_DATE__' => Date.today.strftime(Env.date_format_string),
'__TODAYS_YEAR__' => "#{Date.today.year}",
'__GITHUB_USERNAME__' => 'awesome_octocat'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do people really care about adding the org name and bundle ID? Also, it should just skip the date + year.

This CLI output feels really mechanical:
screen shot 2017-06-25 at 07 38 22

In contrast to

screen shot 2017-06-25 at 07 45 49

screen shot 2017-06-25 at 07 47 15

I think we can improve the onboarding a bit here. Though, that said, I'm probably going to delete the guide unless you want to update this: https://guides.cocoapods.org/making/using-pod-lib-create.html


3. Select Product -> Run

You should see a big white king. That means it worked!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be good to keep the ability to edit your README/Podspec inside Xcode too:

E.g.
screen shot 2017-06-25 at 08 00 18

( Current )
screen shot 2017-06-25 at 07 59 54

@orta
Copy link
Member

orta commented Jun 25, 2017

I don't think:

Just make a fork of this repository, make your own RECIPE and then have people use it with the --template-url option that CocoaPods already has

Is a good enough trade-off TBH for not being comprehensive about how people end up using the template, this CP template gets about a hundred uses a day during the week and to expect each user to go research all the forks to find one that matches their particular spec seems off without building proper infrastructure for that.

@fulldecent
Copy link
Collaborator Author

Right now swift4-module-template is doing well. But it would be great to harmonize with this project.

Could you please advice what type of PR might be acceptable here?

@fulldecent
Copy link
Collaborator Author

Just updating to say that Swift 4 module template is still actively used.

@fulldecent
Copy link
Collaborator Author

Updating for new URL. This now supports Swift 5.

@fulldecent
Copy link
Collaborator Author

The main remaining unmerged feature here is the recipe.

Is there an interest in rebasing, squashing this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants