Skip to content

Commit 399e864

Browse files
Updated advance iOS app navigation between packages
1 parent 98e3b53 commit 399e864

12 files changed

Lines changed: 40 additions & 53 deletions

File tree

0 Bytes
Binary file not shown.
File renamed without changes.

ScalablePackageNavigation/Router/Package.swift renamed to ScalablePackageNavigation/AppRouter/Package.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
import PackageDescription
55

66
let package = Package(
7-
name: "Router",
7+
name: "AppRouter",
88
products: [
99
// Products define the executables and libraries a package produces, making them visible to other packages.
1010
.library(
11-
name: "Router",
12-
targets: ["Router"]
11+
name: "AppRouter",
12+
targets: ["AppRouter"]
1313
),
1414
],
1515
targets: [
1616
// Targets are the basic building blocks of a package, defining a module or a test suite.
1717
// Targets can depend on other targets in this package and products from dependencies.
1818
.target(
19-
name: "Router"
19+
name: "AppRouter"
2020
),
2121

2222
]

ScalablePackageNavigation/Router/Sources/Router/Router.swift renamed to ScalablePackageNavigation/AppRouter/Sources/AppRouter/AppRouter.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// The Swift Programming Language
22
// https://docs.swift.org/swift-book
33
import SwiftUI
4-
//import CartPackage
5-
//import OrderSummaryPackage
64
import Combine
75

86
public enum Route {
@@ -15,4 +13,5 @@ public enum Route {
1513
public class AppRouter: ObservableObject {
1614
@Published public var path: [Route] = []
1715
@Published public var cartItems: [String] = []
16+
public init() {} // Add public initializer
1817
}

ScalablePackageNavigation/CartPackage/Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ let package = Package(
1313
),
1414
],
1515
dependencies: [
16-
.package(name: "Router", path: "../Router") // Local path
16+
.package(name: "AppRouter", path: "../AppRouter") // Local path
1717
],
1818
targets: [
1919
// Targets are the basic building blocks of a package, defining a module or a test suite.
2020
// Targets can depend on other targets in this package and products from dependencies.
2121
.target(
2222
name: "CartPackage",
23-
dependencies: ["Router"] // Explicit dependency
23+
dependencies: ["AppRouter"] // Explicit dependency
2424
),
2525

2626
]

ScalablePackageNavigation/CartPackage/Sources/CartPackage/CartView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import SwiftUI
2-
import Router
2+
import Combine
3+
import AppRouter
34

45
@available(iOS 13.0, *)
56
public struct CartView: View {

ScalablePackageNavigation/CustomFoundation/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Lines changed: 0 additions & 22 deletions
This file was deleted.

ScalablePackageNavigation/OrderSummaryPackage/Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ let package = Package(
1313
),
1414
],
1515
dependencies: [
16-
.package(name: "Router", path: "../Router") // Local path
16+
.package(name: "AppRouter", path: "../AppRouter") // Local path
1717
],
1818
targets: [
1919
// Targets are the basic building blocks of a package, defining a module or a test suite.
2020
// Targets can depend on other targets in this package and products from dependencies.
2121
.target(
2222
name: "OrderSummaryPackage",
23-
dependencies: ["Router"]
23+
dependencies: ["AppRouter"]
2424
),
2525

2626
]

ScalablePackageNavigation/OrderSummaryPackage/Sources/OrderSummaryPackage/OrderSummaryView.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import SwiftUI
2-
import Router
2+
import Combine
3+
import AppRouter
34

45
@available(iOS 13.0, *)
56
public struct OrderSummaryView: View {
@@ -16,7 +17,9 @@ public struct OrderSummaryView: View {
1617
}
1718
Button("Go to Home") {
1819
router.path = []
20+
router.cartItems.removeAll()
1921
}
22+
.navigationBarBackButtonHidden()
2023
}
2124
}
2225
}

