Skip to content

Commit 0160c72

Browse files
author
Dmitriy Kuragin
committed
migrate exmples to latest swift version. Fix dialogflow#3
1 parent 5301162 commit 0160c72

20 files changed

+147
-697
lines changed

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ Carthage/Build
3535

3636
# Mac OS X
3737
*.DS_Store
38+
AIDemo/AIDemo.xcworkspace
39+
AIOSXDemo/AIOSXDemo.xcworkspace

Diff for: AI/src/Requests/TextQueryRequest.swift

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public class TextQueryRequest: TextQueryRequestType, PrivateRequest, QueryContai
9898
self.privateResume(completionHandler)
9999
}
100100

101+
@discardableResult
101102
public func resume(completionHandler: @escaping (RequestCompletion<ResponseType>) -> Void) -> Self {
102103
// TODO: Replace run-function with the following call.
103104
// (self as TextQueryRequest).privateResume(completionHandler)

Diff for: AI/src/Requests/UserEntitiesRequest.swift

+1
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ public class UserEntitiesRequest: Request, PrivateRequest {
133133
self.privateResume(completionHandler)
134134
}
135135

136+
@discardableResult
136137
public func resume(completionHandler: @escaping (RequestCompletion<ResponseType>) -> Void) -> Self {
137138
// TODO: Replace run-function with the following call.
138139
// (self as TextQueryRequest).privateResume(completionHandler)

Diff for: AIDemo/AIDemo.xcodeproj/project.pbxproj

+21-23
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
58D1E4BD1BFC6BB400D257AA /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 58D1E4BB1BFC6BB400D257AA /* LaunchScreen.storyboard */; };
1515
58D1E4C61BFC6D7200D257AA /* TextRequestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58D1E4C51BFC6D7200D257AA /* TextRequestViewController.swift */; };
1616
58D1E4C91BFC6E0100D257AA /* ResultViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58D1E4C81BFC6E0100D257AA /* ResultViewController.swift */; };
17-
CE5E74301C1A987A00890183 /* VoiceRequestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE5E742F1C1A987A00890183 /* VoiceRequestViewController.swift */; };
1817
EF171C8443E8B5AA44FA5594 /* Pods_AIDemo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 34D2689E82A65A36E929393F /* Pods_AIDemo.framework */; };
1918
/* End PBXBuildFile section */
2019

@@ -30,7 +29,6 @@
3029
58D1E4BE1BFC6BB400D257AA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3130
58D1E4C51BFC6D7200D257AA /* TextRequestViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextRequestViewController.swift; sourceTree = "<group>"; };
3231
58D1E4C81BFC6E0100D257AA /* ResultViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ResultViewController.swift; sourceTree = "<group>"; };
33-
CE5E742F1C1A987A00890183 /* VoiceRequestViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VoiceRequestViewController.swift; sourceTree = "<group>"; };
3432
F182421779ABBD2542C80E0C /* Pods-AIDemo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AIDemo.release.xcconfig"; path = "Pods/Target Support Files/Pods-AIDemo/Pods-AIDemo.release.xcconfig"; sourceTree = "<group>"; };
3533
/* End PBXFileReference section */
3634

