khan / swifttweaks Goto Github PK
View Code? Open in Web Editor NEWTweak your iOS app without recompiling!
License: MIT License
Tweak your iOS app without recompiling!
License: MIT License
public struct TweakClosure {
public let collectionName: String
public let groupName: String
public let tweakName: String
internal let closure: () -> ()
}
The idea here: when you want to perform an action in your app only in certain debug builds, you could put it in a TweakClosure, and then call something like this:
MyTweakLibrary.evaluate(MyTweakLibrary.someTweakClosure)
You'd also want to have that TweakClosure conform to AnyTweak
, so that it can be included in a TweakGroup
, and displayed in a table cell with a little [RUN] button (I'm thinking it'd look like a little App Store [BUY] button)
Should be UIView.animate(basicTweakTemplate:...
HI!
Downloaded SwiftTweaks from Github
make no alterations in the project
try to build framework and get "Umbrella header 'SwiftTweaks.h' not found"
Search in Stackoverflow and it says that
"This usually happens after a project rename or something like that. The problem is that the umbrella header is no longer listed as a Public header."
(http://stackoverflow.com/questions/30355133/swift-framework-umbrella-header-h-not-found)
but I checked and the headers SwiftTweaks.h is already on the "public" headers section
Thanks in advance for any help!
Currently, if you have an Int
tweak, the UI shows e.g. 3.0
instead of 3
.
A two-finger triple-tap is a commonly-used gesture when the shake gesture's already used for something else - let's make it super-easy for devs to use that instead of the shake gesture!
(Of course, devs can always use whatever custom gesture they'd want.)
Instead of:
public enum GestureType {
case Shake
case Gesture(UIGestureRecognizer)
}
We'd have:
public enum GestureType {
case Shake
case TwoFingerTripleTap
case CustomGesture(UIGestureRecognizer)
}
The section header UI elements are missing - what's changed to cause this? Something in the Swift3 migration, I bet.
Sometimes, the collection + group + tweak names aren't enough to really communicate the effect of a tweak.
Maybe it'd be neat to optionally allow a longer "hint" text, to be displayed on long-pressing in the cell?
Would need to design the affordance for the long press, because it'll be rarely used, but I think it'd be helpful.
The hint would be presented in a UIAlertController.Alert
Hi,
Firstly thanks so much for this project! As a user of FBTweaks I've been waiting for a swift replacement, and I look forward to contributing if possible :)
I have noticed that the Personal Hotspot Blue Bar pushes the TweakViewController beyond the bottom of the window bounds. Screenshot attached:
Cheers,
Daniel
So you can more easily create templates (think: the parameters of a spring animation) rather than having to create 4 separate tweak values.
The idea would be, you could create a struct that conforms to TweakGroupType
.
CocoaPods
and Carthage
are awesome tools and make our life really easier, but there are some devs who still don't know how to use them.
It would be cool to add the Manual installation guide in your README.md
. You can take a look at my iOS Readme Template to see how you can do it.
Maybe SwiftTweaks can just detect the simulator by using
#if arch(i386) || arch(x86_64)
Steps to reproduce:
We're using SwiftTweaks in a project and while using bind
for a few Tweaks I was wondering when those observer closures are released. I skimmed through the source code and it appears to me that the closure given to bind
is saved in a dictionary where it is strongly references forever.
If I'm not mistaken these bindings dictionaries are never cleaned up neither there is any API to unregister the binding. So everytime my ViewController is started I bind
a new closure that will be around forever, this looks like a memory leak to me.
Is there anything I'm missing that resolved this memory issue? Or is this an issue and do we need to add some kind of unbind
call to remove the closure from the list.
Currently, if you're using bindMultiple
, you need to do something like this:
let tweaksToWatch: [TweakType] = [ExampleTweaks.marginHorizontal, ExampleTweaks.marginVertical]
ExampleTweaks.bindMultiple(tweaksToWatch) {
let horizontal = ExampleTweaks.assign(ExampleTweaks.marginHorizontal)
let vertical = ExampleTweaks.assign(ExampleTweaks.marginVertical)
scrollView.contentInset = UIEdgeInsets(top: vertical, right: horizontal, bottom: vertical, left: horizontal)
}
It'd be neat to be able to do something like this instead:
let tweaksToWatch: [TweakType] = [ExampleTweaks.marginHorizontal, ExampleTweaks.marginVertical]
ExampleTweaks.bindMultiple(tweaksToWatch) { horizontal, vertical in
scrollView.contentInset = UIEdgeInsets(top: vertical, right: horizontal, bottom: vertical, left: horizontal)
}
I've found this helpful in http://github.com/robb/Cartography/
The tableviews in TweaksRootViewController often don't get the topLayoutGuide update (so their content scrolls under the navigation bar)
Doesn't reproduce now that we don't have the segmented controller in the nav bar (because you can't switch the tab, there's not a path to reproduce the error) but the underlying bug in the layout logic is still there!
I would like to present the TweaksViewController
from a button press, which works well, however, the FloatingTweakGroupViewController
does not then display (as TweaksViewController.floatingTweaksWindowPresenter == nil
in this case)
Making TweakWindow.tweaksViewController
public
allows for all the benefits of using TweakWindow
triggered from any application event.
You can see a simple example on this fork: https://github.com/DanielAsher/SwiftTweaks/commits/fix/floating-window-on-tweak-manual-present
cheers,
Daniel
If the initial Int tweak value is set to say 150, and you hit the plus button, the value changes to 101. If you hit the minus button, it changes to 99. Setting a defaultValue while creating the tweak doesn't fix it either.
There's code there to assert it, but we should have unit tests for it, too!
I would love to have custom text to show information like API URL.
I love the FloatingTweakGroupViewController
- but sometimes the very part of the current view I'm trying to tweak is obscured by the floating window. Enabling a drag gesture on the floating window would allow us to reposition it and expose the hidden parts of the underlying view.
We didn't need this for our initial use of SwiftTweaks, but it'd be helpful to have!
Things to consider:
I need the ability to test behavior when a tweak is enabled/disabled. We are using Tweaks for feature flagging, false turns off in-development features for production.
Because I am scared new development features may affect production in an unexpected way, I would like to be able to unit test various modules which use tweak. Is there not a way to write a different value programmatically?
Sometimes, you want to have a feature flag that has multiple options - for example, you might have 3 environments to point against (e.g. test, stage, production) and want to switch between them.
A couple of ideas for implementing this:
TweakableEnum
, that can be used in a tweak easily. The protocol would probably require a static var caseNames: [String]
to list out the options in the Tweaks UI. We'd also probably want a failable-init that returns the correct enum case
for a given String
(so that the enum can "look up" a persisted stringly-typed value.) This might depend on us building #14 first (adding String as a TweakableType).[String]
and optionally has a default value (asserting if the default value doesn't exist in the array, and if no default given, uses the first value in the array). Leave it to the implementer to switch on the current value of the string - they can always build a string-based enum and init with rawValue:
to get away from stringly-based stuff.Anyhow, I've not yet tried building this out yet, so I dunno what will be easy-to-understand-and-implemented here. One goal for SwiftTweaks is to keep tweak libraries simple and straightforward - so while I'm inclined to do the "most precise and Swifty thing", it's even more important that SwiftTweaks remains easy-to-use for new folks, so that'll be a big criteria in evaluating which one of these will work!
Original discussion here: #44
Much like TweaksViewController is public, we could probably do some investigation and make FloatingTweakGroupViewController public as well, so developers can use that component (without mucking around in TweakWindow's child objects).
For developers who aren't using TweakWindow, let's make the floating UI publicly usable - and include an optional init Bool for TweakViewController that hides the (+) buttons when not in use.
Something like:
public extension Tweak {
func currentValueInStore<S: TweakLibraryType.class>(store: S) -> T {
return store.assign(self)
}
}
This would simplify getting values from tweaks, from:
let value = TweakStore.assign(TweakStore.some.tweak)
to
let value = TweakStore.some.tweak.currentValueInStore(TweakStore.self)
e.g.
via #26 (diff)
I would love to be able to push on a custom view controller for Swift Tweaks.
See discussion here: #53
Often, when I've dialed in an animation, I want to be able to create a "backup" so I can go experiment more, knowing that I have a save point if I want to go back.
It'd be neat if we had the ability to create/update/read Backups. I would like that they use the same visual format as the email template we use when sharing a set of tweaks.
One interesting bit that'll arise from this: what happens if the underlying TweakLibraryType
changes? Do we need some kind of randomly-generated-from-a-deterministically-derived-seed thing (where TweakStore creates a "version name" to ensure that a Backup can only be restored if the underlying version name is the same?)
In order to integrate with RxSwift's DelegateProxy
mechanism, TweaksViewController.delegate
could be changed from unowned
to weak
.
This gist shows the required DelegateProxy implementation and an example call to rx_pressedDone
.
No dependency on RxSwift
is required of the SwiftTweaks
project
The required change to SwiftTweaks can be seen in this commit.
Please let me know if you would like me to submit a pull request.
If you have a long TweakGroup (~4 items or more) the table's scroll offset needs to be set properly on first appearance.
Not sure what's going on in testHexToColor
, but there's an EXC_BAD_ACCESS
for this test case:
HexToColorTestCase(string: "Hello", expectedColor: nil),
Any ideas?
Some of em are a bit sparse. Do an audit and write some good'ns.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.