An opinionated starting point for awesome, reusable Swift 5 modules

Overview

Build Status

Swift 5 Module Template

Use this template as a starting point for any Swift 5 module that you want other people to include in their projects.

STATUS: This template is ready and works in production code, compatible with Xcode 12.4 (12D4e)

Swift 5 Module directory layout

Features

Your new Swift 5 module will immediately have working, compilable code, and all these features:

  • 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
  • Included example/demo app using SwiftUI

We make the assumption you are using an Xcode project to manage your code.

How to use this

Clone or download a release and run the ./configure program. It will ask you some questions and generate a project.

Or if you have CocoaPods installed, you can alternatively use:

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

You then add all the interesting features you want your module to have.

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/swift5-module-template/issues/8.

Automating the configure script

To skip interactive prompts in the ./configure script, use these environment variables:

Template variable Environment variable
__PROJECT_NAME__ SMT_PROJECT_NAME
__ORGANIZATION NAME__ SMT_ORGANIZATION_NAME
com.AN.ORGANIZATION.IDENTIFIER SMT_COM_AN_ORGANIZATION_IDENTIFIER
__AUTHOR NAME__ SMT_AUTHOR_NAME
__TODAYS_DATE__ SMT_TODAYS_DATE
__TODAYS_DATE__ (date format) SMT_DATE_FORMAT_STRING Note: this will ask you for today’s date but it will use this format in the template.
__TODAYS_YEAR__ SMT_TODAYS_YEAR
__GITHUB_USERNAME__ SMT_GITHUB_USERNAME

For example, you may use: export SMT_ORGANIZATION_NAME='Awesome Org' before running ./configure.

How it works

┌─────────────┐              ┌─────────────┐              ┌─────────────┐
│     Use     │              │    Save     │              │Use your own │
│    Xcode    │─Save recipe─▶│  template   │─./configure─▶│   module    │
└─────────────┘              └─────────────┘              └─────────────┘
       ▲              ▲             ▲               ▲            ▲       
                                                                         
       │              │             │               │            │       
        Contributors to this project          End users of this project

Contributing

See the file Recipe.md for the complete steps (e.g. Open Xcode, make new project, click here, type that, …) of how we made the template.

