diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/PreviewColor.png b/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/PreviewColor.png new file mode 100644 index 00000000..540d291e Binary files /dev/null and b/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/PreviewColor.png differ diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/PreviewSymbol.png b/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/PreviewSymbol.png new file mode 100644 index 00000000..1b600c04 Binary files /dev/null and b/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/PreviewSymbol.png differ diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/PreviewSymbolFormatted.png b/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/PreviewSymbolFormatted.png new file mode 100644 index 00000000..ba3266f1 Binary files /dev/null and b/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/PreviewSymbolFormatted.png differ diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/SFSymbolsIcon.png b/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/SFSymbolsIcon.png new file mode 100644 index 00000000..67e778ce Binary files /dev/null and b/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/SFSymbolsIcon.png differ diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/SampleIcon2.png b/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/SampleIcon2.png new file mode 100644 index 00000000..d8c7b787 Binary files /dev/null and b/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/SampleIcon2.png differ diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/SwiftUIIcon.png b/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/SwiftUIIcon.png new file mode 100644 index 00000000..b40e4283 Binary files /dev/null and b/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/SwiftUIIcon.png differ diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/XcodeNewFile.png b/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/XcodeNewFile.png new file mode 100644 index 00000000..a8d2d28b Binary files /dev/null and b/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/XcodeNewFile.png differ diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/XcodeSidebar.png b/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/XcodeSidebarStoryboard.png similarity index 100% rename from Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/XcodeSidebar.png rename to Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/XcodeSidebarStoryboard.png diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/XcodeSidebarSwiftUI.png b/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/XcodeSidebarSwiftUI.png new file mode 100644 index 00000000..bcfe6a0d Binary files /dev/null and b/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/XcodeSidebarSwiftUI.png differ diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/XcodeTemplateOptions.png b/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/XcodeTemplateOptions.png deleted file mode 100644 index 9ed45708..00000000 Binary files a/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/XcodeTemplateOptions.png and /dev/null differ diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/XcodeTemplateOptionsStoryboard.png b/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/XcodeTemplateOptionsStoryboard.png new file mode 100644 index 00000000..12363e78 Binary files /dev/null and b/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/XcodeTemplateOptionsStoryboard.png differ diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/XcodeTemplateOptionsSwiftUI.png b/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/XcodeTemplateOptionsSwiftUI.png new file mode 100644 index 00000000..2d61131c Binary files /dev/null and b/Sources/NetworkReachability/NetworkReachability.docc/Images/Tutorials/XcodeTemplateOptionsSwiftUI.png differ diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Projects/ProjectIntegrate-SwiftUI.zip b/Sources/NetworkReachability/NetworkReachability.docc/Projects/ProjectIntegrate-SwiftUI.zip new file mode 100644 index 00000000..63e88143 Binary files /dev/null and b/Sources/NetworkReachability/NetworkReachability.docc/Projects/ProjectIntegrate-SwiftUI.zip differ diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Projects/ProjectIntegrate.zip b/Sources/NetworkReachability/NetworkReachability.docc/Projects/ProjectIntegrate-UIKit.zip similarity index 100% rename from Sources/NetworkReachability/NetworkReachability.docc/Projects/ProjectIntegrate.zip rename to Sources/NetworkReachability/NetworkReachability.docc/Projects/ProjectIntegrate-UIKit.zip diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Projects/ProjectSetup-SwiftUI.zip b/Sources/NetworkReachability/NetworkReachability.docc/Projects/ProjectSetup-SwiftUI.zip new file mode 100644 index 00000000..ca3e6fb1 Binary files /dev/null and b/Sources/NetworkReachability/NetworkReachability.docc/Projects/ProjectSetup-SwiftUI.zip differ diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Projects/ProjectSetup.zip b/Sources/NetworkReachability/NetworkReachability.docc/Projects/ProjectSetup-UIKit.zip similarity index 100% rename from Sources/NetworkReachability/NetworkReachability.docc/Projects/ProjectSetup.zip rename to Sources/NetworkReachability/NetworkReachability.docc/Projects/ProjectSetup-UIKit.zip diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Projects/ProjectUI-SwiftUI.zip b/Sources/NetworkReachability/NetworkReachability.docc/Projects/ProjectUI-SwiftUI.zip new file mode 100644 index 00000000..18cbe9a3 Binary files /dev/null and b/Sources/NetworkReachability/NetworkReachability.docc/Projects/ProjectUI-SwiftUI.zip differ diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Projects/ProjectUI.zip b/Sources/NetworkReachability/NetworkReachability.docc/Projects/ProjectUI-UIKit.zip similarity index 100% rename from Sources/NetworkReachability/NetworkReachability.docc/Projects/ProjectUI.zip rename to Sources/NetworkReachability/NetworkReachability.docc/Projects/ProjectUI-UIKit.zip diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/ComputeColor.swift b/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/ComputeColor.swift new file mode 100644 index 00000000..93169904 --- /dev/null +++ b/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/ComputeColor.swift @@ -0,0 +1,44 @@ +import SwiftUI + +struct ContentView: View { + + @ObservedObject + var reachabilityManager: ReachabilityManager + + var body: some View { + Text("Hello, world!") + .padding() + } + + private var symbolName: String { + switch reachabilityManager.reachability { + case .wifi: + return "wifi.circle.fill" + case .ethernet: + return "cable.connector" + case .unknown: + return "questionmark.circle.fill" + case .cellular: + return "antenna.radiowaves.left.and.right.circle.fill" + case .disconnected: + return "xmark.circle.fill" + } + } + + private var backgroundColor: Color { + switch reachabilityManager.reachability { + case .disconnected: + return .red + case .unknown: + return .yellow + case .wifi, .ethernet, .cellular: + return .green + } + } +} + +struct ContentView_Previews: PreviewProvider { + static var previews: some View { + ContentView(reachabilityManager: .init()) + } +} diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/ComputeSymbol.swift b/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/ComputeSymbol.swift new file mode 100644 index 00000000..2312385f --- /dev/null +++ b/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/ComputeSymbol.swift @@ -0,0 +1,33 @@ +import SwiftUI + +struct ContentView: View { + + @ObservedObject + var reachabilityManager: ReachabilityManager + + var body: some View { + Text("Hello, world!") + .padding() + } + + private var symbolName: String { + switch reachabilityManager.reachability { + case .wifi: + return "wifi.circle.fill" + case .ethernet: + return "cable.connector" + case .unknown: + return "questionmark.circle.fill" + case .cellular: + return "antenna.radiowaves.left.and.right.circle.fill" + case .disconnected: + return "xmark.circle.fill" + } + } +} + +struct ContentView_Previews: PreviewProvider { + static var previews: some View { + ContentView(reachabilityManager: .init()) + } +} diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/ContentView.swift b/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/ContentView.swift new file mode 100644 index 00000000..0ec9f8a0 --- /dev/null +++ b/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/ContentView.swift @@ -0,0 +1,14 @@ +import SwiftUI + +struct ContentView: View { + var body: some View { + Text("Hello, world!") + .padding() + } +} + +struct ContentView_Previews: PreviewProvider { + static var previews: some View { + ContentView() + } +} diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/CreateStatus.swift b/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/CreateStatus.swift new file mode 100644 index 00000000..a03186e2 --- /dev/null +++ b/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/CreateStatus.swift @@ -0,0 +1,13 @@ +final class ReachabilityManager { + + enum Status { + case ethernet + case wifi + case cellular + case unknown + case disconnected + } + + var reachability: Status = .disconnected + +} diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/FormatSymbol.swift b/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/FormatSymbol.swift new file mode 100644 index 00000000..b64e6ff1 --- /dev/null +++ b/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/FormatSymbol.swift @@ -0,0 +1,45 @@ +import SwiftUI + +struct ContentView: View { + + @ObservedObject + var reachabilityManager: ReachabilityManager + + var body: some View { + Image(systemName: symbolName) + .resizable() + .frame(width: 60, height: 60) + } + + private var symbolName: String { + switch reachabilityManager.reachability { + case .wifi: + return "wifi.circle.fill" + case .ethernet: + return "cable.connector" + case .unknown: + return "questionmark.circle.fill" + case .cellular: + return "antenna.radiowaves.left.and.right.circle.fill" + case .disconnected: + return "xmark.circle.fill" + } + } + + private var backgroundColor: Color { + switch reachabilityManager.reachability { + case .disconnected: + return .red + case .unknown: + return .yellow + case .wifi, .ethernet, .cellular: + return .green + } + } +} + +struct ContentView_Previews: PreviewProvider { + static var previews: some View { + ContentView(reachabilityManager: .init()) + } +} diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/ImplementManager.swift b/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/ImplementManager.swift new file mode 100644 index 00000000..675dd33e --- /dev/null +++ b/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/ImplementManager.swift @@ -0,0 +1,40 @@ +import Combine +import Network +import NetworkReachability + +final class ReachabilityManager: ObservableObject { + + init() { + setUp() + } + + enum Status { + case ethernet + case wifi + case cellular + case unknown + case disconnected + } + + @Published + var reachability: Status = .disconnected + + private var monitor: NetworkMonitor! + + private func setUp() { + monitor = .init() { [weak self] _, networkPath in + guard let self = self else { return } + if networkPath.usesInterfaceType(.wiredEthernet) { + self.reachability = .ethernet + } else if networkPath.usesInterfaceType(.wifi) { + self.reachability = .wifi + } else if networkPath.usesInterfaceType(.cellular) { + self.reachability = .cellular + } else if networkPath.status == .satisfied { + self.reachability = .unknown + } else { + self.reachability = .disconnected + } + } + } +} diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/MakeObservableObject.swift b/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/MakeObservableObject.swift new file mode 100644 index 00000000..8689a211 --- /dev/null +++ b/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/MakeObservableObject.swift @@ -0,0 +1,16 @@ +import Combine + +final class ReachabilityManager: ObservableObject { + + enum Status { + case ethernet + case wifi + case cellular + case unknown + case disconnected + } + + @Published + var reachability: Status = .disconnected + +} diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/ReachabilityApp.swift b/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/ReachabilityApp.swift new file mode 100644 index 00000000..b7332487 --- /dev/null +++ b/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/ReachabilityApp.swift @@ -0,0 +1,10 @@ +import SwiftUI + +@main +struct ReachabilityApp: App { + var body: some Scene { + WindowGroup { + ContentView(reachabilityManager: ReachabilityManager()) + } + } +} diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/ReachabilityAppTemplate.swift b/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/ReachabilityAppTemplate.swift new file mode 100644 index 00000000..6e68dd68 --- /dev/null +++ b/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/ReachabilityAppTemplate.swift @@ -0,0 +1,10 @@ +import SwiftUI + +@main +struct ReachabilityApp: App { + var body: some Scene { + WindowGroup { + ContentView() + } + } +} diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/UseColor.swift b/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/UseColor.swift new file mode 100644 index 00000000..33f1edc9 --- /dev/null +++ b/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/UseColor.swift @@ -0,0 +1,50 @@ +import SwiftUI + +struct ContentView: View { + + @ObservedObject + var reachabilityManager: ReachabilityManager + + var body: some View { + ZStack { + Image(systemName: symbolName) + .resizable() + .frame(width: 60, height: 60) + } + .frame(maxWidth: .infinity, + maxHeight: .infinity) + .background(backgroundColor) + } + + private var symbolName: String { + switch reachabilityManager.reachability { + case .wifi: + return "wifi.circle.fill" + case .ethernet: + return "cable.connector" + case .unknown: + return "questionmark.circle.fill" + case .cellular: + return "antenna.radiowaves.left.and.right.circle.fill" + case .disconnected: + return "xmark.circle.fill" + } + } + + private var backgroundColor: Color { + switch reachabilityManager.reachability { + case .disconnected: + return .red + case .unknown: + return .yellow + case .wifi, .ethernet, .cellular: + return .green + } + } +} + +struct ContentView_Previews: PreviewProvider { + static var previews: some View { + ContentView(reachabilityManager: .init()) + } +} diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/UseSymbol.swift b/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/UseSymbol.swift new file mode 100644 index 00000000..cac8a525 --- /dev/null +++ b/Sources/NetworkReachability/NetworkReachability.docc/Snippets/Tutorials/UseSymbol.swift @@ -0,0 +1,43 @@ +import SwiftUI + +struct ContentView: View { + + @ObservedObject + var reachabilityManager: ReachabilityManager + + var body: some View { + Image(systemName: symbolName) + } + + private var symbolName: String { + switch reachabilityManager.reachability { + case .wifi: + return "wifi.circle.fill" + case .ethernet: + return "cable.connector" + case .unknown: + return "questionmark.circle.fill" + case .cellular: + return "antenna.radiowaves.left.and.right.circle.fill" + case .disconnected: + return "xmark.circle.fill" + } + } + + private var backgroundColor: Color { + switch reachabilityManager.reachability { + case .disconnected: + return .red + case .unknown: + return .yellow + case .wifi, .ethernet, .cellular: + return .green + } + } +} + +struct ContentView_Previews: PreviewProvider { + static var previews: some View { + ContentView(reachabilityManager: .init()) + } +} diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Tutorials.tutorial b/Sources/NetworkReachability/NetworkReachability.docc/Tutorials.tutorial index 087515a9..0388b51b 100644 --- a/Sources/NetworkReachability/NetworkReachability.docc/Tutorials.tutorial +++ b/Sources/NetworkReachability/NetworkReachability.docc/Tutorials.tutorial @@ -3,14 +3,22 @@ Step-by-step tutorials to learn NetworkReachability using Xcode 13 @Image(source: "Intro.png", alt: "A MacBook Pro Running Xcode") } - @Chapter(name: "Build a Sample App") { - Create a sample iOS application using NetworkReachability + @Chapter(name: "UIKit Sample App") { + Create a sample iOS application with NetworkReachability using UIKit - @Image(source: "SampleIcon.png", alt: "Xcode Icon") + @Image(source: "SampleIcon.png", alt: "Sample App Icon") @TutorialReference(tutorial: "doc:SampleProjectSetup-UIKit") @TutorialReference(tutorial: "doc:SampleProjectUI-UIKit") @TutorialReference(tutorial: "doc:SampleProjectIntegration-UIKit") } + @Chapter(name: "SwiftUI Sample App") { + Create a sample iOS application with NetworkReachability using SwiftUI + + @Image(source: "SampleIcon2.png", alt: "Sample App Icon") + @TutorialReference(tutorial: "doc:SampleProjectSetup-SwiftUI") + @TutorialReference(tutorial: "doc:SampleProjectIntegration-SwiftUI") + @TutorialReference(tutorial: "doc:SampleProjectUI-SwiftUI") + } @Resources { Explore more resources for learning about NetworkReachability. @Downloads(destination: "https://github.com/vsanthanam/NetworkReachability/releases") { diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Tutorials/SampleProject-SwiftUI/SampleProjectIntegration-SwiftUI.tutorial b/Sources/NetworkReachability/NetworkReachability.docc/Tutorials/SampleProject-SwiftUI/SampleProjectIntegration-SwiftUI.tutorial new file mode 100644 index 00000000..029ce26d --- /dev/null +++ b/Sources/NetworkReachability/NetworkReachability.docc/Tutorials/SampleProject-SwiftUI/SampleProjectIntegration-SwiftUI.tutorial @@ -0,0 +1,36 @@ +@Tutorial(time: 5, projectFiles: "ProjectIntegrate-SwiftUI.zip") { + @XcodeRequirement(title: "Xcode 13", destination: "https://developer.apple.com/download/") + @Intro(title: "Implementing Reachability") { + This tutorial guides you through the process of consuming reachability data in your application. + } + + @Section(title: "Integrate Reachability") { + @ContentAndMedia { + Create an `ObservableObject` for use with SwiftUI using NetworkReachability and callback closures. + @Image(source: "SampleIcon2.png", alt: "Sample App Icon") + } + + @Steps { + @Step { + Choose File > New > File, select iOS as the platform, select the “Swift File” template, and click Next. Name the new file "ReachabilityManager.swift" and click Create. + + @Image(source: "XcodeNewFile", alt: "New File Chooser") + } + + @Step { + Create a new class, and create an enumeration representing the various reachability options within your new class. + @Code(name: "ReachabilityManager.swift", file: "CreateStatus.swift") + } + + @Step { + Make your class an `ObservableObject` and annotate the instance variable with the `@Published` property wrapper. + @Code(name: "ReachabilityManager.swift", file: "MakeObservableObject.swift") + } + + @Step { + Create a `NetworkMonitor` class and use the callback API to recieve updates from the monitor. + @Code(name: "ReachabilityManager.swift", file: "ImplementManager.swift") + } + } + } +} diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Tutorials/SampleProject-SwiftUI/SampleProjectSetup-SwiftUI.tutorial b/Sources/NetworkReachability/NetworkReachability.docc/Tutorials/SampleProject-SwiftUI/SampleProjectSetup-SwiftUI.tutorial new file mode 100644 index 00000000..a1b9c13d --- /dev/null +++ b/Sources/NetworkReachability/NetworkReachability.docc/Tutorials/SampleProject-SwiftUI/SampleProjectSetup-SwiftUI.tutorial @@ -0,0 +1,55 @@ +@Tutorial(time: 5, projectFiles: "ProjectSetup-SwiftUI.zip") { + @XcodeRequirement(title: "Xcode 13", destination: "https://developer.apple.com/download/") + @Intro(title: "SwiftUI Project Setup") { + This tutorial guides you through the process of creating a new SwiftUI application and adding NetworkReachability as a dependency using the Swift Package Manager within Xcode. + } + @Section(title: "Create a New Project") { + @ContentAndMedia { + Create a new project for an iOS Application and save it on your Mac. + @Image(source: "XcodeIcon.png", alt: "Xcode App Icon") + } + @Steps { + @Step { + Open Xcode and either click “Create a new Xcode project” in Xcode’s startup window, or choose File > New > Project. + @Image(source: "XcodeOpen.png", alt: "Xcode Dialog") + } + @Step { + In the template selector, select iOS as the platform, select the App template, and then click Next. + @Image(source: "XcodeTemplate.png", alt: "Xcode Template Selector") + } + @Step { + Enter “Reachability” as the product name, select “SwiftUI” for the interface and “Swift” for the language, and click Next. Choose a location to save the Reachability project on your Mac. + @Image(source: "XcodeTemplateOptionsSwiftUI.png", alt: "Xcode Template Options") + } + } + } + @Section(title: "Add NetworkReachability as a Dependency") { + @ContentAndMedia { + Use the Swift Package Manager to add NetworkReachability as a dependenct to your app target. + @Image(source: "SwiftPackageIcon.png", alt: "Swift Package ICon") + } + @Steps { + @Step { + Select your `.xcodeproj` file in the Xcode Sidebar, and select your app's target. + @Image(source: "XcodeSidebarSwiftUI.png", alt: "The Xcode Sidebar") + } + @Step { + Scroll to the "Frameworks, Libraries, and Embedded Content" section and choose the "+" button. + @Image(source: "XcodeAddLibrary.png", alt: "The Frameworks, Libraries, and Embedded Content Section") + } + @Step { + In the popup, choose "Add Other ..." > "Add Package Dependency ..." + @Image(source: "XcodeChooseFramework.png", alt: "Framework Selector") + } + @Step { + In the top right-hand corner of the package selector, enter the URL `https://github.com/vsanthanam/NetworkReachability.git` + @Image(source: "XcodePackageChooser.png", alt: "Framework Selector") + Add the version information if necessary. + } + @Step { + Choose "Add Package" and confirm your selected target. + @Image(source: "XcodeAddPackageConfirm.png", alt: "Confirm Package") + } + } + } +} diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Tutorials/SampleProject-SwiftUI/SampleProjectUI-SwiftUI.tutorial b/Sources/NetworkReachability/NetworkReachability.docc/Tutorials/SampleProject-SwiftUI/SampleProjectUI-SwiftUI.tutorial new file mode 100644 index 00000000..69eec29b --- /dev/null +++ b/Sources/NetworkReachability/NetworkReachability.docc/Tutorials/SampleProject-SwiftUI/SampleProjectUI-SwiftUI.tutorial @@ -0,0 +1,65 @@ +@Tutorial(time: 10, projectFiles: "ProjectUI-SwiftUI.zip") { + @XcodeRequirement(title: "Xcode 13", destination: "https://developer.apple.com/download/") + @Intro(title: "Canvas Setup") { + This tutorial guides you through the process of creating your app's user interface using SwiftUI and SF Symbols. + } + @Section(title: "Observe reachability in your view") { + @ContentAndMedia { + Observe an instance of `ReachabilityManager` and use it to build your symbols. + @Image(source: "SFSymbolsIcon", alt: "SF Symbols Icon") + } + @Steps { + @Step { + Select `ContentView.swift` in the Xcode Sidebar + @Image(source: "XcodeSidebarSwiftUI", alt: "The Xcode Sidebar") + } + @Step { + Add a new observed object and compute the symbol name + @Code(name: "ContentView.swift", file: "ComputeSymbol.swift", previousFile: "ContentView.swift") + } + @Step { + Add a property to compute the background color + @Code(name: "ContentView.swift", file: "ComputeColor.swift") + } + @Step { + Select `ReachabilityApp.swift` in the Xcode Sidebar + @Image(source: "XcodeSidebarSwiftUI", alt: "The Xcode Sidebar") + } + @Step { + Initialize an instance of `ReachabilityManager` and pass it to your content view. + @Code(name: "ReachabilityApp.swift", file: "ReachabilityApp.swift", previousFile: "ReachabilityAppTemplate.swift") + } + } + } + @Section(title: "Create the ContentView") { + @ContentAndMedia { + Use SwiftUI to create your sample app's view hiearachy. + @Image(source: "SwiftUIIcon", alt: "Swift UI Icon") + } + @Steps { + @Step { + Add a symbol to the view body + @Code(name: "ContentView.swift", file: "UseSymbol.swift", previousFile: "ComputeColor.swift") { + @Image(source: "PreviewSymbol", alt: "Swift UI Preview") + } + } + @Step { + Size the symbol + @Code(name: "ContentView.swift", file: "FormatSymbol.swift") { + @Image(source: "PreviewSymbolFormatted", alt: "Swift UI Preview") + } + } + @Step { + Wrap the symbol in a ZStack and add a background color + @Code(name: "ContentView.swift", file: "UseColor.swift") { + @Image(source: "PreviewColor", alt: "Swift UI Preview") + } + } + @Step { + Run the app and try changing the targe device's network connectivity. Your UI should update to match. + @Image(source: "Simulator-iPhone8-Integration", alt: "iPhone 8 Simulator") + This works best on device as the iPhone Simulator's reachability callbacks are spotty at best. If you have a Mac with Apple Silicon, you can build for iPad and run on your machine as well. + } + } + } +} diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Tutorials/SampleProjectIntegration-UIKit.tutorial b/Sources/NetworkReachability/NetworkReachability.docc/Tutorials/SampleProject-UIKit/SampleProjectIntegration-UIKit.tutorial similarity index 82% rename from Sources/NetworkReachability/NetworkReachability.docc/Tutorials/SampleProjectIntegration-UIKit.tutorial rename to Sources/NetworkReachability/NetworkReachability.docc/Tutorials/SampleProject-UIKit/SampleProjectIntegration-UIKit.tutorial index 944bf415..bae86369 100644 --- a/Sources/NetworkReachability/NetworkReachability.docc/Tutorials/SampleProjectIntegration-UIKit.tutorial +++ b/Sources/NetworkReachability/NetworkReachability.docc/Tutorials/SampleProject-UIKit/SampleProjectIntegration-UIKit.tutorial @@ -1,4 +1,4 @@ -@Tutorial(time: 10, projectFiles: "ProjectIntegrate.zip") { +@Tutorial(time: 5, projectFiles: "ProjectIntegrate-UIKit.zip") { @XcodeRequirement(title: "Xcode 13", destination: "https://developer.apple.com/download/") @Intro(title: "Implementing Reachability") { This tutorial guides you through the process of consuming reachability data in your application. @@ -6,6 +6,7 @@ @Section(title: "Integrate Reachability") { @ContentAndMedia { Use delegation to update your application's user interface when its network connectivity changes. + @Image(source: "SampleIcon.png", alt: "Sample App Icon") } @Steps { @Step { @@ -27,7 +28,7 @@ @Step { Run the app and try changing the targe device's network connectivity. Your UI should update to match. @Image(source: "Simulator-iPhone8-Integration", alt: "iPhone 8 Simulator") - This works best on device, or when targeting Mac Catalyst, as the iPhone Simulator's reachability callbacks are spotty at best. + This works best on device as the iPhone Simulator's reachability callbacks are spotty at best. If you have a Mac with Apple Silicon, you can build for iPad and run on your machine as well. } } } diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Tutorials/SampleProjectSetup-UIKit.tutorial b/Sources/NetworkReachability/NetworkReachability.docc/Tutorials/SampleProject-UIKit/SampleProjectSetup-UIKit.tutorial similarity index 90% rename from Sources/NetworkReachability/NetworkReachability.docc/Tutorials/SampleProjectSetup-UIKit.tutorial rename to Sources/NetworkReachability/NetworkReachability.docc/Tutorials/SampleProject-UIKit/SampleProjectSetup-UIKit.tutorial index 1eff5261..5c13807b 100644 --- a/Sources/NetworkReachability/NetworkReachability.docc/Tutorials/SampleProjectSetup-UIKit.tutorial +++ b/Sources/NetworkReachability/NetworkReachability.docc/Tutorials/SampleProject-UIKit/SampleProjectSetup-UIKit.tutorial @@ -1,6 +1,6 @@ -@Tutorial(time: 5, projectFiles: "ProjectSetup.zip") { +@Tutorial(time: 5, projectFiles: "ProjectSetup-UIKit.zip") { @XcodeRequirement(title: "Xcode 13", destination: "https://developer.apple.com/download/") - @Intro(title: "Project Setup") { + @Intro(title: "UIKit Project Setup") { This tutorial guides you through the process of creating a new UIKit application and adding NetworkReachability as a dependency using the Swift Package Manager within Xcode. } @Section(title: "Create a New Project") { @@ -19,7 +19,7 @@ } @Step { Enter “Reachability” as the product name, select “Storyboard” for the interface and “Swift” for the language, and click Next. Choose a location to save the Reachability project on your Mac. - @Image(source: "XcodeTemplateOptions.png", alt: "Xcode Template Options") + @Image(source: "XcodeTemplateOptionsStoryboard.png", alt: "Xcode Template Options") } } } @@ -31,7 +31,7 @@ @Steps { @Step { Select your `.xcodeproj` file in the Xcode Sidebar, and select your app's target. - @Image(source: "XcodeSidebar.png", alt: "The Xcode Sidebar") + @Image(source: "XcodeSidebarStoryboard.png", alt: "The Xcode Sidebar") } @Step { Scroll to the "Frameworks, Libraries, and Embedded Content" section and choose the "+" button. diff --git a/Sources/NetworkReachability/NetworkReachability.docc/Tutorials/SampleProjectUI-UIKit.tutorial b/Sources/NetworkReachability/NetworkReachability.docc/Tutorials/SampleProject-UIKit/SampleProjectUI-UIKit.tutorial similarity index 94% rename from Sources/NetworkReachability/NetworkReachability.docc/Tutorials/SampleProjectUI-UIKit.tutorial rename to Sources/NetworkReachability/NetworkReachability.docc/Tutorials/SampleProject-UIKit/SampleProjectUI-UIKit.tutorial index f49f85b7..015fec86 100644 --- a/Sources/NetworkReachability/NetworkReachability.docc/Tutorials/SampleProjectUI-UIKit.tutorial +++ b/Sources/NetworkReachability/NetworkReachability.docc/Tutorials/SampleProject-UIKit/SampleProjectUI-UIKit.tutorial @@ -1,7 +1,7 @@ -@Tutorial(time: 15, projectFiles: "ProjectUI.zip") { +@Tutorial(time: 15, projectFiles: "ProjectUI-UIKit.zip") { @XcodeRequirement(title: "Xcode 13", destination: "https://developer.apple.com/download/") @Intro(title: "Storyboard Setup") { - This tutorial guides you through the process of creating your app's user interface using Storyboards, Interface Builder, UIKit, and SFSymbols. + This tutorial guides you through the process of creating your app's user interface using Storyboards, Interface Builder, UIKit, and SF Symbols. } @Section(title: "Create the storyboard") { @ContentAndMedia { @@ -31,6 +31,7 @@ @Section(title: "Add Iconography from SF Symbols") { @ContentAndMedia { Add iconography to your sample reachability application from SF Symbols to communicate different network connectivity information to users. + @Image(source: "SFSymbolsIcon", alt: "SF Symbols Icon") } @Steps { @Step {