• Stars
    star
    537
  • Rank 82,649 (Top 2 %)
  • Language
    Swift
  • License
    Apache License 2.0
  • Created about 6 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A delicious, quality‑of‑life supplement for your app‑development toolbox.

Cake

We are aware of Xcode 11, probably don’t commit to Cake at this time

Modules are a powerful Swift feature, yet existing tooling makes modulizing your projects so tedious that most people don’t bother.

A modular app gains:

  • Encapsulation. Internal scope is a criminally under-utilized Swift feature that makes encapsulation significantly more achievable.
  • Namespacing. Modules have an implicit namespace; fear not about reusing names, modulize instead.
  • Hierarchy. Once you start creating modules you automatically arrange them so that some have more importance than others. This naturally leads to a structured codebase where new files nestle into their logical, encapsulated homes, effortlessly.
  • Organization. You no longer have to cram everything concerning an area of responsibility into a single file to gain from file-private. Instead separate all that code out into multiple files in its own module and use internal access control.
  • Testability. Making a piece of functionality its own module means you can make more of that module internal scope rather than private and this means more of the module can be imported @testable making the functionality easier to test without adopting practices that make your code less readable for the sake of testing (like injection).

Cake makes working with Swift modules a breeze.

Xcode 10.2-beta Required

Supporting Swift tools-version-5 and tools-version-4 is not our thing. Cake requires at least Xcode 10.2 to function.

Support Cake’s development

Hey there, I’m Max Howell, a prolific producer of open source software and probably you already use some of it (I created brew). I work full-time on open source and it’s hard; currently I earn less than minimum wage. Please help me continue my work, I appreciate it 🙏🏻

Other ways to say thanks.

How it works

“The secret of getting ahead is getting started. The secret of getting started is breaking your complex overwhelming tasks into small, manageable tasks, and then starting on the first one.” —Mark Twain

Cake is an app that runs in your menu bar and watches your Xcode projects. If you chose to integrate Cake into your App’s xcodeproj it will automatically generate your module hierarchy based on your directory structure. For example:

.
└ Sources
  └ Model
    ├ Module1
    │ ├ a.swift
    │ └ b.swift
    └ Module2
      ├ c.swift
      └ d.swift

Now ⌘B and you’ll be able to import:

import Module1
import Module2

FAQ: What is a cake project? A Cake project has a Cakefile.swift file in its root.

Delicious: All your modules are built statically so there’s no launch-time consequences.

Curious? Cake is made with Cake, so is Workbench, check out the sources to see more about what a cake‐project looks like.

Details: Cake generates a sub-project (Cake.xcodeproj), you lightly integrate this into your app’s project.

Module hierarchies

“You’ve got to think about the big things while you’re doing small things, so that all the small things go in the right direction.” —Alvin Toffler

Before long you will need some modules to depend on others. This is an important step since you are starting to acknowledge the relationships between components in your codebase. Cake makes declaring dependencies as easy as nesting directories.

.
└ Sources
  └ Model
    └ Base
      ├ a.swift
      ├ b.swift
      └ Foo
        ├ c.swift
        └ d.swift

Here Foo depends on Base and thus, Foo can now import Base.

All other tools require you to specify relationships cryptically, either textually or with a confounding GUI. With Cake, use the filesystem, relationships are not only easy to read, but also, trivial to refactor (just move the directory).

Further Reading: Advanced module hierarchies

FAQ: What should go in your Base module? Cake’s Base module contains extensions on the standard library.

Dependencies

“You can do anything, but not everything.” —David Allen

Cake makes using Swift packages in Xcode easy. Write out your Cakefile, ⌘B, Cake fetches your deps and integrates them: no muss, no fuss.

import Cakefile

dependencies = [
    .github("mxcl/Path.swift" ~> 0.8),
    .github("Weebly/OrderedSet" ~> 3),
]

// ^^ naturally, using Cake to manage your deps is entirely optional

We figure out your deployment targets, we make your deps available to all your targets and we generate a stub module that imports all your deps in one line (import Dependencies).

We check out your dependencies tidily, for example the above Cakefile gives you:

.
└ Dependencies
  ├ mxcl/Path.swift-0.8.0
  │ ├ Path.swift
  │ └ …
  └ Weebly∕OrderedSet-3.1.0.swift

Which generates this in your Cake.xcodeproj:

Which you can then commit, or not commit: that’s up to you. Though we suggest you do.

Delicious: All dependency modules are built statically so there are no launch-time consequences.

Delicious: A fresh clone of a Cake project builds with vanilla Xcode, no other tools (even Cake) are required. Distribute away without worry!

Delicious: Cake finally makes it possible to use SwiftPM packages for iOS development!

FAQ: Should I commit my deps?

Caveat: We only support SwiftPM dependencies at this time.

Further Reading: Cakefile Reference

Carthage & CocoaPods

If your app uses Carthage or CocoaPods we detect that and integrate them so your cake modules (the Batter) can use these dependencies.

Note, this only applies to cake modules (the Batter); for your App target follow the instructions provided by CocoaPods and Carthage themselves; nothing is different.