@@ -70,7 +68,6 @@
7068
children = (
7169
58D1E4C41BFC6D6600D257AA /* TextRequest */,
7270
58D1E4C71BFC6DF000D257AA /* Result */,
73-
CE5E742E1C1A980D00890183 /* VoiceRequest */,
7471
58D1E4B21BFC6BB400D257AA /* AppDelegate.swift */,
7572
58D1E4B61BFC6BB400D257AA /* Main.storyboard */,
7673
58D1E4B91BFC6BB400D257AA /* Assets.xcassets */,
@@ -105,14 +102,6 @@
105102
name = Pods;
106103
sourceTree = "<group>";
107104
};
108-
CE5E742E1C1A980D00890183 /* VoiceRequest */ = {
109-
isa = PBXGroup;
110-
children = (
111-
CE5E742F1C1A987A00890183 /* VoiceRequestViewController.swift */,
112-
);
113-
path = VoiceRequest;
114-
sourceTree = "<group>";
115-
};
116105
F6538459F510446765E5D455 /* Frameworks */ = {
117106
isa = PBXGroup;
118107
children = (
@@ -129,12 +118,12 @@
129118
isa = PBXNativeTarget;
130119
buildConfigurationList = 58D1E4C11BFC6BB400D257AA /* Build configuration list for PBXNativeTarget "AIDemo" */;
131120
buildPhases = (
132-
2BEF95B8FF07C320FB0DC103 /* Check Pods Manifest.lock */,
121+
2BEF95B8FF07C320FB0DC103 /* [CP] Check Pods Manifest.lock */,
133122
58D1E4AB1BFC6BB400D257AA /* Sources */,
134123
58D1E4AC1BFC6BB400D257AA /* Frameworks */,
135124
58D1E4AD1BFC6BB400D257AA /* Resources */,
136-
A937B83877837E2C3D229AC0 /* Embed Pods Frameworks */,
137-
398F0DB78AD428D6AEA2AC37 /* Copy Pods Resources */,
125+
A937B83877837E2C3D229AC0 /* [CP] Embed Pods Frameworks */,
126+
398F0DB78AD428D6AEA2AC37 /* [CP] Copy Pods Resources */,
138127
);
139128
buildRules = (
140129
);
@@ -152,11 +141,12 @@
152141
isa = PBXProject;
153142
attributes = {
154143
LastSwiftUpdateCheck = 0710;
155-
LastUpgradeCheck = 0710;
144+
LastUpgradeCheck = 0820;
156145
ORGANIZATIONNAME = "Kuragin Dmitriy";
157146
TargetAttributes = {
158147
58D1E4AE1BFC6BB400D257AA = {
159148
CreatedOnToolsVersion = 7.1.1;
149+
LastSwiftMigration = 0820;
160150
};
161151
};
162152
};
@@ -192,44 +182,44 @@
192182
/* End PBXResourcesBuildPhase section */
193183

194184
/* Begin PBXShellScriptBuildPhase section */
195-
2BEF95B8FF07C320FB0DC103 /* Check Pods Manifest.lock */ = {
185+
2BEF95B8FF07C320FB0DC103 /* [CP] Check Pods Manifest.lock */ = {
196186
isa = PBXShellScriptBuildPhase;
197187
buildActionMask = 2147483647;
198188
files = (
199189
);
200190
inputPaths = (
201191
);
202-
name = "Check Pods Manifest.lock";
192+
name = "[CP] Check Pods Manifest.lock";
203193
outputPaths = (
204194
);
205195
runOnlyForDeploymentPostprocessing = 0;
206196
shellPath = /bin/sh;
207-
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";
197+
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
208198
showEnvVarsInLog = 0;
209199
};
210-
398F0DB78AD428D6AEA2AC37 /* Copy Pods Resources */ = {
200+
398F0DB78AD428D6AEA2AC37 /* [CP] Copy Pods Resources */ = {
211201
isa = PBXShellScriptBuildPhase;
212202
buildActionMask = 2147483647;
213203
files = (
214204
);
215205
inputPaths = (
216206
);
217-
name = "Copy Pods Resources";
207+
name = "[CP] Copy Pods Resources";
218208
outputPaths = (
219209
);
220210
runOnlyForDeploymentPostprocessing = 0;
221211
shellPath = /bin/sh;
222212
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AIDemo/Pods-AIDemo-resources.sh\"\n";
223213
showEnvVarsInLog = 0;
224214
};
225-
A937B83877837E2C3D229AC0 /* Embed Pods Frameworks */ = {
215+
A937B83877837E2C3D229AC0 /* [CP] Embed Pods Frameworks */ = {
226216
isa = PBXShellScriptBuildPhase;
227217
buildActionMask = 2147483647;
228218
files = (
229219
);
230220
inputPaths = (
231221
);
232-
name = "Embed Pods Frameworks";
222+
name = "[CP] Embed Pods Frameworks";
233223
outputPaths = (
234224
);
235225
runOnlyForDeploymentPostprocessing = 0;
@@ -245,7 +235,6 @@
245235
buildActionMask = 2147483647;
246236
files = (
247237
58D1E4C61BFC6D7200D257AA /* TextRequestViewController.swift in Sources */,
248-
CE5E74301C1A987A00890183 /* VoiceRequestViewController.swift in Sources */,
249238
58D1E4B31BFC6BB400D257AA /* AppDelegate.swift in Sources */,
250239
58D1E4C91BFC6E0100D257AA /* ResultViewController.swift in Sources */,
251240
);
@@ -286,8 +275,10 @@
286275
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
287276
CLANG_WARN_EMPTY_BODY = YES;
288277
CLANG_WARN_ENUM_CONVERSION = YES;
278+
CLANG_WARN_INFINITE_RECURSION = YES;
289279
CLANG_WARN_INT_CONVERSION = YES;
290280
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
281+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
291282
CLANG_WARN_UNREACHABLE_CODE = YES;
292283
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
293284
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -330,8 +321,10 @@
330321
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
331322
CLANG_WARN_EMPTY_BODY = YES;
332323
CLANG_WARN_ENUM_CONVERSION = YES;
324+
CLANG_WARN_INFINITE_RECURSION = YES;
333325
CLANG_WARN_INT_CONVERSION = YES;
334326
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
327+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
335328
CLANG_WARN_UNREACHABLE_CODE = YES;
336329
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
337330
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -350,6 +343,7 @@
350343
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
351344
MTL_ENABLE_DEBUG_INFO = NO;
352345
SDKROOT = iphoneos;
346+
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
353347
VALIDATE_PRODUCT = YES;
354348
};
355349
name = Release;
@@ -358,23 +352,27 @@
358352
isa = XCBuildConfiguration;
359353
baseConfigurationReference = 214B739D944FBA0038FC493D /* Pods-AIDemo.debug.xcconfig */;
360354
buildSettings = {
355+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
361356
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
362357
INFOPLIST_FILE = AIDemo/Info.plist;
363358
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
364359
PRODUCT_BUNDLE_IDENTIFIER = com.speaktoit.AIDemo;
365360
PRODUCT_NAME = "$(TARGET_NAME)";
361+
SWIFT_VERSION = 3.0;
366362
};
367363
name = Debug;
368364
};
369365
58D1E4C31BFC6BB400D257AA /* Release */ = {
370366
isa = XCBuildConfiguration;
371367
baseConfigurationReference = F182421779ABBD2542C80E0C /* Pods-AIDemo.release.xcconfig */;
372368
buildSettings = {
369+
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
373370
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
374371
INFOPLIST_FILE = AIDemo/Info.plist;
375372
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
376373
PRODUCT_BUNDLE_IDENTIFIER = com.speaktoit.AIDemo;
377374
PRODUCT_NAME = "$(TARGET_NAME)";
375+
SWIFT_VERSION = 3.0;
378376
};
379377
name = Release;
380378
};

Diff for: AIDemo/AIDemo/AppDelegate.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1616
var window: UIWindow?
1717

1818

19-
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
19+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
2020
AI.configure("YOUR_CLIENT_ACCESS_TOKEN")
2121

2222
let session = AVAudioSession.sharedInstance()
2323

2424
do {
25-
try session.setCategory(AVAudioSessionCategoryPlayAndRecord, withOptions: [.AllowBluetooth])
25+
try session.setCategory(AVAudioSessionCategoryPlayAndRecord, with: [.allowBluetooth])
2626
try session.setActive(true)
2727
} catch {
2828
// handle error
@@ -31,25 +31,25 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
3131
return true
3232
}
3333

34-
func applicationWillResignActive(application: UIApplication) {
34+
func applicationWillResignActive(_ application: UIApplication) {
3535
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
3636
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
3737
}
3838

39-
func applicationDidEnterBackground(application: UIApplication) {
39+
func applicationDidEnterBackground(_ application: UIApplication) {
4040
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
4141
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
4242
}
4343

44-
func applicationWillEnterForeground(application: UIApplication) {
44+
func applicationWillEnterForeground(_ application: UIApplication) {
4545
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
4646
}
4747

48-
func applicationDidBecomeActive(application: UIApplication) {
48+
func applicationDidBecomeActive(_ application: UIApplication) {
4949
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
5050
}
5151

52-
func applicationWillTerminate(application: UIApplication) {
52+
func applicationWillTerminate(_ application: UIApplication) {
5353
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
5454
}
5555

0 commit comments

Comments
 (0)