Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/added port of mac os xfor swift #23

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ script:
#xcodebuild -workspace ApiAIDemoWatchOS/ApiAIDemoWatchOS.xcworkspace clean build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
- pod install --project-directory=./ApiAIMacOSDemo
- xcodebuild -workspace ApiAIMacOSDemo/ApiAIMacOSDemo.xcworkspace -scheme ApiAIMacOSDemo -sdk macosx build
- pod install --project-directory=./ApiAIMacOSDemo
- xcodebuild -workspace ApiAIMacOSDemo/ApiAIMacOSDemo.xcworkspace -scheme ApiAIMacOSDemo -sdk macosx build
- pod install --project-directory=./ApiAIMacOSDemoSwift
- xcodebuild -workspace ApiAIMacOSDemoSwift/APIAiMacOSSwiftDemo.xcworkspace -scheme APIAiMacOSSwiftDemo -sdk macosx build

notifications:
email:
recipients:
Expand Down
29 changes: 26 additions & 3 deletions ApiAI.podspec.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ApiAI",
"version": "0.5.5",
"version": "0.6.2",
"license": "Apache 2.0",
"summary": "The API.AI iOS SDK makes it easy to integrate speech recognition with API.AI natural language processing API on iOS devices.",
"homepage": "http://api.ai/",
Expand All @@ -10,7 +10,7 @@

"source": {
"git": "https://github.com/api-ai/api-ai-ios-sdk.git",
"tag": "v0.5.5"
"tag": "v0.6.2"
},

"requires_arc": true,
Expand Down Expand Up @@ -220,9 +220,32 @@

"requires_arc": true,

