Giter VIP home page Giter VIP logo

tweaks-swift's Introduction

Tweaks Macros for Swift

Poetry cannot be translated; and, therefore, it is the poets that preserve the languages.

Samuel Johnson

Why this extension ?

Because macros does not exists anymore in Swift, so we have to translate them into Swift functions func.

Generics

Swift brings the power of generics, so this extension use it pretty intensively. The major benefit is that tweaks are now checked at compile time.

For instance, if you want to control the animation duration, you can do :

let duration: Double = tweak("Advanced", "Animation", "Duration", Double(1.0), Double(0.3), Double(8.0))

NB: the let duration: Double is to prove to you that the tweak(_:_:_:_:_:_:) function is returining the right type, which is Double in this case.

Installation

Three simple steps :

  • of course, include the original FBTweaks project with one of the two options they provide
  • include the FBTweaks+Macros.swift
  • add the content of the ObjC-Briding-Header.h file to your own Objective-C Briding Header file.

And you're good to go.

Known issues

  • tweaks are not statically stored during compile time in the __FBTweak section of the mach-o, as they are in the objective-c macros implementation. If you figure out a way to do that with the Swift compiler, do not hesitate to make a PR.

Contact

Pierre Dulac
@dulaccc

License

Tweaks-swift is available under the MIT license. See the LICENSE file for more info.

tweaks-swift's People

Contributors

dulacp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tweaks-swift's Issues

Enum support?

Hi do you have support for enumerated values, which was recently added to tweaks?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.