https://github.com/dulacp/tweaks-swift
Extension to use the great facebook Tweaks project with Swift
https://github.com/dulacp/tweaks-swift
Last synced: 6 months ago
JSON representation
Extension to use the great facebook Tweaks project with Swift
- Host: GitHub
- URL: https://github.com/dulacp/tweaks-swift
- Owner: dulacp
- License: mit
- Created: 2014-09-19T11:32:29.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-03-16T22:26:05.000Z (about 8 years ago)
- Last Synced: 2024-06-11T20:11:02.394Z (11 months ago)
- Language: Swift
- Homepage:
- Size: 3.91 KB
- Stars: 9
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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 :
```swift
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](https://github.com/facebook/Tweaks#installation) 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](https://github.com/facebook/Tweaks#how-it-works). If you figure out a way to do that with the Swift compiler, do not hesitate to make a PR.
## Contact
[Pierre Dulac](http://github.com/dulaccc)
[@dulaccc](https://twitter.com/dulaccc)## License
Tweaks-swift is available under the MIT license. See the LICENSE file for more info.