Skip to content

Commit 5760375

Browse files
update to swfit4
1 parent 8485541 commit 5760375

File tree

10 files changed

+57
-27
lines changed

10 files changed

+57
-27
lines changed

CodeGenerator.xcodeproj/project.pbxproj

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -419,23 +419,26 @@
419419
isa = PBXProject;
420420
attributes = {
421421
LastSwiftUpdateCheck = 0820;
422-
LastUpgradeCheck = 0820;
422+
LastUpgradeCheck = 0920;
423423
ORGANIZATIONNAME = wangjie;
424424
TargetAttributes = {
425425
A03920581E0F3A7B005A6E89 = {
426426
CreatedOnToolsVersion = 8.2;
427427
DevelopmentTeam = 5C59L2E3AR;
428+
LastSwiftMigration = 0920;
428429
ProvisioningStyle = Automatic;
429430
};
430431
A03920691E0F3A7B005A6E89 = {
431432
CreatedOnToolsVersion = 8.2;
432-
DevelopmentTeam = 6DJS27PW5B;
433+
DevelopmentTeam = 5C59L2E3AR;
434+
LastSwiftMigration = 0920;
433435
ProvisioningStyle = Automatic;
434436
TestTargetID = A03920581E0F3A7B005A6E89;
435437
};
436438
A039207C1E0F3A8B005A6E89 = {
437439
CreatedOnToolsVersion = 8.2;
438440
DevelopmentTeam = 5C59L2E3AR;
441+
LastSwiftMigration = 0920;
439442
ProvisioningStyle = Automatic;
440443
};
441444
};
@@ -620,15 +623,21 @@
620623
CLANG_CXX_LIBRARY = "libc++";
621624
CLANG_ENABLE_MODULES = YES;
622625
CLANG_ENABLE_OBJC_ARC = YES;
626+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
623627
CLANG_WARN_BOOL_CONVERSION = YES;
628+
CLANG_WARN_COMMA = YES;
624629
CLANG_WARN_CONSTANT_CONVERSION = YES;
625630
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
626631
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
627632
CLANG_WARN_EMPTY_BODY = YES;
628633
CLANG_WARN_ENUM_CONVERSION = YES;
629634
CLANG_WARN_INFINITE_RECURSION = YES;
630635
CLANG_WARN_INT_CONVERSION = YES;
636+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
637+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
631638
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
639+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
640+
CLANG_WARN_STRICT_PROTOTYPES = YES;
632641
CLANG_WARN_SUSPICIOUS_MOVE = YES;
633642
CLANG_WARN_UNREACHABLE_CODE = YES;
634643
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -669,15 +678,21 @@
669678
CLANG_CXX_LIBRARY = "libc++";
670679
CLANG_ENABLE_MODULES = YES;
671680
CLANG_ENABLE_OBJC_ARC = YES;
681+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
672682
CLANG_WARN_BOOL_CONVERSION = YES;
683+
CLANG_WARN_COMMA = YES;
673684
CLANG_WARN_CONSTANT_CONVERSION = YES;
674685
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
675686
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
676687
CLANG_WARN_EMPTY_BODY = YES;
677688
CLANG_WARN_ENUM_CONVERSION = YES;
678689
CLANG_WARN_INFINITE_RECURSION = YES;
679690
CLANG_WARN_INT_CONVERSION = YES;
691+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
692+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
680693
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
694+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
695+
CLANG_WARN_STRICT_PROTOTYPES = YES;
681696
CLANG_WARN_SUSPICIOUS_MOVE = YES;
682697
CLANG_WARN_UNREACHABLE_CODE = YES;
683698
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -706,14 +721,15 @@
706721
buildSettings = {
707722
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
708723
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
709-
CODE_SIGN_IDENTITY = "Mac Developer";
724+
CODE_SIGN_IDENTITY = "";
710725
COMBINE_HIDPI_IMAGES = YES;
711726
DEVELOPMENT_TEAM = 5C59L2E3AR;
712727
INFOPLIST_FILE = CodeGenerator/Info.plist;
713728
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
714729
PRODUCT_BUNDLE_IDENTIFIER = com.wangjie.CodeGenerator;
715730
PRODUCT_NAME = "$(TARGET_NAME)";
716-
SWIFT_VERSION = 3.0;
731+
SWIFT_SWIFT3_OBJC_INFERENCE = On;
732+
SWIFT_VERSION = 4.0;
717733
};
718734
name = Debug;
719735
};
@@ -722,14 +738,15 @@
722738
buildSettings = {
723739
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
724740
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
725-
CODE_SIGN_IDENTITY = "Mac Developer";
741+
CODE_SIGN_IDENTITY = "";
726742
COMBINE_HIDPI_IMAGES = YES;
727743
DEVELOPMENT_TEAM = 5C59L2E3AR;
728744
INFOPLIST_FILE = CodeGenerator/Info.plist;
729745
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
730746
PRODUCT_BUNDLE_IDENTIFIER = com.wangjie.CodeGenerator;
731747
PRODUCT_NAME = "$(TARGET_NAME)";
732-
SWIFT_VERSION = 3.0;
748+
SWIFT_SWIFT3_OBJC_INFERENCE = On;
749+
SWIFT_VERSION = 4.0;
733750
};
734751
name = Release;
735752
};
@@ -740,12 +757,13 @@
740757
BUNDLE_LOADER = "$(TEST_HOST)";
741758
CODE_SIGN_IDENTITY = "Mac Developer";
742759
COMBINE_HIDPI_IMAGES = YES;
743-
DEVELOPMENT_TEAM = 6DJS27PW5B;
760+
DEVELOPMENT_TEAM = 5C59L2E3AR;
744761
INFOPLIST_FILE = CodeGeneratorTests/Info.plist;
745762
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
746763
PRODUCT_BUNDLE_IDENTIFIER = com.wangjie.CodeGeneratorTests;
747764
PRODUCT_NAME = "$(TARGET_NAME)";
748-
SWIFT_VERSION = 3.0;
765+
SWIFT_SWIFT3_OBJC_INFERENCE = On;
766+
SWIFT_VERSION = 4.0;
749767
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CodeGenerator.app/Contents/MacOS/CodeGenerator";
750768
};
751769
name = Debug;
@@ -757,12 +775,13 @@
757775
BUNDLE_LOADER = "$(TEST_HOST)";
758776
CODE_SIGN_IDENTITY = "Mac Developer";
759777
COMBINE_HIDPI_IMAGES = YES;
760-
DEVELOPMENT_TEAM = 6DJS27PW5B;
778+
DEVELOPMENT_TEAM = 5C59L2E3AR;
761779
INFOPLIST_FILE = CodeGeneratorTests/Info.plist;
762780
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
763781
PRODUCT_BUNDLE_IDENTIFIER = com.wangjie.CodeGeneratorTests;
764782
PRODUCT_NAME = "$(TARGET_NAME)";
765-
SWIFT_VERSION = 3.0;
783+
SWIFT_SWIFT3_OBJC_INFERENCE = On;
784+
SWIFT_VERSION = 4.0;
766785
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/CodeGenerator.app/Contents/MacOS/CodeGenerator";
767786
};
768787
name = Release;
@@ -779,8 +798,11 @@
779798
MACOSX_DEPLOYMENT_TARGET = 10.11;
780799
PRODUCT_BUNDLE_IDENTIFIER = com.wangjie.CodeGenerator.Generate;
781800
PRODUCT_NAME = "$(TARGET_NAME)";
801+
PROVISIONING_PROFILE = "";
802+
PROVISIONING_PROFILE_SPECIFIER = "";
782803
SKIP_INSTALL = YES;
783-
SWIFT_VERSION = 3.0;
804+
SWIFT_SWIFT3_OBJC_INFERENCE = On;
805+
SWIFT_VERSION = 4.0;
784806
};
785807
name = Debug;
786808
};
@@ -796,8 +818,10 @@
796818
MACOSX_DEPLOYMENT_TARGET = 10.11;
797819
PRODUCT_BUNDLE_IDENTIFIER = com.wangjie.CodeGenerator.Generate;
798820
PRODUCT_NAME = "$(TARGET_NAME)";
821+
PROVISIONING_PROFILE_SPECIFIER = "";
799822
SKIP_INSTALL = YES;
800-
SWIFT_VERSION = 3.0;
823+
SWIFT_SWIFT3_OBJC_INFERENCE = On;
824+
SWIFT_VERSION = 4.0;
801825
};
802826
name = Release;
803827
};

