Skip to content

Commit 72fa6fb

Browse files
committed
Merge branch 'master' into patch-2
2 parents 05eb3ff + 2806a84 commit 72fa6fb

18 files changed

Lines changed: 123 additions & 55 deletions

Artwork/linked-frameworks.png

94.6 KB
Loading

Artwork/run-script-phase.png

106 KB
Loading

INSTALLATION.md

Lines changed: 25 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,42 @@
1-
#### Installing with Cocoapods
1+
## Installing with Cocoapods
22

33
SimulatorStatusMagic is available through [CocoaPods](http://cocoapods.org). To install, simply add the following line to your Podfile:
44

55
```ruby
66
pod 'SimulatorStatusMagic', :configurations => ['Debug']
77
```
88

9-
#### Installing with Carthage
9+
## Installing with Carthage
1010

11-
SimlatorStatusMagic is also available through [Carthage](https://github.com/Carthage/Carthage). Carthage will not make any modifications to your project, so installation is more involved than with CocoaPods. To get started, ensure that you have installed Carthage and then create a Cartfile with the following content:
11+
SimlatorStatusMagic is also available through [Carthage](https://github.com/Carthage/Carthage). Carthage will not make any modifications to your project, so installation is more involved than with CocoaPods. This describes a way of adding `SimulatorStatusMagic` so that it is only imported for `DEBUG` build configurations.
1212

13-
```ruby
14-
github "shinydevelopment/SimulatorStatusMagic"
15-
```
16-
17-
Next bootstrap your environment by executing carthage update:
18-
19-
```sh
20-
$ carthage update
13+
1. Add `SimulatorStatusMagic` to your `Cartfile`:
2114
```
22-
23-
Next drag SimulatorStatusMagiciOS.framework from Carthage/Build/iOS and onto your project and link it with your application target. Then select your application target within Xcode, navigate to the Build Phases panel and click the + icon and select New Run Script Phase. Set the content to:
24-
25-
```sh
26-
/usr/local/bin/carthage copy-frameworks
15+
github "shinydevelopment/SimulatorStatusMagic"
2716
```
17+
2. Run `carthage update SimulatorStatusMagic --platform iOS`
18+
3. Add the framework file directly from `Carthage/Build/iOS/` to `Linked Frameworks and Libraries`, **NOT** Embedded Libraries. Ensure that the file is reference at this location so that future `carthage update` builds will be embedded correctly.
2819

29-
In the Input Files section add:
30-
31-
- `$(SRCROOT)/Carthage/Build/iOS/SimulatorStatusMagiciOS.framework`
20+
![Linked Frameworks and Libraries](Artwork/linked-frameworks.png)
3221

33-
Now build your application target and everything should be set.
22+
4. Add the `embed-debug-only-framework.sh` script found [here](https://gist.github.com/kenthumphries/cf04683184217c7331f9c213c556c65a) and discussed [here](https://github.com/shinydevelopment/SimulatorStatusMagic/blob/master/INSTALLATION.md).
3423

35-
#### Installing without a dependency manager
24+
![Embed run script phase](Artwork/run-script-phase.png)
3625

37-
SimulatorStatusMagic can also be included as a dynamic framework by following steps:
26+
5. Add code referencing `SimulatorStatusMagiciOS` inside `#if canImport ... #endif` blocks in your `AppDelegate`:
27+
```swift
28+
#if DEBUG
29+
import SimulatorStatusMagiciOS
30+
#endif
3831

39-
* Download the source code and open the XCode project
40-
* Run the target `SimulatorStatusMagicUniversalFramework` which generates a universal framework for both device and simulator.
41-
* Drag and drop the generated framework into your project.
42-
43-
Note that SimulatorStatusMagic calls non-public APIs and should not be submitted to the app store. If you wish to add SimulatorStatusMagic for Debug configuration only, follow these steps:
44-
45-
* Ensure that SimulatorStatusMagiciOS.framework is within your project folder, but not added to any project target
46-
* In app target Build Settings, expand the Framework Search Paths and add the framework's containing folder in the Debug configuration. For example, `$(SRCROOT)/ThirdPartyFrameworks/`
47-
* Now you should be able to import and compile with SimulatorStatusMagiciOS, but app will crash with error:
48-
`dyld: Library not loaded: @rpath/SimulatorStatusMagiciOS.framework/SimulatorStatusMagiciOS`
49-
* To solve this, open app target's Build Phases and click the + icon then select New Run Script Phase
50-
* Configure Run Script phase to embed SimulatorStatusMagiciOS.framework only when Debug configuration is used
51-
* Use the script `embed-debug-only-framework.sh` that is [available here](https://gist.github.com/kenthumphries/cf04683184217c7331f9c213c556c65a)
32+
@UIApplicationMain
33+
final class AppDelegate: UIResponder, UIApplicationDelegate {
34+
func application(_ application: UIApplication, didFinishLaunchingWithOptions options: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool {
35+
#if DEBUG
36+
SDStatusBarManager.sharedInstance()?.enableOverrides()
37+
#endif
38+
}
39+
}
40+
```
5241

53-
Now that SimilatorStatusMagic is added only for Debug configuration, you must ensure that any imports or calls to SDStatusBarManager are made between `#if DEBUG` and `#endif`.
42+
6. Run your app in `DEBUG` to see the status bar changes in effect.

README.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
# :boom: Important Note on iOS 12 Compatibility :boom:
2-
3-
The latest version is mostly working with iOS 12 thanks to [@cysp](https://github.com/cysp)'s kind pull request, however the new date status bar functionality on the iPad is not yet supported. It is being discussed in [#68](https://github.com/shinydevelopment/SimulatorStatusMagic/issues/68) and [#72](https://github.com/shinydevelopment/SimulatorStatusMagic/issues/72), and of course pull requests with support for this are very welcome.
4-
5-
---
6-
71
## Simulator Status Magic
82

93
Modify the iOS Simulator so that it has a perfect status bar, then run your app and take perfect screenshots every time. The modifications made are designed to match the images you see on the Apple site and are as follows:
104

115
* 9:41 AM is displayed for the time.
126
* The battery is full and shows 100%.
13-
* On iPhone: The carrier text is removed, 5 bars of cellular signal and full WiFi bars are displayed.
14-
* On iPad: The carrier text is set to "iPad" and full WiFi bars are displayed.
7+
* 5 bars of cellular signal and full WiFi bars are displayed.
8+
* Tue Jan 9 is displayed for the date (iPad only)
159

1610
### How do I use it?
1711

@@ -27,9 +21,9 @@ Run the app again and click "Restore Default Status Bar". Resetting the iOS Simu
2721

2822
### I have a script to take my screenshots, can I automate this?
2923

30-
Yes! SimulatorStatusMagic is available via [CocoaPods](http://cocoapods.org), [Carthage](https://github.com/Carthage/Carthage) and as a standalone source release. [Installation instructions](https://github.com/shinydevelopment/SimulatorStatusMagic/blob/master/INSTALLATION.md) are available for each method.
24+
Yes! SimulatorStatusMagic is available via [CocoaPods](http://cocoapods.org), [Carthage](https://github.com/Carthage/Carthage) and as a standalone source release. [Installation instructions](https://github.com/shinydevelopment/SimulatorStatusMagic/blob/master/INSTALLATION.md) are available.
3125

32-
It is recommended to only include `SDStatusBarManager` in your debug configuration so that the code is never included in release builds. Then, when you want to apply a perfect status bar, call `[[SDStatusBarManager sharedInstance] enableOverrides]`. To restore the standard status bar, call `[[SDStatusBarManager sharedInstance] disableOverrides]`.
26+
It is recommended to **only** include `SDStatusBarManager` in your debug configuration so that the code is **never** included in release builds. When you want to apply a perfect status bar, call `[[SDStatusBarManager sharedInstance] enableOverrides]`. To restore the standard status bar, call `[[SDStatusBarManager sharedInstance] disableOverrides]`.
3327

3428
### What about automation of the sample app?
3529

SDStatusBarManager/SDStatusBarManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ typedef NS_ENUM(NSInteger, SDStatusBarManagerNetworkType)
4545

4646
@property (copy, nonatomic) NSString *carrierName;
4747
@property (copy, nonatomic) NSString *timeString;
48+
@property (copy, nonatomic) NSString *dateString;
4849
@property (assign, nonatomic, readonly) BOOL usingOverrides;
4950
@property (assign, nonatomic) SDStatusBarManagerBluetoothState bluetoothState;
5051
@property (assign, nonatomic) SDStatusBarManagerNetworkType networkType;

SDStatusBarManager/SDStatusBarManager.m

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
static NSString * const SDStatusBarManagerNetworkTypeKey = @"network_type";
3939
static NSString * const SDStatusBarManagerCarrierNameKey = @"carrier_name";
4040
static NSString * const SDStatusBarManagerTimeStringKey = @"time_string";
41+
static NSString * const SDStatusBarManagerDateStringKey = @"date_string";
4142

4243
@interface SDStatusBarManager ()
4344

@@ -54,7 +55,7 @@ - (instancetype)init
5455
if (self) {
5556
// Set any defaults for the status bar
5657
self.batteryDetailEnabled = YES;
57-
self.iPadDateEnabled = NO;
58+
self.iPadDateEnabled = YES;
5859
self.iPadGsmSignalEnabled = NO;
5960
}
6061
return self;
@@ -65,6 +66,7 @@ - (void)enableOverrides
6566
self.usingOverrides = YES;
6667

6768
self.overrider.timeString = [self localizedTimeString];
69+
self.overrider.dateString = [self localizedDateString];
6870
self.overrider.carrierName = self.carrierName;
6971
self.overrider.bluetoothEnabled = self.bluetoothState != SDStatusBarManagerBluetoothHidden;
7072
self.overrider.bluetoothConnected = self.bluetoothState == SDStatusBarManagerBluetoothVisibleConnected;
@@ -158,6 +160,21 @@ - (NSString *)timeString
158160
return [self.userDefaults valueForKey:SDStatusBarManagerTimeStringKey];
159161
}
160162

163+
- (void)setDateString:(NSString *)dateString {
164+
if ([self.dateString isEqualToString:dateString]) return;
165+
166+
[self.userDefaults setObject:dateString forKey:SDStatusBarManagerDateStringKey];
167+
168+
if (self.usingOverrides) {
169+
[self enableOverrides];
170+
}
171+
}
172+
173+
- (NSString *)dateString
174+
{
175+
return [self.userDefaults valueForKey:SDStatusBarManagerDateStringKey];
176+
}
177+
161178
- (NSUserDefaults *)userDefaults
162179
{
163180
if (!_userDefaults) {
@@ -217,6 +234,23 @@ - (NSString *)localizedTimeString
217234
return [formatter stringFromDate:[[NSCalendar currentCalendar] dateFromComponents:components]];
218235
}
219236

237+
- (NSString *)localizedDateString
238+
{
239+
if (self.dateString.length > 0) {
240+
return self.dateString;
241+
}
242+
243+
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
244+
formatter.dateFormat = [[NSDateFormatter dateFormatFromTemplate:@"EEE MMM d" options:0 locale:NSLocale.currentLocale] stringByReplacingOccurrencesOfString:@"," withString:@""];
245+
246+
NSDateComponents *components = [[NSCalendar currentCalendar] components: NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond fromDate:[NSDate date]];
247+
components.day = 9;
248+
components.month = 1;
249+
components.year = 2007;
250+
251+
return [formatter stringFromDate:[[NSCalendar currentCalendar] dateFromComponents:components]];
252+
}
253+
220254
#pragma mark Singleton instance
221255
+ (SDStatusBarManager *)sharedInstance
222256
{

SDStatusBarManager/SDStatusBarOverrider.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
@protocol SDStatusBarOverrider <NSObject>
3030

3131
@property (copy, nonatomic) NSString *timeString;
32+
@property (copy, nonatomic) NSString *dateString;
3233
@property (copy, nonatomic) NSString* carrierName;
3334

3435
@property (assign, nonatomic) BOOL bluetoothEnabled;

SDStatusBarManager/SDStatusBarOverriderPost10_0.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ + (StatusBarOverrideData *)getStatusBarOverrideData;
169169
@implementation SDStatusBarOverriderPost10_0
170170

171171
@synthesize timeString;
172+
@synthesize dateString;
172173
@synthesize carrierName;
173174
@synthesize bluetoothConnected;
174175
@synthesize bluetoothEnabled;

SDStatusBarManager/SDStatusBarOverriderPost10_3.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ + (StatusBarOverrideData *)getStatusBarOverrideData;
147147
@implementation SDStatusBarOverriderPost10_3
148148

149149
@synthesize timeString;
150+
@synthesize dateString;
150151
@synthesize carrierName;
151152
@synthesize bluetoothConnected;
152153
@synthesize bluetoothEnabled;

SDStatusBarManager/SDStatusBarOverriderPost11_0.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ + (StatusBarOverrideData *)getStatusBarOverrideData;
150150
@implementation SDStatusBarOverriderPost11_0
151151

152152
@synthesize timeString;
153+
@synthesize dateString;
153154
@synthesize carrierName;
154155
@synthesize bluetoothConnected;
155156
@synthesize bluetoothEnabled;

0 commit comments

Comments
 (0)