Indexed by TopGit from live GitHub metadata: facebookarchive/Tweaks has 4.7k stars, written primarily in Objective-C. An easy way to fine-tune, and adjust parameters for iOS apps in development.
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
The best way to improve an app is to use it every day. Even when ideas can be tested out in advance — for example, with Origami — it can still take some time with the app to see how it works in practice.
Occasionally, it's perfect the first try. Sometimes, the idea doesn't work at all. But often, it just needs a few minor adjustments. That last case is where Tweaks fits in. Tweaks makes those small adjustments easy: with no code changes and no computer, you can try out different options and decide which works best.
Some of the most useful parameters to adjust are animation timings, velocity thresholds, colors, and physics constants. At Facebook, we also use tweaks to temporarily disable new features during development. That way, the designers and engineers involved can enable it on just their devices, without getting in the way of others testing the app.
Tweaks was invaluable for building Paper. We hope it can be useful for your app too.
Usage
Each configurable value is called a tweak. There's a few ways to set them up, found in FBTweakInline.h.
Value
The simplest way to create a tweak is to replace a constant with FBTweakValue:
The first three parameters are where the tweak is listed and what it's called, and the last one is the default value. You can pass in many types of values for the default: booleans, numbers, or strings.
In release builds, the FBTweakValue macro expands to just the default value, so there's no performance impact. In debug builds, though, it fetches the latest value of the tweak.
You can also pass a fifth parameter, which will constrain the possible values for a tweak. The fifth parameter can be an array, dictionary, or an FBTweakNumericRange. If it's a dictionary, the values should be strings to show in the list of choices. Arrays will show the values' description as choices. (Note that you have to surround array and dictionary literals with an extra set of parentheses.)
The first parameter is the object to bind to, and the second is the property. Whenever the tweak is changed, self.headerView's alpha property is updated to match. A few more examples:
The first three parameters are the standard tweak listing information, and the last is a block to call. You can use FBTweakAction in any scope, but the block must be global: it can't depend on any local or instance variables (it wouldn't know which object to adjust).
Actions are useful for things like launching debug UIs, checking for updates, or (if you make one that intentionally crashes) testing crash reporting.
Tweaks UI
To configure your tweaks, you need a way to show the configuration UI. There's two options for that:
Traditionally, tweaks is activated by shaking your phone. To use that, just replace your root UIWindow with a FBTweakShakeWindow. If you're using Storyboards, you can override -window on your app delegate:
You can present a FBTweakViewController from anywhere in your app. Be sure to restrict the activation UI to debug builds!
- (void)showTweaks {
FBTweakViewController *tweakVC = [[FBTweakViewController alloc] initWithStore:[FBTweakStore sharedInstance]];
tweakVC.tweaksDelegate = self;
// Assuming this is in the app delegate
[self.window.rootViewController presentViewController:tweakVC animated:YES completion:nil];
}
- (void)tweakViewControllerPressedDone:(FBTweakViewController *)tweakViewController {
[tweakViewController dismissViewControllerAnimated:YES completion:NULL];
}
Tweaks UI Dismiss Notification
Alternatively, when the Tweaks UI is dismissed, you can register your notification center to listen to FBTweakShakeViewControllerDidDismissNotification, which can be used after importing FBTweakViewController.h
Advanced
You can also access the objects that make up the macros mentioned above. That can be useful for more complex scenarios, like adjusting members of a C structure.
Also you have de ability to implement the optional method tweakWillChange: in order to handle the previous value of your tweak:
- (void)tweakWillChange:(FBTweak *)tweak
{
NSLog(@"%@", tweak.currentValue); // Here current value is the previous value of the tweak
}
To override when tweaks are enabled, you can define the FB_TWEAK_ENABLED macro. It's suggested to avoid including them when submitting to the App Store.
Using from a Swift Project
Khan Academy's project SwiftTweaks is designed for Swift, and might be a better choice for Swift projects.
Tweaks can be used from Swift projects. In this case the handy shortcut macros defined in FBTweakInline.h are not available, meaning tweaks need to be created programmatically, similar to this example:
let tweak = FBTweak(identifier: "com.tweaks.example.advanced")
tweak.name = "Advanced settings"
tweak.defaultValue = false
let collection = FBTweakCollection(name: "Enable");
collection.addTweak(tweak)
let category = FBTweakCategory(name: "Settings")
category.addTweakCollection(collection);
let store = FBTweakStore.sharedInstance()
store.addTweakCategory(category)
tweak.addObserver(self)
After setting up a tweak you can watch for when it changes:
func tweakDidChange(tweak: FBTweak!)
{
self.advancedSettingsEnabled = tweak.currentValue as Bool;
}
How it works
In debug builds, the tweak macros use __attribute__((section)) to statically store data about each tweak in the __FBTweak section of the mach-o. Tweaks loads that data at startup and loads the latest values from NSUserDefaults.
In release builds, the macros just expand to the default value. Nothing extra is included in the binary.
Installation
There are two options:
Tweaks is available as Tweaks in CocoaPods. (If you have issues with custom Xcode configurations, this comment might help.)
Manually add the files from FBTweak/ into your Xcode project. Slightly simpler, but updates are also manual.
Tweaks requires iOS 6 or later.
There's also a demo project available. To use it, make sure to open FBTweakExample.xcworkspace (rather than the .xcodeproj) so the dependencies build correctly.
Contributing
See the CONTRIBUTING file for how to help out.
License
Tweaks is BSD-licensed. We also provide an additional patent grant.
Does facebookarchive/Tweaks have a project website?
No homepage URL was recorded for facebookarchive/Tweaks in TopGit's last sync. The README tab above frequently contains screenshots and demo links, or check the repository description on GitHub.
Is facebookarchive/Tweaks open source?
TopGit's metadata for facebookarchive/Tweaks does not record a license. Most public repositories on GitHub ARE open source, but the exact terms vary — verify by opening the LICENSE file directly.
What is facebookarchive/Tweaks?
facebookarchive/Tweaks (facebookarchive/Tweaks) is a Objective-C project on GitHub. From the project's own README: An easy way to fine-tune, and adjust parameters for iOS apps in development.
Where do I read more about facebookarchive/Tweaks?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/facebookarchive/Tweaks is the definitive source.
Read full README in the tab above.
Want a second opinion on Tweaks?
Ask an AI that can read this page — one click and you get its take on Tweaks.