CodeGenerator.xcodeproj/xcshareddata/xcschemes/CodeGenerator.xcscheme

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0820"
3+
LastUpgradeVersion = "0920"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,6 +26,7 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
language = ""
2930
shouldUseLaunchSchemeArgsEnv = "YES">
3031
<Testables>
3132
<TestableReference
@@ -55,6 +56,7 @@
5556
buildConfiguration = "Debug"
5657
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
5758
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
59+
language = ""
5860
launchStyle = "0"
5961
useCustomWorkingDirectory = "NO"
6062
ignoresPersistentStateOnLaunch = "NO"

CodeGenerator.xcodeproj/xcshareddata/xcschemes/Generate....xcscheme

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0820"
3+
LastUpgradeVersion = "0920"
44
wasCreatedForAppExtension = "YES"
55
version = "2.0">
66
<BuildAction
@@ -41,6 +41,7 @@
4141
buildConfiguration = "Debug"
4242
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4343
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
44+
language = ""
4445
shouldUseLaunchSchemeArgsEnv = "YES">
4546
<Testables>
4647
<TestableReference
@@ -70,6 +71,7 @@
7071
buildConfiguration = "Debug"
7172
selectedDebuggerIdentifier = ""
7273
selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
74+
language = ""
7375
launchStyle = "0"
7476
useCustomWorkingDirectory = "NO"
7577
ignoresPersistentStateOnLaunch = "NO"

