Skip to content

Commit e3ecbaf

Browse files
ShelinHimeShelinHime
authored andcommitted
Step 3 - Install Ably
1 parent ed24f3e commit e3ecbaf

File tree

4 files changed

+131
-2
lines changed

4 files changed

+131
-2
lines changed

Example/Example.xcodeproj/project.pbxproj

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,28 @@
1212
3430CB721D93D951001AB9C9 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3430CB711D93D951001AB9C9 /* Assets.xcassets */; };
1313
3430CB751D93D951001AB9C9 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3430CB731D93D951001AB9C9 /* LaunchScreen.storyboard */; };
1414
3430CB7D1D93DC96001AB9C9 /* ExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3430CB7C1D93DC96001AB9C9 /* ExampleViewController.swift */; };
15+
37ADD6F991EDB11454DA382E /* Pods_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C458CEB05FC81848170A1B2 /* Pods_Example.framework */; };
1516
/* End PBXBuildFile section */
1617

1718
/* Begin PBXFileReference section */
19+
2F341EBAB2813C29B1B3D9F7 /* Pods-Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Example/Pods-Example.debug.xcconfig"; sourceTree = "<group>"; };
1820
3430CB671D93D951001AB9C9 /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
1921
3430CB6A1D93D951001AB9C9 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
2022
3430CB6F1D93D951001AB9C9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
2123
3430CB711D93D951001AB9C9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
2224
3430CB741D93D951001AB9C9 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
2325
3430CB761D93D951001AB9C9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
2426
3430CB7C1D93DC96001AB9C9 /* ExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExampleViewController.swift; sourceTree = "<group>"; };
27+
4C458CEB05FC81848170A1B2 /* Pods_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
28+
C4526166C65E31647E75A1F9 /* Pods-Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-Example/Pods-Example.release.xcconfig"; sourceTree = "<group>"; };
2529
/* End PBXFileReference section */
2630

2731
/* Begin PBXFrameworksBuildPhase section */
2832
3430CB641D93D951001AB9C9 /* Frameworks */ = {
2933
isa = PBXFrameworksBuildPhase;
3034
buildActionMask = 2147483647;
3135
files = (
36+
37ADD6F991EDB11454DA382E /* Pods_Example.framework in Frameworks */,
3237
);
3338
runOnlyForDeploymentPostprocessing = 0;
3439
};
@@ -40,6 +45,8 @@
4045
children = (
4146
3430CB691D93D951001AB9C9 /* Example */,
4247
3430CB681D93D951001AB9C9 /* Products */,
48+
5BED26FFD91B066AE0730FDA /* Pods */,
49+
94E596D5F904B4C428521F10 /* Frameworks */,
4350
);
4451
sourceTree = "<group>";
4552
};
@@ -64,16 +71,36 @@
6471
path = Example;
6572
sourceTree = "<group>";
6673
};
74+
5BED26FFD91B066AE0730FDA /* Pods */ = {
75+
isa = PBXGroup;
76+
children = (
77+
2F341EBAB2813C29B1B3D9F7 /* Pods-Example.debug.xcconfig */,
78+
C4526166C65E31647E75A1F9 /* Pods-Example.release.xcconfig */,
79+
);
80+
name = Pods;
81+
sourceTree = "<group>";
82+
};
83+
94E596D5F904B4C428521F10 /* Frameworks */ = {
84+
isa = PBXGroup;
85+
children = (
86+
4C458CEB05FC81848170A1B2 /* Pods_Example.framework */,
87+
);
88+
name = Frameworks;
89+
sourceTree = "<group>";
90+
};
6791
/* End PBXGroup section */
6892

6993
/* Begin PBXNativeTarget section */
7094
3430CB661D93D951001AB9C9 /* Example */ = {
7195
isa = PBXNativeTarget;
7296
buildConfigurationList = 3430CB791D93D951001AB9C9 /* Build configuration list for PBXNativeTarget "Example" */;
7397
buildPhases = (
98+
33DFD21BCDF935BE1AE7A39B /* [CP] Check Pods Manifest.lock */,
7499
3430CB631D93D951001AB9C9 /* Sources */,
75100
3430CB641D93D951001AB9C9 /* Frameworks */,
76101
3430CB651D93D951001AB9C9 /* Resources */,
102+
88731D81C736F2EF9CB4197E /* [CP] Embed Pods Frameworks */,
103+
FBB6B77C0F9CEABC972B6D9B /* [CP] Copy Pods Resources */,
77104
);
78105
buildRules = (
79106
);
@@ -130,6 +157,54 @@
130157
};
131158
/* End PBXResourcesBuildPhase section */
132159

