Skip to content

Commit 5bf1dea

Browse files
New example app: Location manager (#112)
* Beginnings of a location-based example. * wip * some tests * update makefile * clean up * wip * clean up * clean up * clean up * no need for raw value * dont need raw value * make searches cancellable * Update Examples/LocationManager/LocationManager/LocationManagerClient/LocationManagerClient.swift Co-authored-by: Stephen Celis <[email protected]> * Update Examples/LocationManager/LocationManager/LocalSearchClient/LocalSearchModels.swift Co-authored-by: Stephen Celis <[email protected]> * Update Examples/LocationManager/LocationManager/LocalSearchClient/LocalSearchModels.swift Co-authored-by: Stephen Celis <[email protected]> * fixes Co-authored-by: Stephen Celis <[email protected]>
1 parent e8e272a commit 5bf1dea

File tree

20 files changed

+1912
-0
lines changed

20 files changed

+1912
-0
lines changed

ComposableArchitecture.xcworkspace/contents.xcworkspacedata

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/LocationManager/LocationManager.xcodeproj/project.pbxproj

Lines changed: 511 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1140"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "CA17CC0824720BBA00BDDF11"
18+
BuildableName = "LocationManager.app"
19+
BlueprintName = "LocationManager"
20+
ReferencedContainer = "container:LocationManager.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
<TestableReference
32+
skipped = "NO">
33+
<BuildableReference
34+
BuildableIdentifier = "primary"
35+
BlueprintIdentifier = "CA17CC1E24720BBB00BDDF11"
36+
BuildableName = "LocationManagerTests.xctest"
37+
BlueprintName = "LocationManagerTests"
38+
ReferencedContainer = "container:LocationManager.xcodeproj">
39+
</BuildableReference>
40+
</TestableReference>
41+
</Testables>
42+
</TestAction>
43+
<LaunchAction
44+
buildConfiguration = "Debug"
45+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
46+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
47+
launchStyle = "0"
48+
useCustomWorkingDirectory = "NO"
49+
ignoresPersistentStateOnLaunch = "NO"
50+
debugDocumentVersioning = "YES"
51+
debugServiceExtension = "internal"
52+
allowLocationSimulation = "YES">
53+
<BuildableProductRunnable
54+
runnableDebuggingMode = "0">
55+
<BuildableReference
56+
BuildableIdentifier = "primary"
57+
BlueprintIdentifier = "CA17CC0824720BBA00BDDF11"
58+
BuildableName = "LocationManager.app"
59+
BlueprintName = "LocationManager"
60+
ReferencedContainer = "container:LocationManager.xcodeproj">
61+
</BuildableReference>
62+
</BuildableProductRunnable>
63+
</LaunchAction>
64+
<ProfileAction
65+
buildConfiguration = "Release"
66+
shouldUseLaunchSchemeArgsEnv = "YES"
67+
savedToolIdentifier = ""
68+
useCustomWorkingDirectory = "NO"
69+
debugDocumentVersioning = "YES">
70+
<BuildableProductRunnable
71+
runnableDebuggingMode = "0">
72+
<BuildableReference
73+
BuildableIdentifier = "primary"
74+
BlueprintIdentifier = "CA17CC0824720BBA00BDDF11"
75+
BuildableName = "LocationManager.app"
76+
BlueprintName = "LocationManager"
77+
ReferencedContainer = "container:LocationManager.xcodeproj">
78+
</BuildableReference>
79+
</BuildableProductRunnable>
80+
</ProfileAction>
81+
<AnalyzeAction
82+
buildConfiguration = "Debug">
83+
</AnalyzeAction>
84+
<ArchiveAction
85+
buildConfiguration = "Release"
86+
revealArchiveInOrganizer = "YES">
87+
</ArchiveAction>
88+
</Scheme>
7.96 KB
Loading
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"scale" : "2x",
6+
"size" : "20x20"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"scale" : "3x",
11+
"size" : "20x20"
12+
},
13+
{
14+
"idiom" : "iphone",
15+
"scale" : "2x",
16+
"size" : "29x29"
17+
},
18+
{
19+
"idiom" : "iphone",
20+
"scale" : "3x",
21+
"size" : "29x29"
22+
},
23+
{
24+
"idiom" : "iphone",
25+
"scale" : "2x",
26+
"size" : "40x40"
27+
},
28+
{
29+
"idiom" : "iphone",
30+
"scale" : "3x",
31+
"size" : "40x40"
32+
},
33+
{
34+
"idiom" : "iphone",
35+
"scale" : "2x",
36+
"size" : "60x60"
37+
},
38+
{
39+
"filename" : "AppIcon.png",
40+
"idiom" : "iphone",
41+
"scale" : "3x",
42+
"size" : "60x60"
43+
},
44+
{
45+
"idiom" : "ipad",
46+
"scale" : "1x",
47+
"size" : "20x20"
48+
},
49+
{
50+
"idiom" : "ipad",
51+
"scale" : "2x",
52+
"size" : "20x20"
53+
},
54+
{
55+
"idiom" : "ipad",
56+
"scale" : "1x",
57+
"size" : "29x29"
58+
},
59+
{
60+
"idiom" : "ipad",
61+
"scale" : "2x",
62+
"size" : "29x29"
63+
},
64+
{
65+
"idiom" : "ipad",
66+
"scale" : "1x",
67+
"size" : "40x40"
68+
},
69+
{
70+
"idiom" : "ipad",
71+
"scale" : "2x",
72+
"size" : "40x40"
73+
},
74+
{
75+
"idiom" : "ipad",
76+
"scale" : "1x",
77+
"size" : "76x76"
78+
},
79+
{
80+
"idiom" : "ipad",
81+
"scale" : "2x",
82+
"size" : "76x76"
83+
},
84+
{
85+
"idiom" : "ipad",
86+
"scale" : "2x",
87+
"size" : "83.5x83.5"
88+
},
89+
{
90+
"idiom" : "ios-marketing",
91+
"scale" : "1x",
92+
"size" : "1024x1024"
93+
}
94+
],
95+
"info" : {
96+
"author" : "xcode",
97+
"version" : 1
98+
}
99+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>$(DEVELOPMENT_LANGUAGE)</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>$(PRODUCT_NAME)</string>
15+
<key>CFBundlePackageType</key>
16+
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>1.0</string>
19+
<key>CFBundleVersion</key>
20+
<string>1</string>
21+
<key>LSRequiresIPhoneOS</key>
22+
<true/>
23+
<key>UIApplicationSceneManifest</key>
24+
<dict>
25+
<key>UIApplicationSupportsMultipleScenes</key>
26+
<false/>
27+
<key>UISceneConfigurations</key>
28+
<dict>
29+
<key>UIWindowSceneSessionRoleApplication</key>
30+
<array>
31+
<dict>
32+
<key>UISceneConfigurationName</key>
33+
<string>Default Configuration</string>
34+
<key>UISceneDelegateClassName</key>
35+
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
36+
</dict>
37+
</array>
38+
</dict>
39+
</dict>
40+
<key>UILaunchStoryboardName</key>
41+
<string>LaunchScreen</string>
42+
<key>NSLocationWhenInUseUsageDescription</key>
43+
<string>To show points of interests near you.</string>
44+
<key>UIRequiredDeviceCapabilities</key>
45+
<array>
46+
<string>armv7</string>
47+
</array>
48+
<key>UISupportedInterfaceOrientations</key>
49+
<array>
50+
<string>UIInterfaceOrientationPortrait</string>
51+
<string>UIInterfaceOrientationLandscapeLeft</string>
52+
<string>UIInterfaceOrientationLandscapeRight</string>
53+
</array>
54+
<key>UISupportedInterfaceOrientations~ipad</key>
55+
<array>
56+
<string>UIInterfaceOrientationPortrait</string>
57+
<string>UIInterfaceOrientationPortraitUpsideDown</string>
58+
<string>UIInterfaceOrientationLandscapeLeft</string>
59+
<string>UIInterfaceOrientationLandscapeRight</string>
60+
</array>
61+
</dict>
62+
</plist>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import Combine
2+
import ComposableArchitecture
3+
import MapKit
4+
5+
extension LocalSearchClient {
6+
static let live = LocalSearchClient(
7+
search: { request in
8+
Effect.future { callback in
9+
MKLocalSearch(request: request).start { response, error in
10+
switch (response, error) {
11+
case let (.some(response), _):
12+
callback(.success(LocalSearchResponse(response: response)))
13+
14+
case (_, .some):
15+
callback(.failure(LocalSearchClient.Error()))
16+
17+
case (.none, .none):
18+
fatalError("It should not be possible that response and error are both nil.")
19+
}
20+
}
21+
}
22+
})
23+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import ComposableArchitecture
2+
import MapKit
3+
4+
struct LocalSearchClient {
5+
var search: (MKLocalSearch.Request) -> Effect<LocalSearchResponse, Error>
6+
7+
struct Error: Swift.Error, Equatable {
8+
init() {}
9+
}
10+
}

0 commit comments

Comments
 (0)