ScalablePackageNavigation/ScalablePackageNavigation.xcodeproj/project.pbxproj

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
4F381BEB2E4648FF006B6CDA /* AppRouter in Frameworks */ = {isa = PBXBuildFile; productRef = 4F381BEA2E4648FF006B6CDA /* AppRouter */; };
1011
4FC6A5072E463C0E0034244F /* OrderSummaryPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 4FC6A5062E463C0E0034244F /* OrderSummaryPackage */; };
1112
4FC6A50A2E463C140034244F /* CartPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 4FC6A5092E463C140034244F /* CartPackage */; };
12-
4FF513612E463E1B0074C3AC /* Router in Frameworks */ = {isa = PBXBuildFile; productRef = 4FF513602E463E1B0074C3AC /* Router */; };
1313
/* End PBXBuildFile section */
1414

1515
/* Begin PBXFileReference section */
@@ -29,8 +29,8 @@
2929
isa = PBXFrameworksBuildPhase;
3030
buildActionMask = 2147483647;
3131
files = (
32+
4F381BEB2E4648FF006B6CDA /* AppRouter in Frameworks */,
3233
4FC6A5072E463C0E0034244F /* OrderSummaryPackage in Frameworks */,
33-
4FF513612E463E1B0074C3AC /* Router in Frameworks */,
3434
4FC6A50A2E463C140034244F /* CartPackage in Frameworks */,
3535
);
3636
runOnlyForDeploymentPostprocessing = 0;
@@ -76,7 +76,7 @@
7676
packageProductDependencies = (
7777
4FC6A5062E463C0E0034244F /* OrderSummaryPackage */,
7878
4FC6A5092E463C140034244F /* CartPackage */,
79-
4FF513602E463E1B0074C3AC /* Router */,
79+
4F381BEA2E4648FF006B6CDA /* AppRouter */,
8080
);
8181
productName = ScalablePackageNavigation;
8282
productReference = 4FC6A4DC2E4628C50034244F /* ScalablePackageNavigation.app */;
@@ -110,7 +110,7 @@
110110
packageReferences = (
111111
4FC6A5052E463C0E0034244F /* XCLocalSwiftPackageReference "OrderSummaryPackage" */,
112112
4FC6A5082E463C140034244F /* XCLocalSwiftPackageReference "CartPackage" */,
113-
4FF5135F2E463E1B0074C3AC /* XCLocalSwiftPackageReference "Router" */,
113+
4F381BE92E4648FF006B6CDA /* XCLocalSwiftPackageReference "AppRouter" */,
114114
);
115115
preferredProjectObjectVersion = 77;
116116
productRefGroup = 4FC6A4DD2E4628C50034244F /* Products */;
@@ -361,6 +361,10 @@
361361
/* End XCConfigurationList section */
362362

363363
/* Begin XCLocalSwiftPackageReference section */
364+
4F381BE92E4648FF006B6CDA /* XCLocalSwiftPackageReference "AppRouter" */ = {
365+
isa = XCLocalSwiftPackageReference;
366+
relativePath = AppRouter;
367+
};
364368
4FC6A5052E463C0E0034244F /* XCLocalSwiftPackageReference "OrderSummaryPackage" */ = {
365369
isa = XCLocalSwiftPackageReference;
366370
relativePath = OrderSummaryPackage;
@@ -369,13 +373,13 @@
369373
isa = XCLocalSwiftPackageReference;
370374
relativePath = CartPackage;
371375
};
372-
4FF5135F2E463E1B0074C3AC /* XCLocalSwiftPackageReference "Router" */ = {
373-
isa = XCLocalSwiftPackageReference;
374-
relativePath = Router;
375-
};
376376
/* End XCLocalSwiftPackageReference section */
377377

378378
/* Begin XCSwiftPackageProductDependency section */
379+
4F381BEA2E4648FF006B6CDA /* AppRouter */ = {
380+
isa = XCSwiftPackageProductDependency;
381+
productName = AppRouter;
382+
};
379383
4FC6A5062E463C0E0034244F /* OrderSummaryPackage */ = {
380384
isa = XCSwiftPackageProductDependency;
381385
productName = OrderSummaryPackage;
@@ -384,10 +388,6 @@
384388
isa = XCSwiftPackageProductDependency;
385389
productName = CartPackage;
386390
};
387-
4FF513602E463E1B0074C3AC /* Router */ = {
388-
isa = XCSwiftPackageProductDependency;
389-
productName = Router;
390-
};
391391
/* End XCSwiftPackageProductDependency section */
392392
};
393393
rootObject = 4FC6A4D42E4628C50034244F /* Project object */;

0 commit comments

Comments
 (0)