160+
/* Begin PBXShellScriptBuildPhase section */
161+
33DFD21BCDF935BE1AE7A39B /* [CP] Check Pods Manifest.lock */ = {
162+
isa = PBXShellScriptBuildPhase;
163+
buildActionMask = 2147483647;
164+
files = (
165+
);
166+
inputPaths = (
167+
);
168+
name = "[CP] Check Pods Manifest.lock";
169+
outputPaths = (
170+
);
171+
runOnlyForDeploymentPostprocessing = 0;
172+
shellPath = /bin/sh;
173+
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
174+
showEnvVarsInLog = 0;
175+
};
176+
88731D81C736F2EF9CB4197E /* [CP] Embed Pods Frameworks */ = {
177+
isa = PBXShellScriptBuildPhase;
178+
buildActionMask = 2147483647;
179+
files = (
180+
);
181+
inputPaths = (
182+
);
183+
name = "[CP] Embed Pods Frameworks";
184+
outputPaths = (
185+
);
186+
runOnlyForDeploymentPostprocessing = 0;
187+
shellPath = /bin/sh;
188+
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Example/Pods-Example-frameworks.sh\"\n";
189+
showEnvVarsInLog = 0;
190+
};
191+
FBB6B77C0F9CEABC972B6D9B /* [CP] Copy Pods Resources */ = {
192+
isa = PBXShellScriptBuildPhase;
193+
buildActionMask = 2147483647;
194+
files = (
195+
);
196+
inputPaths = (
197+
);
198+
name = "[CP] Copy Pods Resources";
199+
outputPaths = (
200+
);
201+
runOnlyForDeploymentPostprocessing = 0;
202+
shellPath = /bin/sh;
203+
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Example/Pods-Example-resources.sh\"\n";
204+
showEnvVarsInLog = 0;
205+
};
206+
/* End PBXShellScriptBuildPhase section */
207+
133208
/* Begin PBXSourcesBuildPhase section */
134209
3430CB631D93D951001AB9C9 /* Sources */ = {
135210
isa = PBXSourcesBuildPhase;
@@ -247,6 +322,7 @@
247322
};
248323
3430CB7A1D93D951001AB9C9 /* Debug */ = {
249324
isa = XCBuildConfiguration;
325+
baseConfigurationReference = 2F341EBAB2813C29B1B3D9F7 /* Pods-Example.debug.xcconfig */;
250326
buildSettings = {
251327
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
252328
INFOPLIST_FILE = Example/Info.plist;
@@ -258,6 +334,7 @@
258334
};
259335
3430CB7B1D93D951001AB9C9 /* Release */ = {
260336
isa = XCBuildConfiguration;
337+
baseConfigurationReference = C4526166C65E31647E75A1F9 /* Pods-Example.release.xcconfig */;
261338
buildSettings = {
262339
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
263340
INFOPLIST_FILE = Example/Info.plist;

Example/Example.xcworkspace/contents.xcworkspacedata

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

Example/Example/ExampleViewController.swift

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,43 @@
77
//
88

99
import UIKit
10+
import AblyRealtime
1011

1112
class ExampleViewController: UIViewController {
1213

13-
override func viewDidLoad() {
14-
super.viewDidLoad()
14+
private let API_KEY = "INSERT-YOUR-API-KEY-HERE" /* Add your API key here */
15+
16+
private var client: ARTRealtime!
17+
18+
override func viewDidAppear(animated: Bool) {
19+
super.viewDidAppear(animated)
20+
21+
/*Show alert if API_KEY is not set properly*/
22+
guard API_KEY.rangeOfString("INSERT") == nil else {
23+
return showAlert("Error", message: "You have not set the API key, please configure the API_KEY in ExampleViewController.swift to run this demo.")
24+
}
25+
26+
/* Instance the Ably library */
27+
client = ARTRealtime(key: API_KEY)
28+
client.connection.on { state in
29+
if let state = state {
30+
switch state.current {
31+
case .Connected:
32+
self.showAlert("Connected", message: "Successfully connected to API.")
33+
case .Failed:
34+
self.showAlert("Failed", message: "There was a problem connecting to API")
35+
default:
36+
break
37+
}
38+
}
39+
}
40+
}
41+
42+
private func showAlert(title: String, message: String) {
43+
let alertController = UIAlertController(title: title, message: message, preferredStyle: .Alert)
44+
alertController.addAction(UIAlertAction(title: "OK", style: .Default, handler: nil))
45+
46+
self.presentViewController(alertController, animated: true, completion: nil)
1547
}
1648

1749
}

Example/Podfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Uncomment this line to define a global platform for your project
2+
# platform :ios, '6.0'
3+
4+
use_frameworks!
5+
6+
# Include the latest Ably Library
7+
# Change 'Example' to fit your target name
8+
target 'Example' do
9+
pod 'AblyRealtime'
10+
end

0 commit comments

Comments
 (0)