Comments
  • Pod dependencies

    Pod dependencies

    How would you go about creating a pod with dependencies? Currently there is no use of CocoaPods in either the module project or the example app project.

    opened by djbe 12
  • Improvements for pod dependencies [DISCUSSION, HELP REQUESTED]

    Improvements for pod dependencies [DISCUSSION, HELP REQUESTED]

    This template is great, it should be the default of pod lib create as soon as possible. The current template provided by CocoaPods is very confusing.

    I've changed the project generated by the swift3-module-template a bit so that it is easier to create a pod that has dependencies on other pods (see issue https://github.com/fulldecent/swift3-module-template/issues/8). The podfile in the root of my project looks like this:

    platform :ios, '9.0'
    inhibit_all_warnings!
    use_frameworks!
    
    workspace 'Abc'
    
    target 'iOS Example' do
      project 'iOS Example'
    
      pod 'Abc', path: '.'
    end
    
    target 'Abc' do
      project 'Abc'
    
      pod 'Dependency1'
      pod 'Dependency2'
    
      target 'AbcTests'
    end
    

    It will create one workspace that contains three projects:

    • Pods
    • iOS Example
    • Abc

    The pod spec looks like this:

    Pod::Spec.new do |s|
      s.name = 'Abc'
      s.version = '0.1.0'
      s.license = { :type => 'MIT', :file => 'LICENSE' }
      s.summary = 'The greatest pod ever made'
      s.description = <<-DESC
          Let me tell you about the greatest pod ever made.
        DESC
      s.homepage = 'https://about.abc'
      s.authors = { 'Abc' => '[email protected]' }
      s.source = { :git => 'https://github.com/abc/abc.git', :tag => s.version }
    
      s.ios.deployment_target = '8.0'
      s.source_files = 'Abc/Source/**/*.swift'
    
      s.dependency 'Dependency1', '~> 1.2.0'
      s.dependency 'Dependency2', '~> 2.3.0'
    end
    

    When you add or remove files from your pod, just run pod update and the updated pod will be used.

    My folder looks like this:

    .git
    .gitignore
    .swift-version
    .swiftlint.yml
    .travis.yml
    CHANGELOG.md
    CONTRIBUTING.md
    LICENSE
    Package.swift
    Podfile
    Podfile.lock
    Pods
    README.md
    Abc.podspec
    Abc.xcodeproj
    Abc.xcworkspace
    Abc
      - Source
      - Resources
    AbcTests
      - Resources
    AbcTestsHost
    iOS Example
      - Source
      - Resources
    iOS Example.xcodeproj
    

    What do you guys think?

    opened by yvbeek 7
  • Adding ObjC file to template

    Adding ObjC file to template

    Hey,

    Thanks a lot for merging my pull request https://github.com/fulldecent/swift3-module-template/pull/35

    I have a question after merging - should I add one ObjC class to the template, so it would be obvious for users how to add objc files and have interoperability with swift code? What do you think?

    P.S. I think that this template can be universal for both languages. Ofc example and tests will still be in Swift, which is not a problem for me.

    opened by dm-z 4
  • Update Package.swift to use Swift 5+

    Update Package.swift to use Swift 5+

    Upgrade Package.swift so it can take advantage of the latest features.

    • Use swift-tools-version:5+ instead of swift-tools-version:4.2
    • Add "platform" parameter to the package declaration
    • Add "swiftLanguageVersions" parameter to the package declaration

    Documentation references: https://developer.apple.com/documentation/swift_packages/package https://developer.apple.com/documentation/swift_packages/platform https://developer.apple.com/documentation/swift_packages/package/3197887-swiftlanguageversions https://developer.apple.com/documentation/swift_packages/swiftversion

    opened by yaroslav-zhurakovskiy 3
  • Fixed tests target (path to Info.plist was wrong, so tests didn't run)

    Fixed tests target (path to Info.plist was wrong, so tests didn't run)

    When I created a project using "./configure", then opened Xcode and hit "Cmd+U" (to run the tests). Xcode can't find Info.plistor the tests, because in a base project it is located in Tests folder, but in project.pbxproj it was "__PROJECT_NAME__Tests/Info.plist". Removing "PROJECT_NAME" in plist path fixed the problem.

    P.S. Thanks a lot for this template - very useful.

    opened by dm-z 3
  • Unable to Drag and drop 'xxProjectxNamexx' in to iOS Example.

    Unable to Drag and drop 'xxProjectxNamexx' in to iOS Example.

    At Step: VI. Make your iOS Example application depend on your module

    I am unable to drag and drop 'xxProjectxNamexx' into Opened 'iOS Example' as a separate package. When I do so it appears with int the iOS Example Project and not as a separate package

    Screenshot 2021-02-26 at 9 16 46 AM

    I am trying to create a UIKit Version of the template.

    opened by johannfza 2
  • Rename to swift4-module-template

    Rename to swift4-module-template

    Rename this project to swift4-module template. The new Xcode just hit Gold Master so it is GO time.

    Alternatives considered:

    • Make a new project -- this is stupid because nobody wants to make new swift3 projects once Xcode 9 is out. AND because this project is only about making NEW projects.

    Work plan:

    • [x] Rename the project
    • [x] Update the REMOTES on my computer
    • [x] Ask people linking to the old project to now link to the new one
    • [x] s/oldurl/newurl/g in the GitHub

    Old links, care of AHREFS:

    • Reach out to them to offer updated link to this project.
    • [x] http://cocoadocs.org/docsets/FDWaveformView/2.2.1/
    • [x] http://cocoadocs.org/docsets/FDWaveformView/2.2.1/index.html
    • [x] http://cocoadocs.org/docsets/SwiftVer/1.0.1/
    • [x] http://cocoadocs.org/docsets/ZHTableViewGroupSwift/0.2.0/
    • [x] http://cocoadocs.org/docsets/ZHTableViewGroupSwift/0.2.0/index.html
    • [x] http://cocoapods.org/pods/FDWaveformView
    • [x] http://cocoapods.org/pods/ZHTableViewGroupSwift
    • [x] http://getawesomeness.herokuapp.com/get/swift
    • [x] http://hnpaper.forge.partlab.io/u/fulldecent
    • [x] http://uiview.com/project/93/
    • [x] http://www.alexruperez.com/entries/2014-matteocrippa-awesome-swift
    • [x] http://www.alexruperez.com/repos/71-awesome-swift
    • [x] https://cocoapods.org/pods/FDWaveformView
    • [x] https://cocoapods.org/pods/ZHTableViewGroupSwift
    • [x] https://devhub.io/repos/SwiftCarlos-awesome-swift
    • [x] https://devhub.io/repos/candostdagdeviren-awesome-swift
    • [x] https://devhub.io/repos/fulldecent-swift3-module-template
    • [x] https://devhub.io/repos/jonkykong-awesome-swift
    • [x] https://devhub.io/repos/malcommac-awesome-swift
    • [x] https://devhub.io/repos/matteocrippa-awesome-swift
    • [x] https://devhub.io/repos/omaralbeik-awesome-swift
    • [x] https://devhub.io/repos/rchatham-awesome-swift
    • [x] https://devhub.io/repos/ytakzk-awesome-swift
    • [x] https://devhub.io/zh/repos/SwiftCarlos-awesome-swift
    • [x] https://devhub.io/zh/repos/candostdagdeviren-awesome-swift
    • [x] https://devhub.io/zh/repos/jonkykong-awesome-swift
    • [x] https://devhub.io/zh/repos/malcommac-awesome-swift
    • [x] https://devhub.io/zh/repos/matteocrippa-awesome-swift
    • [x] https://devhub.io/zh/repos/omaralbeik-awesome-swift
    • [x] https://devhub.io/zh/repos/rchatham-awesome-swift
    • [x] https://devhub.io/zh/repos/ytakzk-awesome-swift
    • [x] https://getawesomeness.herokuapp.com/get/swift
    • [x] https://github.oldjpg.com/repository/47279041
    • [x] https://libraries.io/github/fulldecent/swift3-module-template
    • [x] https://libraries.io/github/pavangandhi/SwiftNew
    • [x] https://news.ycombinator.com/item?id=12515713
    • [x] https://porter.io/daily/2016-09-16/
    • [x] https://porter.io/github.com/fulldecent/swift3-module-template
    • [x] https://porter.io/github.com/matteocrippa/awesome-swift
    • [x] https://project-awesome.org/matteocrippa/awesome-swift
    • [x] https://recordnotfound.com/awesome-swift-marmelroy-89681
    • [x] https://recordnotfound.com/awesome-swift-matteocrippa-1387
    • [x] https://recordnotfound.com/swift3-module-template-fulldecent-137320
    • [x] https://swift.zeef.com/robin.eggenkamp
    opened by fulldecent 2
  • Crash when using Swift standard libraries

    Crash when using Swift standard libraries

    I've found an interesting crash, and I'm not sure what would be an ideal solution to fix it.

    So steps to reproduce:

    1. Generate a project from template
    2. Add function to YourProjectName.swift func crushFunc() { print("Let's crash!") }
    3. Compile the project for target "iOS Example" or "YouProjectNameTests", you don't even need to call a function, it will crash on launch

    To fix this, I had to turn on build setting "Always Embed Swift Standard Libraries" -> YES for both targets (Example and Tests), otherwise it will crash on launch. But this fix will generate warnings if user wants to add Pod Dependencies to the project (Debug + Release for Example and Test targets - 4 combined warning when installing cocoapods):

    [!] The iOS Example [Debug] target overrides the ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES build setting defined in ../Pods/Target Support Files/Pods-iOS Example/Pods-iOS Example.debug.xcconfig'. This can lead to problems with the CocoaPods installation - Use the$(inherited)` flag, or - Remove the build settings from the target.

    opened by dm-z 2
  • Automate search-replace steps in recipe

    Automate search-replace steps in recipe

    Just like in PR #30, this PR tries to leverage the (macOS flavor of) find and sed to automate the execution of steps 5.1.1 and 5.1.2. in the recipe, ultimately merging both into a single step of 5.1.

    Hopefully, this saves template maintainers a bit of time when executing those recipe steps, and seems less tedious to me than the manual process. It also loses the dependency on the text editor.

    opened by claui 2
  • Remove development team ID

    Remove development team ID

    This PR removes all occurrences of the development team ID from project.pbxproj files, which would lead to unsightly warnings if Xcode does not know that particular team ID.

    The PR also updates the recipe to reflect this change. Since the recipe already assumes we’re on macOS, we can use (the macOS flavors of) find and sed to find and replace such IDs via Terminal.app. I feel this is more convenient than manual search-and-replace; besides, no text editor is needed while executing that step.

    opened by claui 2
  • .travis.yml file has some issues. Also an issue with the location of info.plist for the test target.

    .travis.yml file has some issues. Also an issue with the location of info.plist for the test target.

    1. The WORKSPACE variable currently is set to WORKSPACE="__PROJECT_NAME__.xcworkspace"

    2. Similarly, IOS_FRAMEWORK_SCHEME="__PROJECT_NAME__"

    3. I had to set my DESTINATION="platform=iOS Simulator,OS=10.2,id=E40727B3-41FB-4D6E-B4CB-BFA87109EB12" for the destination to not be invalid and cause failure.

    4. The last line being CheckCocoaPodsQualityIndexes.rb ProjectName fails to find the file. I currently am trying ruby Tests/CheckCocoaPodsQualityIndexes.rb. But travis is running slow for some reason at the moment.

    5. The test target is looking for the info.plist file at ProjectNameTests/info.plist while it's actually at Tests/info.plist. This has to be changed in the test target's build settings.

    opened by lanza 2
  • Support for Non-ASCII characters

    Support for Non-ASCII characters

    The ./configure script works great, but I had to change the author name from the usual "Nicolás Miari" to "Nicolas Miari" (no diactritics) to get it to work, otherwise it would fail with:

    Traceback (most recent call last):
    	8: from ./configure:107:in `<main>'
    	7: from ./configure:13:in `replace_variables_in_files'
    	6: from ./configure:13:in `glob'
    	5: from ./configure:17:in `block in replace_variables_in_files'
    	4: from ./configure:17:in `open'
    	3: from ./configure:19:in `block (2 levels) in replace_variables_in_files'
    	2: from ./configure:19:in `each'
    	1: from ./configure:20:in `block (3 levels) in replace_variables_in_files'
    ./configure:20:in `gsub!': incompatible character encodings: ASCII-8BIT and UTF-8 (Encoding::CompatibilityError)
    

    I guess I can go back to the generate files and fix it, but it would be nice to have.

    opened by nicolas-miari 0
  • Update recipe images

    Update recipe images

    The images in the recipe folder show an example of using Xcode.

    The pictures illustrate an old version of Xcode.

    Update the pictures to show the same thing but using the current version of Xcode (with default themes, font sizes, etc.)

    opened by fulldecent 0
  • Move from Travis CI to GitHub Actions

    Move from Travis CI to GitHub Actions

    I would like to promote GitHub Actions as the new, better-maintained alternative to Travis CI.

    GitHub Actions appears to be the new best practice.

    Work plan:

    • [ ] Remove .travis.yml in the project folder
    • [ ] Add corresponding GitHub Actions CI to the project folder
      • [ ] Please study https://github.com/Alamofire/Alamofire/blob/master/.github/workflows/ci.yml
      • [ ] Please also include our extra feature (quality checks)
    • [ ] Update the recipe so that the correct GitHub Actions CI is now included (see the curl commands)
    • [ ] Test that it works:
      • [ ] Complete the recipe, ensure that the generated product folder matches the files already in your pull request
        • [ ] Attach screenshot of empty diff -r
      • [ ] Deploy the generated product folder as a new repository on GitHub and ensure that the GitHub Action was successfully triggered
        • [ ] Attach link to the GitHub Action CI task that was triggered
    help wanted 
    opened by fulldecent 1
Releases(13.1)
Owner
William Entriken
EN/中文 [email protected]
William Entriken
An opinionated starting point for awesome, reusable Swift 5 modules

Swift 5 Module Template Use this template as a starting point for any Swift 5 module that you want other people to include in their projects. STATUS:

William Entriken 419 Dec 5, 2022
A starting point to create CLI utilities with swift

cli tuist template A starting point to create CLI utilities with swift Installation Just create a Tuist folder and a Templates folder inside it. Creat

humdrum 6 May 3, 2022
Use this template as a starting point for any Swift 5 module that you want other people to include in their projects

Swift 5 Module Template Use this template as a starting point for any Swift 5 mo

James Knipe 0 Dec 28, 2021
BCSwiftTor - Opinionated pure Swift controller for Tor, including full support for Swift 5.5 and Swift Concurrency

BCSwiftTor Opinionated pure Swift controller for Tor, including full support for

Blockchain Commons, LLC — A “not-for-profit” benefit corporation 4 Oct 6, 2022
A simple and opinionated AES encrypt / decrypt Objective-C class that just works.

AESCrypt-ObjC - Simple AES encryption / decryption for iOS and OS X AESCrypt is a simple to use, opinionated AES encryption / decryption Objective-C c

Gurpartap Singh 782 Oct 12, 2022
The starting file for the 360iDev "It's Widget Time" workshop.

360iDevWidgets_start The starting file for the 360iDev "It's Widget Time" workshop. Syllabus This is a workshop to introduce you to adding widgets to

Steve Lipton 5 Dec 29, 2021
An application where users can simulate trading stocks with a starting balance of fake money.

Eighth Wonder Finance Table of Contents Overview Product Spec Video Walkthrough Wireframes Schema Overview Description An application where users can

Josh Harris 0 Dec 5, 2021
A simple GUI for starting/stopping our various local development environments

EnvironmentLauncher A simple GUI for starting/stopping SchoolMint's various local development environments Before you begin, some notes This is a WIP

Francis Scheuermann 1 May 17, 2022
**`withCheckedContinuation`'s body will run on background thread in case of starting from main-actor.**

ConcurrencyContinuationReproduce Differences of Concurrency behaviors between Xcode 14.0 and 14.1 Xcode 14.0 iOS 13+: Runs on main (inherited same con

Hiroshi Kimura 4 Dec 20, 2022
Swift Modules, a swift module (or package) manager

Swift Modules The Swift Modules manager similar to the JavaScript world's npm and bower

Jan Kuča 60 Jun 3, 2021
Interface-oriented router for discovering modules, and injecting dependencies with protocol in Objective-C and Swift.

ZIKRouter An interface-oriented router for managing modules and injecting dependencies with protocol. The view router can perform all navigation types

Zuik 631 Dec 26, 2022
A toolbox of AI modules written in Swift: Graphs/Trees, Support Vector Machines, Neural Networks, PCA, K-Means, Genetic Algorithms

AIToolbox A toolbox of AI modules written in Swift: Graphs/Trees, Linear Regression, Support Vector Machines, Neural Networks, PCA, KMeans, Genetic Al

Kevin Coble 776 Dec 18, 2022
Swift modules for game development.

Introduction I have been making iOS games with Swift, SceneKit, and SpriteKit since 2015 when I was in high school. After working on over a hundred pr

Kelin Lyu 3 May 29, 2022
Declarative view styling in Swift. Inspired by CSS modules.

Gaikan gives you powerful styling capabilities using a declarative DSL in Swift. Inspired by React: CSS in JS and CSS modules. To style UIView(s) just

null 141 Aug 23, 2021
decoupling between modules in your iOS Project. iOS模块化过程中模块间解耦方案

DecouplingKit 中文readme Podfile platform :ios, '7.0' pod 'DecouplingKit', '~> 0.0.2' DecouplingKit, decoupling between modules in your iOS Project. D

coderyi 139 Aug 23, 2022
Custom MacBook login screen and pam modules using multipeer connectivity and usb hardware checks with iOS app for sign in.

Custom MacBook login screen and pam modules using multipeer connectivity and usb hardware checks with iOS app for sign in.

null 2 Aug 17, 2022
Used MVVM with with clear seperation to each modules

Classifieds Deployment Target: iOS 14.0, Xcode Version: Xcode 12.0 + Notes Used MVVVM with with clear seperation to each modules. Noted that image url

Muhammed Azharudheen 1 Nov 16, 2021
Modules to use with The Composable Architecture

TCA-Modules Modules to use with The Composable Architecture You can run Examples

Stanislau Parechyn 1 May 20, 2022
React-native-photo-editor - Photo editor using native modules for iOS and Android

?? Image editor using native modules for iOS and Android. Inherit from 2 available libraries, ZLImageEditor (iOS) and PhotoEditor (Android)

Baron Ha. 244 Jan 5, 2023
Approximate is a Swift package that provides implementations of floating point comparisons for the Swift ecosystem

Approximate Approximate floating point equality comparisons for the Swift Programming Language. Introduction Approximate is a Swift package that provi

Christopher Blanchard 1 Jun 1, 2022