Easily generate cross platform Swift framework projects from the command line

Overview

SwiftPlate

Easily generate cross platform Swift framework projects from the command line.

SwiftPlate will generate Xcode projects for you in seconds, that support:

  • CocoaPods
  • Carthage
  • Swift Package Manager
  • iOS
  • macOS
  • watchOS
  • tvOS
  • Linux

Just run swiftplate, and you’ll be presented with a simple step-by-step guide:

Screenshot

Usage

Using Homebrew (recommended)

$ brew install swiftplate
$ swiftplate

Using Make

$ git clone [email protected]:JohnSundell/SwiftPlate.git
$ cd swiftplate
$ make

Using Marathon

$ git clone [email protected]:JohnSundell/SwiftPlate.git
$ marathon run swiftplate/main

Using the Swift interpreter directly

$ git clone [email protected]:JohnSundell/SwiftPlate.git
$ swift swiftplate/main.swift

Using Xcode

$ git clone [email protected]:JohnSundell/SwiftPlate.git
$ open swiftplate/SwiftPlate.xcodeproj

Command line arguments

Besides using the guide to input information, SwiftPlate also supports command line arguments when launched. When a certain piece of information is supplied through an argument, SwiftPlate won't ask for that information when run. These are the arguments currently supported:

Name Description Long parameter Short parameter
Destination Where the generated project should be saved --destination -d
Project name The name of your project --project -p
Author name Your name --name -n
Author email Your email (for Podspec) --email -e
GitHub URL Any URL you'll be hosting the project at (for Podspec) --url -u
Organization name The name of your organization --organization -o
Repo Any custom SwiftPlate repository that should be used for templates --repo -r
Force Prevent user prompt at the end (for CIs etc.) --force -f

Questions or feedback?

Feel free to open an issue, or find me @johnsundell on Twitter.