CodeGeneratorTests/NSObject+file.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Foundation
1111
extension NSObject {
1212

1313
func string(from path: String, ofType type: String) -> String {
14-
let path = Bundle(for: type(of: self)).path(forResource: path, ofType: type)!
14+
let path = Bundle(for: Swift.type(of: self)).path(forResource: path, ofType: type)!
1515
return try! String(contentsOfFile: path)
1616
}
1717
}

Generate.../AccessLevel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ enum AccessLevel: String {
1919
let allLevels: [AccessLevel] = [.open, .public, .internal, .fileprivate, .private]
2020
for level in allLevels {
2121
if let result = " (\(level)) ".firstMatch(in: string) {
22-
self.init(rawValue: string.substring(with: result.rangeAt(1)))!
22+
self.init(rawValue: string.substring(with: result.range(at: 1)))!
2323
return
2424
}
2525
}

Generate.../ClosureType.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class ClosureType: SwiftType {
2121
override var unwrappedName: String {
2222
if isOptional {
2323
let result = "^\\((.*)\\)[?!]$".firstMatch(in: name)!
24-
return name.substring(with: result.rangeAt(1))
24+
return name.substring(with: result.range(at: 1))
2525
}
2626
return name
2727
}
@@ -43,7 +43,7 @@ class ClosureType: SwiftType {
4343
var inTypes: [SwiftType] {
4444
let rawInTypes = unwrappedName.components(separatedBy: "->")[0]
4545
guard let result = "\\((.*)\\)".firstMatch(in: rawInTypes) else { return [] }
46-
let inTypesString = rawInTypes.substring(with: result.rangeAt(1))
46+
let inTypesString = rawInTypes.substring(with: result.range(at: 1))
4747
if inTypesString.isEmpty {
4848
return []
4949
}

Generate.../FuncSignature.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ struct FuncSignature {
3030
guard let nameResult = "func ([\\S]*)\\(".firstMatch(in: string) else {
3131
throw NSError.sourceInvalid
3232
}
33-
name = string.substring(with: nameResult.rangeAt(1))
33+
name = string.substring(with: nameResult.range(at: 1))
3434

3535
let paramsRange = try string.paramsRange()
3636
let rawParams = string.substring(with: paramsRange)
@@ -45,7 +45,7 @@ struct FuncSignature {
4545
returnType = SwiftType.Void
4646
return
4747
}
48-
let returnTypeString = stringAfterLastParam.substring(with: returnTypeResult.rangeAt(1)).replacingOccurrences(of: "{", with: "").trimed
48+
let returnTypeString = stringAfterLastParam.substring(with: returnTypeResult.range(at: 1)).replacingOccurrences(of: "{", with: "").trimed
4949
returnType = TypeParser.parse(string: returnTypeString)
5050
}
5151
}

Generate.../InterfaceDefinition.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ struct InterfaceDefinition {
1919
guard let definition = "(protocol|class|extension|struct) ([A-Za-z]*)".firstMatch(in: line) else {
2020
continue
2121
}
22-
name = line.substring(with: definition.rangeAt(2))
23-
type = line.substring(with: definition.rangeAt(1))
22+
name = line.substring(with: definition.range(at: 2))
23+
type = line.substring(with: definition.range(at: 1))
2424
lineIndex = index
2525
return
2626
}

Generate.../InterfaceSignature.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ struct InterfaceSignature {
4141
if let firstTwoIndex = line.trimed.index(line.trimed.startIndex, offsetBy: 2, limitedBy: line.trimed.endIndex),line.trimed.substring(to: firstTwoIndex) == "//" {
4242
continue
4343
}
44-
openBraceCount += line.characters.filter { $0 == "{" }.count
45-
openBraceCount -= line.characters.filter { $0 == "}" }.count
44+
let lineOpen = line.filter { $0 == "{" }
45+
openBraceCount += lineOpen.count
46+
let lineClose = line.filter { $0 == "}" }
47+
openBraceCount -= lineClose.count
4648
guard openBraceCount == 1 else { continue }
4749
guard let varSignature = VarSignature(string: line) else { continue }
4850
varSignatures.append(varSignature)

Generate.../VarSignature.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ struct VarSignature {
2424
guard let result = "(var|let)\\s*(\\S*)\\s*:\\s*(\\S[^\\{]*[^ \\{])".firstMatch(in: string) else {
2525
return nil
2626
}
27-
declaration = string.substring(with: result.rangeAt(1))
28-
name = string.substring(with: result.rangeAt(2))
29-
let typeString = string.substring(with: result.rangeAt(3))
27+
declaration = string.substring(with: result.range(at: 1))
28+
name = string.substring(with: result.range(at: 2))
29+
let typeString = string.substring(with: result.range(at: 3))
3030
type = TypeParser.parse(string: typeString)
3131
accessLevel = AccessLevel(string: string)
3232
}

0 commit comments

Comments
 (0)