"dependencies": {
"ApiAI/Core": []
}
},
{
"name": "Events",

"source_files": [
"ApiAI/EventRequest/**/*.{h,m,c}"
],

"resources": [],

"public_header_files": [
"ApiAI/EventRequest/**/*.{h}"
],

"ios": {
"frameworks": ["Foundation"]
},

"requires_arc": true,

"dependencies": {
"ApiAI/Core": []
}
}
]
}
}
28 changes: 28 additions & 0 deletions ApiAI.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@
585BC6C91A15F9E800B2584A /* AIDefaultConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = 585BC6C81A15F9E800B2584A /* AIDefaultConfiguration.m */; };
5862C2D61BAEABE1007C6C4F /* AIRequestContext.m in Sources */ = {isa = PBXBuildFile; fileRef = 5862C2D51BAEABE1007C6C4F /* AIRequestContext.m */; };
5862E2FE1B6A103B00F6F712 /* AIVoiceFileRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5862E2FD1B6A103B00F6F712 /* AIVoiceFileRequest.m */; };
5865DD1C1DFA7CA50073D1A3 /* AIEventRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5865DD1B1DFA7CA50073D1A3 /* AIEventRequest.m */; };
5865DD1F1DFA7CD00073D1A3 /* AIEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = 5865DD1E1DFA7CD00073D1A3 /* AIEvent.m */; };
5865DD201DFA7E4A0073D1A3 /* AIEventRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5865DD1B1DFA7CA50073D1A3 /* AIEventRequest.m */; };
5865DD211DFA7E4A0073D1A3 /* AIEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = 5865DD1E1DFA7CD00073D1A3 /* AIEvent.m */; };
5865DD271DFA82400073D1A3 /* EventsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5865DD261DFA82400073D1A3 /* EventsTests.m */; };
5867737D1BD0F76000E1253D /* speech_d.wav in Resources */ = {isa = PBXBuildFile; fileRef = 5867737C1BD0F76000E1253D /* speech_d.wav */; };
5869BCFD1B37E56A000B99B7 /* AINullabilityDefines.h in Copy Files */ = {isa = PBXBuildFile; fileRef = 5869BCFC1B37E505000B99B7 /* AINullabilityDefines.h */; };
587074061CA184C900C4535B /* AIVoiceRequestButton.xib in Resources */ = {isa = PBXBuildFile; fileRef = 581AB39E1A245D8300E8A190 /* AIVoiceRequestButton.xib */; };
Expand Down Expand Up @@ -307,6 +312,11 @@
5862E2FB1B6A103300F6F712 /* AIVoiceFileRequest_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AIVoiceFileRequest_Private.h; sourceTree = "<group>"; };
5862E2FC1B6A103B00F6F712 /* AIVoiceFileRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AIVoiceFileRequest.h; sourceTree = "<group>"; };
5862E2FD1B6A103B00F6F712 /* AIVoiceFileRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AIVoiceFileRequest.m; sourceTree = "<group>"; };
5865DD1A1DFA7CA50073D1A3 /* AIEventRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AIEventRequest.h; sourceTree = "<group>"; };
5865DD1B1DFA7CA50073D1A3 /* AIEventRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AIEventRequest.m; sourceTree = "<group>"; };
5865DD1D1DFA7CD00073D1A3 /* AIEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AIEvent.h; sourceTree = "<group>"; };
5865DD1E1DFA7CD00073D1A3 /* AIEvent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AIEvent.m; sourceTree = "<group>"; };
5865DD261DFA82400073D1A3 /* EventsTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EventsTests.m; sourceTree = "<group>"; };
5867737C1BD0F76000E1253D /* speech_d.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = speech_d.wav; sourceTree = "<group>"; };
5869BCFC1B37E505000B99B7 /* AINullabilityDefines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AINullabilityDefines.h; sourceTree = "<group>"; };
588D23831AFB3C95008289F1 /* AIResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AIResponse.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -515,6 +525,17 @@
path = Private;
sourceTree = "<group>";
};
5865DD191DFA7C890073D1A3 /* EventRequest */ = {
isa = PBXGroup;
children = (
5865DD1A1DFA7CA50073D1A3 /* AIEventRequest.h */,
5865DD1B1DFA7CA50073D1A3 /* AIEventRequest.m */,
5865DD1D1DFA7CD00073D1A3 /* AIEvent.h */,
5865DD1E1DFA7CD00073D1A3 /* AIEvent.m */,
);
path = EventRequest;
sourceTree = "<group>";
};
588D23811AFB3C95008289F1 /* Response */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -626,6 +647,7 @@
58C2A83019BEE0E000632C2F /* ApiAI */ = {
isa = PBXGroup;
children = (
5865DD191DFA7C890073D1A3 /* EventRequest */,
58FF3A1F1C43BB210038BD9D /* UserEntities */,
58D697561B67AC3E00693710 /* VoiceFileRequest */,
58D696E01B679D0300693710 /* VoiceRequest */,
Expand Down Expand Up @@ -823,6 +845,7 @@
58F0604D1A8CB366002615DF /* ApiAITests.m */,
58AA07AD1B39494900A259D9 /* AIVADTest.m */,
581409F71C86C7E30014BBE8 /* UserEntitiesTests.m */,
5865DD261DFA82400073D1A3 /* EventsTests.m */,
58F0604B1A8CB366002615DF /* Supporting Files */,
);
path = ApiAITests;
Expand Down Expand Up @@ -1137,13 +1160,15 @@
580C6A7A1CA17F8E00C55313 /* AISessionIdentifierStorage.m in Sources */,
580C6A6F1CA17F8100C55313 /* AIRequestEntry.m in Sources */,
580C6A771CA17F8E00C55313 /* AIDataService.m in Sources */,
5865DD201DFA7E4A0073D1A3 /* AIEventRequest.m in Sources */,
580C6A6E1CA17F8100C55313 /* AIResponseConstants.m in Sources */,
580C6A781CA17F8E00C55313 /* AIStreamBuffer.m in Sources */,
580C6A731CA17F8100C55313 /* AIDefaultConfiguration.m in Sources */,
580C6A751CA17F8100C55313 /* AIRequestContext.m in Sources */,
580C6A761CA17F8100C55313 /* AIQueryRequest.m in Sources */,
580C6A721CA17F8100C55313 /* AITextRequest.m in Sources */,
580C6A741CA17F8100C55313 /* AIRequestEntity.m in Sources */,
5865DD211DFA7E4A0073D1A3 /* AIEvent.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1183,13 +1208,15 @@
58C2A85B19BEE0E000632C2F /* ApiAI.m in Sources */,
588D239E1AFB3C95008289F1 /* AIResponseParameter.m in Sources */,
581AB3AF1A245D8300E8A190 /* AIVoiceRequestButton.m in Sources */,
5865DD1C1DFA7CA50073D1A3 /* AIEventRequest.m in Sources */,
58D697041B679D0300693710 /* AIAudioUtils.c in Sources */,
58D697071B679D0300693710 /* AISoundRecorderConstants.m in Sources */,
581AB3B01A245D8300E8A190 /* AIEllipseView.m in Sources */,
5801F1271B0F33790016DE2A /* AIRequestEntity.m in Sources */,
58D6975E1B67ACD300693710 /* AIQueryRequest+Private.m in Sources */,
588D23AE1AFB3E26008289F1 /* AIRequest+AIMappedResponse.m in Sources */,
58C2A85D19BEE0E000632C2F /* AITextRequest.m in Sources */,
5865DD1F1DFA7CD00073D1A3 /* AIEvent.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -1200,6 +1227,7 @@
588D23AF1AFB3F24008289F1 /* AIRequest+AIMappedResponse.m in Sources */,
581409F81C86C7E30014BBE8 /* UserEntitiesTests.m in Sources */,
588D23A91AFB3CAB008289F1 /* AIDatePeriodFormatter.m in Sources */,
5865DD271DFA82400073D1A3 /* EventsTests.m in Sources */,
588D23A41AFB3CA1008289F1 /* AIResponseFulfillment.m in Sources */,
588D23A81AFB3CA1008289F1 /* AIResponseStatus.m in Sources */,
588D23A61AFB3CA1008289F1 /* AIResponseParameter.m in Sources */,
Expand Down
3 changes: 3 additions & 0 deletions ApiAI.xcodeproj/xcshareddata/xcschemes/ApiAITests.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
<Test
Identifier = "ApiAITests">
</Test>
<Test
Identifier = "UserEntitiesTests">
</Test>
</SkippedTests>
</TestableReference>
</Testables>
Expand Down
2 changes: 2 additions & 0 deletions ApiAI/Classes/AINullabilityDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,7 @@

#endif

#define AI_DEPRECATED_ATTRIBUTE __attribute__((deprecated))
#define AI_DEPRECATED_MSG_ATTRIBUTE(msg) __attribute((deprecated((msg))))

#endif
38 changes: 32 additions & 6 deletions ApiAI/Classes/ApiAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
#import "AIUserEntitiesRequest.h"
#endif

#if __has_include("AIEventRequest.h")
#import "AIEventRequest.h"
#endif

/*!

@enum AIRequestType enum
Expand All @@ -66,7 +70,7 @@ typedef NS_ENUM(NSUInteger, AIRequestType) {
/*! Simple text request type */
AIRequestTypeText,
/*! Voice request type with VAD(Voice activity detection) for detect end of phrase. */
AIRequestTypeVoice = 1
AIRequestTypeVoice DEPRECATED_MSG_ATTRIBUTE("Use :voiceRequest or :textRequest methods") = 1
};