Comments
  • Linux support missing from cross-platform?

    Linux support missing from cross-platform?

    Noticed that Swift libraries that are to be run on Linux have one slight variation in the testing that is missing from SwiftPlate.

    Swift Package Manager (swift package init --type library) does additionally the following:

    In Tests/{PROJECT}Tests/{PROJECT}Tests.swift it adds:

        func testExample() {
            // This is an example of a functional test case.
            // Use XCTAssert and related functions to verify your tests produce the correct results.
            XCTAssertEqual({PROJECT}().text, "Hello, World!")
        }
        static var allTests : [(String, ({PROJECT}Tests) -> () throws -> Void)] {
            return [
                ("testExample", testExample),
            ]
        }
    

    the example assert is related to boilerplate code in the Sources/ implementation, but the allTests is more interesting, as that is the convention for the slightly different testing flow for Swift encountered under Linux.

    For Linux it adds another, related file Tests/LinuxMain.swift. Its contents:

    import XCTest
    @testable import {PROJECT}Tests
    
    XCTMain([
         testCase({PROJECT}Tests.allTests),
    ])
    

    Could the "cross-platformness" of SwiftPlate be updated to include libraries on Linux?

    enhancement 
    opened by idcrook 8
  • Dependencies

    Dependencies

    Not sure if I'm being stupid here or not, but what's the best way of managing subdependencies with this? For Cocoapods I could specify them in the podspec via s.dependency ... but can't really install them without a Podfile (something that would require an .xcworkspace as well).

    Also those using the framework project built like this will probably have to use my dependency manager of choice as well, which is far from ideal. Is there a way to work around this? Or is it just not practical working with subdependencies when making a framework for use with all three currently used dependency managers?

    question 
    opened by kiliankoe 7
  • Optional Gather coverage data

    Optional Gather coverage data

    Hi John, First of all, thanks for this tool, it has been very helpful for me. Do you think that an option to enable the "Gather coverage data" for all the testing targets would be useful? Does it suit in this project? If so, I would like to work on that and prepare a PR.

    feature request 
    opened by adellibovi 5
  • Added Linux library Unit testing to boilerplate

    Added Linux library Unit testing to boilerplate

    • Did NOT add a question about Linux support. Instead, added to Templates/ code that will still work unchanged under macOS, *OS. This is related to other details that I will describe.

    • do not see a conventional way to conditionally include snippets into a Template/ output file, so instead I added a conditional extension for Linux only. Snippets ability would be useful in many ways: include example unit testing code and an example object (struct, e.g.) in the Sources/ if, and only if, an optional Boolean such as "Linux Unit testing support" was added to user prompt.

    • tested under macOS. running testStructure.py passed.

    • compilation under Linux will fail, due to testExample not being defined (see above about example unit testing code)

    opened by idcrook 5
  • License put in by default

    License put in by default

    It looks like the generated files have the MIT License put in by default at the top of all files. Though it doesn't really make a difference to my org (we're open sourcing most of our stuff), people might have a problem with it. screen shot 2016-11-23 at 4 42 27 pm

    enhancement 
    opened by codeOfRobin 5
  • Make Directories Dynamically

    Make Directories Dynamically

    Instead of throwing an error if a directory doesn't exist, the script now generates directories dynamically.

    Just a rough/dirty implementation for now.

    opened by ArtSabintsev 5
  • New SwiftPlate release

    New SwiftPlate release

    opened by 3lvis 4
  • Fix for python syntax error in testStructure.py

    Fix for python syntax error in testStructure.py

    • since the file has non-ASCII characters, it can fail with a compile error if the doc type is not specified. This edit corrects for that.

    Platform: macOS 10.12, Python 2.7.12

    Error example

    $ python ../SwiftPlate/testStructure.py test

    File "testStructure.py", line 30
    SyntaxError: Non-ASCII character '\xe2' in file testStructure.py on line 30, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
    
    opened by idcrook 4
  • Add .gitignore file

    Add .gitignore file

    Hi! SwiftPlate is awesome, thanks for creating it. I was wondering if it makes sense to include a default .gitignore file for Xcode/Swift projects, I've seen other tools like this doing it.

    opened by dani-mp 3
  • Replaced MIT license header with Xcode header #19

    Replaced MIT license header with Xcode header #19

    This PR replaces the MIT headers in {PROJECT}.swift and {PROJECT}Tests.swift with headers Xcode would generate.

    But I am not sure how to handle different licenses.

    opened by vknabel 3
  • Does not build under Linux

    Does not build under Linux

    Not sure if this is a requirement for this project-- or is supported-- but wanted to put an issue out there. It might never be supported.

    I do not need this for myself as I can build/run SwiftPlate on macOS, and once I have the boilerplate build, I can use git clones to share in Linux environment.

    building under linux

    I tried to build SwiftPlate from recent clone on Linux (Ubuntu 16.04), and get build errors. Most of them look like they are Swift Core library/Foundation related, which is known to be lagging in completeness compared to macOS/*OS.

    $ swift ../SwiftPlate/main.swift test
    ../SwiftPlate/main.swift:56:16: error: value of type 'ObjCBool' (aka 'Bool') has no member 'boolValue'
            return objCBool.boolValue
                   ^~~~~~~~ ~~~~~~~~~
    ../SwiftPlate/main.swift:176:19: error: use of unresolved identifier 'Process'
        let process = Process()
                      ^~~~~~~
    Foundation.NSProgress:1:12: note: did you mean 'NSProgress'?
    open class NSProgress : Foundation.NSObject {
               ^
    Foundation.ProcessInfo:1:12: note: did you mean 'ProcessInfo'?
    open class ProcessInfo : Foundation.NSObject {
               ^
    

    Process changed to CommandLine?

    I didn't really dig much into these errors. Googling the Process() one yielded something that would appear to related, but after further investigation, I do not think it is: Rename Process to CommandLine [SE-0086] https://github.com/apple/swift/commit/f65c1390cb23395fde5a798fb6731b32a31ec452

    The change referred to has been in place for a while on Swift 3 branch.

    I was able to confirm that Process is available in Foundation on macOS, but is not present in Foundation on Linux (at this time).

    Platform versions

    OS: Ubuntu 16.04.1

    $ swift --version
    Swift version 3.0.1 (swift-3.0.1-RELEASE)
    Target: x86_64-unknown-linux-gnu
    $ uname -a
    Linux vader 4.4.0-49-generic #70-Ubuntu SMP Fri Nov 11 16:40:34 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
    
    enhancement 
    opened by idcrook 3
  • Error while creating a new project

    Error while creating a new project

    Error output

    🚀  Starting to generate project SmartAPI...
    👉  Removing any previous temporary folder...
    ✅  Done
    👉  Making temporary folder (/Users/Amadeu/Developer/swiftplate_temp)...
    ✅  Done
    👉  Making a local clone of the SwiftPlate repo...
    ✅  Done
    👉  Copying template folder...
    ✅  Done
    👉  Removing temporary folder...
    ✅  Done
    👉  Filling in template...
    An error was encountered 🙁
    Error: Error Domain=NSCocoaErrorDomain Code=264 "The file “A.cpython-36.pyc” couldn’t be opened because the text encoding of its contents can’t be determined." UserInfo={NSFilePath=/Users/Amadeu/Developer/AREPL-vscode/test/manualAreplTests/__pycache__/A.cpython-36.pyc}
    
    opened by amadeu01 2
  • Missing path in target (swift-tools-version:4.0)

    Missing path in target (swift-tools-version:4.0)

    If I will generate project using swiftplate there isn't path attribute in target in Package.swift. Because of that I am unable to install framework as dependency through package manager.

    After adding path: "Sources" installation is possible.

    Source https://github.com/apple/swift-evolution/blob/master/proposals/0162-package-manager-custom-target-layouts.md

    opened by jcislinsky 0
  • Error when using `--repo`option

    Error when using `--repo`option

    I have this error when trying to do swiftplate -r ./swiftplate:

    🚀  Starting to generate project Test...
    👉  Removing any previous temporary folder...
    ✅  Done
    👉  Making temporary folder (Test/swiftplate_temp)...
    ✅  Done
    👉  Making a local clone of the SwiftPlate repo...
    ✅  Done
    👉  Copying template folder...
    An error was encountered 🙁
    Error: Error Domain=NSCocoaErrorDomain Code=260 "The folder “Template” doesn’t exist." UserInfo={NSFilePath=Test/swiftplate_temp/SwiftPlate/Template, NSUserStringVariant=(
        Folder
    ), NSUnderlyingError=0x7f926940afa0 {Error Domain=NSOSStatusErrorDomain Code=-43 "fnfErr: File not found"}}
    

    Maybe I'm missing something ? 🤔 It work well without the option -r

    opened by ajacquelin 0
  • Template creation

    Template creation

    I use cookiecutter and my custom template for project generation. I guess you have the same problem - it's very hand to update or create a new template. How you do it? It would be great if you add a command for template generation based on existing project. I want to write a script for it, but if you have a plan for it, I'll wait 😃

    opened by artemnovichkov 2
Releases(1.4.0)
  • 1.4.0(Jul 19, 2017)

    • The default license header put into each source file now matches Xcode's defaults (thanks @vknabel!)
    • Fixes for inserting today's date into the header of each source file (thanks @vknabel, @sorenmortensen & @gperdomor!)
    • README, LICENSE files are now ignored if they already exist (thanks @alexaubry!)
    • Fixes for main.swift being overwritten (thanks @vijaytholpadi!)
    • Generated projects now use the latest Xcode (8.3) settings (thanks @pixyzehn!)
    • Generated projects now include a .gitignore file (thanks @danielmartinprieto!)
    • Generated Xcode project now includes groups for Sources and Tests (thanks @KieranHarper!)
    Source code(tar.gz)
    Source code(zip)
  • 1.3.0(Jan 23, 2017)

    SwiftPlate can now infer most information it needs from the file system & your git config! 🎉

    The following information is optionally inferred (if you leave it blank while running swiftplate):

    • Project name: Name of the folder where you're generating the project.
    • Author name: The value of git config --global user.name.
    • Author email: The value of git config --global user.email.
    • GitHub URL: Any remote git origin URL that you have setup in your project folder.
    Source code(tar.gz)
    Source code(zip)
  • 1.2.1(Jan 14, 2017)

    • Code coverage is now enabled in all projects that SwiftPlate generates (thanks @adellibovi!)
    • You can now launch SwiftPlate with --force (or -f) to prevent it from asking for confirmation before creating your project (thanks @codeOfRobin!)
    Source code(tar.gz)
    Source code(zip)
  • 1.2.0(Jan 10, 2017)

    • Full command line argument support (see README for more information)
    • You can now specify a local repo that should be used for SwiftPlate's template (very useful for development, and also enables custom templates).
    Source code(tar.gz)
    Source code(zip)
  • 1.1.1(Jan 8, 2017)

  • 1.1.0(Nov 26, 2016)

    • SwiftPlate now has a Makefile that enables you to easily install it (implemented by @codeOfRobin)
    • SwiftPlate will now generate projects that are Linux compatible (implemented by @idcrook)
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Nov 21, 2016)

    Initial release of SwiftPlate, which makes it easy to generate cross platform Swift framework projects that are compatible with CocoaPods, Carthage & Swift Package Manager.

    Source code(tar.gz)
    Source code(zip)
Owner
John Sundell
I build apps, games and Swift developer tools! Passionate about open source & developer productivity. You can follow me on Twitter @JohnSundell.
John Sundell
A Swift cross-platform (Apple and Linux) networking library.

KippleNetworking A Swift library that offers cross-platform (Apple and Linux) networking support, intended for the creation of cross-platform SDKs to

Kipple 11 Sep 20, 2022
Cross-platform Swift library for accessing the public GitHub API.

GoatHerb GoatHerb is a cross-platform Swift library for accessing the GitHub API. Features General Compatible with swift-log. Full concurrency (async/

Brian Drelling 3 Oct 30, 2022
The Outline Client is a cross-platform VPN or proxy client for Windows, macOS, iOS, Android, and ChromeOS

Outline Client The Outline Client is a cross-platform VPN or proxy client for Windows, macOS, iOS, Android, and ChromeOS. The Outline Client is design

Jigsaw 7.3k Dec 31, 2022
Cross-platform, sophisticated frontend for the libretro API.

RetroArch is the reference frontend for the libretro API. Popular examples of implementations for this API includes video game system emulators and game engines as well as more generalized 3D programs. These programs are instantiated as dynamic libraries. We refer to these as "libretro cores".

null 7.4k Dec 27, 2022
Cross-platform instrumentation and introspection library written in C

Gum Cross-platform instrumentation and introspection library written in C. This library is consumed by frida-core through its JavaScript bindings, Gum

Frida 524 Jan 4, 2023
Beak 🐦 Peck into your Swift files from the command line

Beak ?? Peck into your Swift files from the command line Beak can take a standard Swift file and then list and run any public global functions in it v

Yonas Kolb 566 Dec 6, 2022
A Swift command line tool for generating your Xcode project

XcodeGen XcodeGen is a command line tool written in Swift that generates your Xcode project using your folder structure and a project spec. The projec

Yonas Kolb 5.9k Jan 9, 2023
Command line tool for exporting resources and generating code from your Figma files

Fugen Fugen is a command line tool for exporting resources and generating code from your Figma files. Currently, Fugen supports the following entities

Almaz Ibragimov 69 Dec 17, 2022
ConfettiKit is a custom framework used to add Confetti on your iOS/iPadOS projects.

ConfettiKit is a custom framework used to add Confetti on your iOS/iPadOS projects. The kit provides variety of customisations inorder to design a confetti which matches your project's UI. ConfettiKit makes your work of adding Confetti on your project with just one line of code.

Gokul Nair 14 Sep 27, 2022
Generate Swift code from Qt5 user interfaces.

Qlift-uic Description qlift-uic takes a Qt5 user interface description file and compiles it to Swift code for use with QLift. Splitted from main QLift

Dmitriy Borovikov 1 Apr 2, 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
OpenAPI specification generator for Vapor based Swift projects.

VaporToOpenAPI VaporToOpenAPI is a Swift library which can generate output compatible with OpenAPI version 3.0.1 from Vapor code. You can use generate

null 3 Dec 15, 2022
A Swift library for hardware projects on Linux/ARM boards with support for GPIOs/SPI/I2C/PWM/UART/1Wire.

A Swift library for hardware projects on Linux/ARM boards with support for GPIOs/SPI/I2C/PWM/UART/1Wire. Summary This library provides an easy way to

uraimo 1.3k Dec 26, 2022
Demo of using Metal to render EDR / HDR content on iOS platform

MetalEDR-iOS Demo of using Metal to render EDR/HDR content on iOS platform. How it works This demo uses a hack to activate EDR display on iOS platform

Wutian 38 Oct 24, 2022
nds4ios is a port of the multi-platform Nintendo DS emulator, DeSmuME to iOS.

nds4ios Supports iOS 6 to iOS 9. nds4ios is a port of the multi-platform Nintendo DS emulator, DeSmuME to iOS. Currently, emulation is powered by a th

Kevin 162 Dec 25, 2022
🚀 Create, maintain, and interact with Xcode projects at scale

What's Tuist ?? Tuist is a command line tool that helps you generate, maintain and interact with Xcode projects. It's open source and written in Swift

Tuist 3.1k Jan 6, 2023
📝 Read, update and write your Xcode projects

XcodeProj XcodeProj is a library written in Swift for parsing and working with Xcode projects. It's heavily inspired by CocoaPods XcodeProj and xcode.

Tuist 1.7k Dec 28, 2022
Challenging each other to complete pet projects!

Podlodka Pet Project Challenge Мотивируем друг друга на завершение своих пет проджектов! Каждую неделю каждый участник вносит в банк 1 ставку и ведет

Vladimir Korolev 2 Aug 27, 2022
Ios jetpack - A codabase for iOS projects foundations

iOSJetpack A codabase for iOS projects foundations Neworking Data Reusable Proto

MonsterTechStudio 1 Jan 24, 2022