Commit bcb3d9a6 authored by Josh Abernathy's avatar Josh Abernathy
Browse files

Merge pull request #1114 from ReactiveCocoa/signal-naming-envvar

Change RAC_DEBUG_SIGNAL_NAMES into an environment variable
parents 2a6caf40 381a3664
No related merge requests found
Showing with 22 additions and 26 deletions
+22 -26
......@@ -5,13 +5,10 @@ To get started with a template, simply double-click it.
### Signal Names
The `name` property of `RACSignal` is currently only functional in `DEBUG`
builds, which means that you won't have access to meaningful names in
Instruments if you're profiling a Release build.
The `name` property of `RACSignal` requires that the `RAC_DEBUG_SIGNAL_NAMES`
environment variable be set, which means that you won't have access to
meaningful names in Instruments by default.
As a workaround, you can do one of the following:
1. Run your application (instead of using the Profile action), then ask
Instruments to attach to the running process.
2. In your application's scheme, set the Profile action to use the "Debug"
configuration, then profile normally.
To add signal names, open your application's scheme in Xcode, select the Profile
action, and add `RAC_DEBUG_SIGNAL_NAMES` with a value of `1` to the list of
environment variables.
......@@ -10,11 +10,11 @@
@interface NSObject (RACDescription)
/// A simplified description of the receiver for Debug builds, which does not
/// invoke -description (and thus should be much faster in many cases).
/// A simplified description of the receiver, which does not invoke -description
/// (and thus should be much faster in many cases).
///
/// This method will return a constant string in Release builds, skipping any
/// work.
/// This is for debugging purposes only, and will return a constant string
/// unless the RAC_DEBUG_SIGNAL_NAMES environment variable is set.
- (NSString *)rac_description;
@end
......@@ -12,11 +12,11 @@
@implementation NSObject (RACDescription)
- (NSString *)rac_description {
#ifdef DEBUG
return [[NSString alloc] initWithFormat:@"<%@: %p>", self.class, self];
#else
return @"(description skipped)";
#endif
if (getenv("RAC_DEBUG_SIGNAL_NAMES") != NULL) {
return [[NSString alloc] initWithFormat:@"<%@: %p>", self.class, self];
} else {
return @"(description skipped)";
}
}
@end
......
......@@ -43,7 +43,7 @@
return invocation.rac_returnValue;
}]
replayLast]
setNameWithFormat:@"%@ -rac_liftSelector: %@ withSignalsFromArray: %@", [self rac_description], NSStringFromSelector(selector), signals];
setNameWithFormat:@"%@ -rac_liftSelector: %s withSignalsFromArray: %@", [self rac_description], sel_getName(selector), signals];
}
- (RACSignal *)rac_liftSelector:(SEL)selector withSignals:(RACSignal *)firstSignal, ... {
......@@ -62,7 +62,7 @@
return [[self
rac_liftSelector:selector withSignalsFromArray:signals]
setNameWithFormat:@"%@ -rac_liftSelector: %@ withSignals: %@", [self rac_description], NSStringFromSelector(selector), signals];
setNameWithFormat:@"%@ -rac_liftSelector: %s withSignals: %@", [self rac_description], sel_getName(selector), signals];
}
@end
......
......@@ -181,7 +181,7 @@ static RACSignal *NSObjectRACSignalForSelector(NSObject *self, SEL selector, Pro
Class class = RACSwizzleClass(self);
NSCAssert(class != nil, @"Could not swizzle class of %@", self);
subject = [[RACSubject subject] setNameWithFormat:@"%@ -rac_signalForSelector: %@", self.rac_description, NSStringFromSelector(selector)];
subject = [[RACSubject subject] setNameWithFormat:@"%@ -rac_signalForSelector: %s", self.rac_description, sel_getName(selector)];
objc_setAssociatedObject(self, aliasSelector, subject, OBJC_ASSOCIATION_RETAIN);
[self.rac_deallocDisposable addDisposable:[RACDisposable disposableWithBlock:^{
......
......@@ -154,7 +154,7 @@ NSString * const RACSchedulerCurrentSchedulerKey = @"RACSchedulerCurrentSchedule
// This doesn't actually need to be __block qualified, but Clang
// complains otherwise. :C
__block NSLock *lock = [[NSLock alloc] init];
lock.name = [NSString stringWithFormat:@"%@ %@", self, NSStringFromSelector(_cmd)];
lock.name = [NSString stringWithFormat:@"%@ %s", self, sel_getName(_cmd)];
__block NSUInteger rescheduleCount = 0;
......
......@@ -82,7 +82,7 @@ typedef RACStream * (^RACStreamBindBlock)(id value, BOOL *stop);
/// Sets the name of the receiver to the given format string.
///
/// This is for debugging purposes only, and won't do anything unless the
/// RAC_DEBUG_SIGNAL_NAMES preprocessor macro is defined.
/// RAC_DEBUG_SIGNAL_NAMES environment variable is set.
///
/// Returns the receiver, for easy method chaining.
- (instancetype)setNameWithFormat:(NSString *)format, ... NS_FORMAT_FUNCTION(1, 2);
......
......@@ -48,7 +48,8 @@
#pragma mark Naming
- (instancetype)setNameWithFormat:(NSString *)format, ... {
#ifdef RAC_DEBUG_SIGNAL_NAMES
if (getenv("RAC_DEBUG_SIGNAL_NAMES") == NULL) return self;
NSCParameterAssert(format != nil);
va_list args;
......@@ -58,8 +59,6 @@
va_end(args);
self.name = str;
#endif
return self;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment