|
1 | | -#### Installing with Cocoapods |
| 1 | +## Installing with Cocoapods |
2 | 2 |
|
3 | 3 | SimulatorStatusMagic is available through [CocoaPods](http://cocoapods.org). To install, simply add the following line to your Podfile: |
4 | 4 |
|
5 | 5 | ```ruby |
6 | 6 | pod 'SimulatorStatusMagic', :configurations => ['Debug'] |
7 | 7 | ``` |
8 | 8 |
|
9 | | -#### Installing with Carthage |
| 9 | +## Installing with Carthage |
10 | 10 |
|
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. |
12 | 12 |
|
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`: |
21 | 14 | ``` |
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" |
27 | 16 | ``` |
| 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. |
28 | 19 |
|
29 | | -In the Input Files section add: |
30 | | - |
31 | | -- `$(SRCROOT)/Carthage/Build/iOS/SimulatorStatusMagiciOS.framework` |
| 20 | + |
32 | 21 |
|
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). |
34 | 23 |
|
35 | | -#### Installing without a dependency manager |
| 24 | + |
36 | 25 |
|
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 |
38 | 31 |
|
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 | +``` |
52 | 41 |
|
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. |
0 commit comments