Skip to content

Commit

Permalink
Code cleanup, tweaked build settings, no longer stripping binary and …
Browse files Browse the repository at this point in the history
…invalidating code signature
  • Loading branch information
sveinbjornt committed Apr 22, 2023
1 parent 5e32f35 commit e324756
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
10 changes: 7 additions & 3 deletions hear.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nstrip -Tx \"$SRCROOT/products/hear\"\n";
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\n# strip -Tx \"$SRCROOT/products/hear\"\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down Expand Up @@ -242,8 +242,9 @@
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
DEPLOYMENT_POSTPROCESSING = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_TESTABILITY = NO;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down Expand Up @@ -302,6 +303,7 @@
COPY_PHASE_STRIP = YES;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEPLOYMENT_POSTPROCESSING = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
Expand All @@ -324,6 +326,7 @@
buildSettings = {
CODE_SIGN_ENTITLEMENTS = hear.entitlements;
CODE_SIGN_IDENTITY = "-";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CREATE_INFOPLIST_SECTION_IN_BINARY = YES;
DEAD_CODE_STRIPPING = YES;
Expand All @@ -344,6 +347,7 @@
buildSettings = {
CODE_SIGN_ENTITLEMENTS = hear.entitlements;
CODE_SIGN_IDENTITY = "-";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CREATE_INFOPLIST_SECTION_IN_BINARY = YES;
DEAD_CODE_STRIPPING = YES;
Expand All @@ -356,7 +360,7 @@
PRODUCT_BUNDLE_IDENTIFIER = org.sveinbjorn.hear;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
STRIPFLAGS = "-x";
STRIPFLAGS = "-Tx";
};
name = Release;
};
Expand Down
24 changes: 13 additions & 11 deletions src/Hear.m
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ - (void)processFile {

NSString *filePath = self.inputFile;
if ([[NSFileManager defaultManager] fileExistsAtPath:filePath] == NO) {
[self die:[NSString stringWithFormat:@"No file at path %@", filePath]];
[self die:[NSString stringWithFormat:@"No file at path '%@'", filePath]];
}

// OK, the file exists, let's try to run speech recognition on it
Expand Down Expand Up @@ -187,13 +187,13 @@ - (void)processFile {
return;
}

// Make sure there's a space between the incoming resulting strings
// Make sure there's a space between the incoming result strings
NSString *s = result.bestTranscription.formattedString;
if ([s hasSuffix:@" "] == FALSE && !result.isFinal) {
s = [NSString stringWithFormat:@"%@ ", s];
}

// Print w/o newline to stdout and flush
// Print to stdout without newline and flush
NSDump(s);

// Close with a newline once we're done
Expand Down Expand Up @@ -246,12 +246,15 @@ - (void)startListening {
NSPrint(transcript);
}

NSString *exitWord = [self.exitWord lowercaseString];
NSString *exitSuffix = [[NSString stringWithFormat:@" %@", exitWord] lowercaseString];
NSString *tsLower = [transcript lowercaseString];
if (self.exitWord != nil && ([tsLower hasSuffix:exitSuffix] || [tsLower isEqualToString:exitWord])) {
// Exit word identified, we're done
exit(EXIT_SUCCESS);
// If an exit word has been set, check if result ends with it
if (self.exitWord != nil) {
NSString *exitWord = [self.exitWord lowercaseString];
NSString *exitSuffix = [[NSString stringWithFormat:@" %@", exitWord] lowercaseString];
NSString *tsLower = [transcript lowercaseString];
if ([tsLower hasSuffix:exitSuffix] || [tsLower isEqualToString:exitWord]) {
// Exit word identified, we're done
exit(EXIT_SUCCESS);
}
}

if (result.isFinal) {
Expand Down Expand Up @@ -297,8 +300,7 @@ - (void)startListening {
}

+ (void)printSupportedLanguages {
NSArray<NSString *> *localeIdentifiers = [Hear supportedLanguages];
NSPrint([localeIdentifiers componentsJoinedByString:@"\n"]);
NSPrint([[Hear supportedLanguages] componentsJoinedByString:@"\n"]);
}

@end

0 comments on commit e324756

Please sign in to comment.