Op‐Ed—an era for Swift µ-frameworks?

CocoaPods and Carthage libraries tend to be on the large side, and this is at least partly because being modular has been historically hard and tedious when developing for Apple platforms and Swift. SwiftPM encourages smaller, tighter frameworks and using Cake means making apps with Swift packages is now possible.

Choose small, modular, single‐responsibility libraries with 100% code coverage that take semantic-versioning seriously. Reject bloated libraries that don’t know how to say no to feature requests.

Constructing frameworks/dylibs

Since everything Cake builds is a static archive, you can simply link whichever parts you like into whatever Frameworks or dylibs you need for your final binaries.

This is a purely optional step, statically linking Cake.a into your App (which Cake sets up by default for you) is perfectly fine. This more advanced option is available to make apps with extensions more optimal in terms of disk usage and memory consumption.

Installation

  1. Download it.

  2. Run it.

  3. Check your menu bar:

  4. Open a project and integrate Cake; or

  5. Create a new Cake.

FAQ: What does integration do?

Delicious: We auto-update!

Bonus Features

Extracting your app’s version from Git

Cake determines your App’s version from your git tags, to use them simply set each target’s “Version” to: $(SEMANTIC_PROJECT_VERSION) and if you like the “Build” number to: $(CURRENT_PROJECT_VERSION).

Delicious! We even append -debug to debug builds.

Xcode Remote Control

Caveats

Due to some Xcode bugs Cake is not a complete Cake‐walk in use. Please see our troubleshooting guide for details.

Documentation

Icons credit

Icons made by Google and Freepik from www.flaticon.com licensed by CC 3.0 BY.

More Repositories

1

PromiseKit

Promises for Swift & ObjC.
Swift
14,218
star
2

swift-sh

Easily script with third-party Swift dependencies.
Swift
1,732
star
3

Path.swift

Delightful, robust, cross-platform and chainable file-pathing functions.
Swift
929
star
4

Workbench

Seamless, automatic, “dotfile” sync to iCloud.
Swift
668
star
5

YOLOKit

Getting square objects down round holes
Objective-C
663
star
6

OMGHTTPURLRQ

Vital extensions to NSURLRequest that Apple left out for some reason.
Objective-C
339
star
7

Version

semver (Semantic Version) Swift µFramework.
Swift
293
star
8

xcodebuild

A continuously resilient `xcodebuild` “GitHub Action”. Also it’s the best.
TypeScript
285
star
9

AppUpdater

Automatically update open source macOS apps from GitHub releases.
Swift
245
star
10

Chalk

Terminal colors using Swift 5’s string interpolation extensions.
Swift
215
star
11

LegibleError

Beating `Error.localizedDescription` at its own game.
Swift
180
star
12

Audioscrobbler.app

Minimal, robust iTunes scrobbling
Objective-C
140
star
13

UIImageWithColor

[UIImage imageWithColor]
Objective-C
80
star
14

yosemite-menu-inverter

Invert your Yosemite icons
Ruby
71
star
15

MBWebSocketServer

An objc draft 10 websocket implementation
Objective-C
69
star
16

AmA

Ask mxcl anything.
50
star
17

ChuzzleKit

A chuzzled object is nil if it is falsy, otherwise it has its falsy parts removed.
Objective-C
48
star
18

UIImageAverageColor

[UIImage averageColor]
Objective-C
32
star
19

playdar.prefpane

All in one Mac OS X Preference Pane for the Playdar daemon
Objective-C
28
star
20

initWith...FuckIt

Constructors for pithy, potty-mouths.
Objective-C
26
star
21

MBAppStoreRater

Non-intrusive invitation to rate your iOS app
Objective-C
22
star
22

bs

Write HTML inline with your JS
Ruby
22
star
23

UIColorPerceivedLuminance

[UIColor perceivedLuminance]
Objective-C
18
star
24

StreamReader

Swift
17
star
25

SuperGoodDeleteWiggle

Wiggle animation (almost) as good as the Springboard delete wiggle animation
Objective-C
13
star
26

mxcl.github.io

HTML
12
star
27

scrobsub

Portable scrobbling solution in plain c
C
9
star
28

generate-podspec

Generate a podspec for your SwiftPM project based on tagged releases.
TypeScript
9
star
29

Kissogram

Swift
8
star
30

UIInvertedImage

[UIImage invertedImage]
Objective-C
8
star
31

homebrew-made

Ruby
7
star
32

Flickr-Friends.wdgt

A recent photo slideshow of your Flickr Friends for the OS X Dashboard
JavaScript
7
star
33

roofparty

A Last.fm radio player written in D
5
star
34

.github

5
star
35

DraftLottery

Example Swift app
Swift
4
star
36

get-swift-version

JavaScript
4
star
37

Roole.tmBundle

TextMate Syntax Highlighting Bundle for Roole
4
star
38

mxcl

3
star
39

SelfieAssist

Objective-C
3
star
40

MXCLPlaceholderTextView

3
star
41

sym0

Cocoa utility functions with zero symbol pollution
Objective-C
2
star