/*!
Expand Down Expand Up @@ -138,7 +142,16 @@ typedef NS_ENUM(NSUInteger, AIRequestType) {
- (AIRequest *)requestWithType:(AIRequestType)requestType DEPRECATED_MSG_ATTRIBUTE("Use :voiceRequest or :textRequest methods");

#if AI_SUPPORT_VOICE_REQUEST
- (AIVoiceRequest *)voiceRequest;
/*!
API.AI speech recognition is going to be deprecated soon.
Use Google Cloud Speech API or other solutions.

This is request type available only for old paid plans.
It doesn't working for new users.

Will be removed on 1 Feb 2016.
*/
- (AIVoiceRequest *)voiceRequest AI_DEPRECATED_MSG_ATTRIBUTE("Will be removed on 1 Feb 2016.");
#endif

#if __has_include("AITextRequest.h")
Expand All @@ -151,9 +164,22 @@ typedef NS_ENUM(NSUInteger, AIRequestType) {


#if __has_include("AIVoiceFileRequest.h")
- (AIVoiceFileRequest *)voiceFileRequestWithFileURL:(NSURL *)fileURL;
- (AIVoiceFileRequest *)voiceFileRequestWithStream:(NSInputStream *)inputStream;
- (AIVoiceFileRequest *)voiceFileRequestWithData:(NSData *)fileData;
/*!
API.AI speech recognition is going to be deprecated soon.
Use Google Cloud Speech API or other solutions.

This is request type available only for old paid plans.
It doesn't working for new users.

Will be removed on 1 Feb 2016.
*/
- (AIVoiceFileRequest *)voiceFileRequestWithFileURL:(NSURL *)fileURL AI_DEPRECATED_MSG_ATTRIBUTE("Will be removed on 1 Feb 2016.");
- (AIVoiceFileRequest *)voiceFileRequestWithStream:(NSInputStream *)inputStream AI_DEPRECATED_MSG_ATTRIBUTE("Will be removed on 1 Feb 2016.");
- (AIVoiceFileRequest *)voiceFileRequestWithData:(NSData *)fileData AI_DEPRECATED_MSG_ATTRIBUTE("Will be removed on 1 Feb 2016.");
#endif

#if __has_include("AIEventRequest.h")
- (AIEventRequest *)eventRequest;
#endif

/*!
Expand All @@ -175,4 +201,4 @@ typedef NS_ENUM(NSUInteger, AIRequestType) {

- (void)cancellAllRequests;

@end
@end
12 changes: 12 additions & 0 deletions ApiAI/Classes/ApiAI.m
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@ - (AIVoiceFileRequest *)voiceFileRequestWithData:(NSData *)fileData

#endif

#if __has_include("AIEventRequest.h")
- (AIEventRequest *)eventRequest
{
AIEventRequest *request = [[AIEventRequest alloc] initWithDataService:_dataService];

[request setVersion:self.version];
[request setLang:self.lang];

return request;
}
#endif

- (void)setConfiguration:(id<AIConfiguration>)configuration
{
_configuration = configuration;
Expand Down
19 changes: 19 additions & 0 deletions ApiAI/EventRequest/AIEvent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// AIEvent.h
// ApiAI
//
// Created by Kuragin Dmitriy on 09/12/2016.
// Copyright © 2016 Kuragin Dmitriy. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface AIEvent : NSObject

@property(nonatomic, copy) NSString *name;
@property(nonatomic, copy) NSDictionary *data;

- (instancetype)initWithName:(NSString *)name andData:(NSDictionary *)data;
- (instancetype)initWithName:(NSString *)name;

@end
32 changes: 32 additions & 0 deletions ApiAI/EventRequest/AIEvent.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// AIEvent.m
// ApiAI
//
// Created by Kuragin Dmitriy on 09/12/2016.
// Copyright © 2016 Kuragin Dmitriy. All rights reserved.
//

#import "AIEvent.h"

@implementation AIEvent

- (instancetype)initWithName:(NSString *)name andData:(NSDictionary *)data {
self = [super init];
if (self) {
self.name = name;
self.data = data;
}

return self;
}

- (instancetype)initWithName:(NSString *)name {
self = [super init];
if (self) {
self.name = name;
self.data = nil;
}
return self;
}

@end
16 changes: 16 additions & 0 deletions ApiAI/EventRequest/AIEventRequest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// AIEventRequest.h
// ApiAI
//
// Created by Kuragin Dmitriy on 09/12/2016.
// Copyright © 2016 Kuragin Dmitriy. All rights reserved.
//

#import "AIQueryRequest.h"
#import "AIEvent.h"

@interface AIEventRequest : AIQueryRequest

@property(nonatomic, strong) AIEvent *event;

@end
Loading