Ver Fonte

Merge pull request #36 from norio-nomura/swift-4.1

Add Swift 4.1 and remove Swift 3.x
Norio Nomura há 7 anos atrás
pai
commit
04f8eaa6b4

+ 32 - 69
.circleci/config.yml

@@ -1,42 +1,19 @@
 aliases:
 aliases:
-  - &store-test-results
-    path: build/reports/
-
-  - &restore-cocoapods-cache
-    key: cocoapods
-
-  - &save-cocoapods-cache
-    key: cocoapods
-    paths:
-      - ~/.cocoapods
-
-  - &steps-for-xcode-8
-    - checkout
-    - run: |
-        ( xcodebuild -scheme Base32 build-for-testing test-without-building # -sdk macosx -destination arch=x86_64
-          xcodebuild -scheme Base32 build-for-testing test-without-building -destination "name=iPhone 7"
-          xcodebuild -scheme Base32 build-for-testing test-without-building -destination "name=Apple TV 1080p"
-          xcodebuild -scheme Base32 build -destination "name=Apple Watch - 38mm"
-        ) | xcpretty -r junit
-    - store_test_results: *store-test-results
-    - restore_cache: *restore-cocoapods-cache
-    - run: pod lib lint
-    - save_cache: *save-cocoapods-cache
-
-  - &steps-for-xcode-9
-    - checkout
-    - run: |
-        ( export XCODE_FLAGS="-scheme Base32 SWIFT_VERSION=${SWIFT_VERSION}"
-          xcodebuild ${XCODE_FLAGS} test # -sdk macosx -destination arch=x86_64
-          xcodebuild ${XCODE_FLAGS} test -sdk iphonesimulator -destination "name=iPhone 8"
-          xcodebuild ${XCODE_FLAGS} test -sdk appletvsimulator -destination "name=Apple TV 4K"
-          xcodebuild ${XCODE_FLAGS} build -sdk watchsimulator -destination "name=Apple Watch Series 3 - 38mm"
-        ) | xcpretty -r junit
-    - store_test_results: *store-test-results
-    - restore_cache: *restore-cocoapods-cache
-    - run: pod lib lint --swift-version=${SWIFT_VERSION}
-    - save_cache: *save-cocoapods-cache
-    - run: bash <(curl -s https://codecov.io/bash)
+  - &xcode-9
+    shell: /bin/bash --login -eo pipefail
+    steps:
+      - checkout
+      - run: |
+          ( xcodebuild -scheme Base32 test # -sdk macosx -destination arch=x86_64
+            xcodebuild -scheme Base32 test -sdk iphonesimulator -destination "name=iPhone 8"
+            xcodebuild -scheme Base32 test -sdk appletvsimulator -destination "name=Apple TV 4K"
+            xcodebuild -scheme Base32 build -sdk watchsimulator -destination "name=Apple Watch Series 3 - 38mm"
+          ) | xcpretty -r junit
+      - store_test_results:
+          path: build/reports/
+      - run: echo "ruby-2.3" > ~/.ruby-version
+      - run: pod lib lint
+      - run: bash <(curl -s https://codecov.io/bash)
 
 
   - &steps-for-spm
   - &steps-for-spm
     - checkout
     - checkout
@@ -45,43 +22,25 @@ aliases:
 version: 2
 version: 2
 jobs:
 jobs:
 
 
-  xcode_8.3.3:
-    macos:
-      xcode: "8.3.3"
-    steps: *steps-for-xcode-8
-
-  xcode_9_swift_3:
-    macos:
-      xcode: "9.0"
-    environment:
-      - SWIFT_VERSION: 3.0
-    steps: *steps-for-xcode-9
-
   xcode_9_swift_4:
   xcode_9_swift_4:
     macos:
     macos:
       xcode: "9.0"
       xcode: "9.0"
-    environment:
-      - SWIFT_VERSION: 4.0
-    steps: *steps-for-xcode-9
+    <<: *xcode-9
 
 
   xcode_9.1_swift_4.0.2:
   xcode_9.1_swift_4.0.2:
     macos:
     macos:
       xcode: "9.1.0"
       xcode: "9.1.0"
-    environment:
-      - SWIFT_VERSION: 4.0
-    steps: *steps-for-xcode-9
+    <<: *xcode-9
 
 
   xcode_9.2_swift_4.0.3:
   xcode_9.2_swift_4.0.3:
     macos:
     macos:
       xcode: "9.2.0"
       xcode: "9.2.0"
-    environment:
-      - SWIFT_VERSION: 4.0
-    steps: *steps-for-xcode-9
+    <<: *xcode-9
 
 
-  spm_swift_3.1.1:
+  xcode_9.3_swift_4.1:
     macos:
     macos:
-      xcode: "8.3.3"
-    steps: *steps-for-spm
+      xcode: "9.3.0"
+    <<: *xcode-9
 
 
   spm_swift_4:
   spm_swift_4:
     macos:
     macos:
@@ -98,9 +57,9 @@ jobs:
       xcode: "9.2.0"
       xcode: "9.2.0"
     steps: *steps-for-spm
     steps: *steps-for-spm
 
 
-  linux_swift_3.1.1:
-    docker:
-      - image: norionomura/swift:311
+  spm_swift_4.1:
+    macos:
+      xcode: "9.3.0"
     steps: *steps-for-spm
     steps: *steps-for-spm
 
 
   linux_swift_4:
   linux_swift_4:
@@ -118,20 +77,24 @@ jobs:
       - image: norionomura/swift:403
       - image: norionomura/swift:403
     steps: *steps-for-spm
     steps: *steps-for-spm
 
 
+  linux_swift_4.1:
+    docker:
+      - image: norionomura/swift:41
+    steps: *steps-for-spm
+
 workflows:
 workflows:
   version: 2
   version: 2
   workflow:
   workflow:
     jobs:
     jobs:
-      - xcode_8.3.3
-      - xcode_9_swift_3
       - xcode_9_swift_4
       - xcode_9_swift_4
       - xcode_9.1_swift_4.0.2
       - xcode_9.1_swift_4.0.2
       - xcode_9.2_swift_4.0.3
       - xcode_9.2_swift_4.0.3
-      - spm_swift_3.1.1
+      - xcode_9.3_swift_4.1
       - spm_swift_4
       - spm_swift_4
       - spm_swift_4.0.2
       - spm_swift_4.0.2
       - spm_swift_4.0.3
       - spm_swift_4.0.3
-      - linux_swift_3.1.1
+      - spm_swift_4.1
       - linux_swift_4
       - linux_swift_4
       - linux_swift_4.0.2
       - linux_swift_4.0.2
       - linux_swift_4.0.3
       - linux_swift_4.0.3
+      - linux_swift_4.1

+ 1 - 1
.swift-version

@@ -1 +1 @@
-3.0
+4.0

+ 0 - 38
.travis.yml

@@ -1,38 +0,0 @@
-language: generic
-matrix:
-  include:
-  - script:
-    - set -o pipefail
-    - xcodebuild -scheme Base32 build-for-testing test-without-building | xcpretty
-    - xcodebuild -scheme Base32 build-for-testing test-without-building -destination "name=iPhone 7" | xcpretty
-    - xcodebuild -scheme Base32 build-for-testing test-without-building -destination "name=Apple TV 1080p" | xcpretty
-    - xcodebuild -scheme Base32 build -destination "name=Apple Watch - 38mm" | xcpretty
-    - swift test
-    - pod lib lint
-    env: JOB=macOS-Swift3.0.2
-    os: osx
-    osx_image: xcode8.2
-  - script:
-    - set -o pipefail
-    - xcodebuild -scheme Base32 build-for-testing test-without-building | xcpretty
-    - xcodebuild -scheme Base32 build-for-testing test-without-building -destination "name=iPhone 7" | xcpretty
-    - xcodebuild -scheme Base32 build-for-testing test-without-building -destination "name=Apple TV 1080p" | xcpretty
-    - xcodebuild -scheme Base32 build -destination "name=Apple Watch - 38mm" | xcpretty
-    - swift test
-    - pod lib lint
-    env: JOB=macOS-Swift3.1
-    os: osx
-    osx_image: xcode8.3
-    before_install:
-      - xcrun simctl delete 38C891AB-EC79-43E4-9311-6FDEB12DCF11 || true
-  - script: docker run -v `pwd`:`pwd` -w `pwd` swift:3.0.2 swift test
-    env: JOB=Linux-Swift3.0.2
-    sudo: required
-    services: docker
-  - script: docker run -v `pwd`:`pwd` -w `pwd` swift:3.1 swift test
-    env: JOB=Linux-Swift3.1
-    sudo: required
-    services: docker
-notifications:
-  webhooks:
-    secure: TKFWG5dDRlNK/XbsC7eKDEh7vnydCUYjGc1Sv9DUOfRjvxYBMq+ys8R9iHAotNNtnCdacohM0bcwT1ZXQcRTYKEd6vKtY1XkkPA2xBogLVfhu17DCDMhJ3iTtati1mMK1rVeSgseXffOKVq1ZjNGjBVCIHl0PZoj5jFiOwYKKO8=

+ 10 - 0
Base32.xcodeproj/Configs/Project.xcconfig

@@ -9,12 +9,21 @@ OTHER_SWIFT_FLAGS = -DXcode
 COMBINE_HIDPI_IMAGES = YES
 COMBINE_HIDPI_IMAGES = YES
 USE_HEADERMAP = NO
 USE_HEADERMAP = NO
 FRAMEWORK_SEARCH_PATHS = "$(PLATFORM_DIR)/Developer/Library/Frameworks";
 FRAMEWORK_SEARCH_PATHS = "$(PLATFORM_DIR)/Developer/Library/Frameworks";
+CLANG_ENABLE_OBJC_WEAK = YES;
+CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
 CLANG_WARN_BOOL_CONVERSION = YES;
 CLANG_WARN_BOOL_CONVERSION = YES;
+CLANG_WARN_COMMA = YES;
 CLANG_WARN_CONSTANT_CONVERSION = YES;
 CLANG_WARN_CONSTANT_CONVERSION = YES;
+CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
 CLANG_WARN_EMPTY_BODY = YES;
 CLANG_WARN_EMPTY_BODY = YES;
 CLANG_WARN_ENUM_CONVERSION = YES;
 CLANG_WARN_ENUM_CONVERSION = YES;
 CLANG_WARN_INFINITE_RECURSION = YES;
 CLANG_WARN_INFINITE_RECURSION = YES;
 CLANG_WARN_INT_CONVERSION = YES;
 CLANG_WARN_INT_CONVERSION = YES;
+CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
+CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+CLANG_WARN_STRICT_PROTOTYPES = YES;
 CLANG_WARN_SUSPICIOUS_MOVE = YES;
 CLANG_WARN_SUSPICIOUS_MOVE = YES;
 CLANG_WARN_UNREACHABLE_CODE = YES;
 CLANG_WARN_UNREACHABLE_CODE = YES;
 CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
 CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -26,3 +35,4 @@ GCC_WARN_UNDECLARED_SELECTOR = YES;
 GCC_WARN_UNINITIALIZED_AUTOS = YES;
 GCC_WARN_UNINITIALIZED_AUTOS = YES;
 GCC_WARN_UNUSED_FUNCTION = YES;
 GCC_WARN_UNUSED_FUNCTION = YES;
 GCC_WARN_UNUSED_VARIABLE = YES;
 GCC_WARN_UNUSED_VARIABLE = YES;
+SWIFT_VERSION = 4.0;

+ 1 - 19
Base32.xcodeproj/project.pbxproj

@@ -224,7 +224,7 @@
 		__RootObject_ /* Project object */ = {
 		__RootObject_ /* Project object */ = {
 			isa = PBXProject;
 			isa = PBXProject;
 			attributes = {
 			attributes = {
-				LastUpgradeCheck = 9999;
+				LastUpgradeCheck = 0930;
 			};
 			};
 			buildConfigurationList = "___RootConfs_" /* Build configuration list for PBXProject "Base32" */;
 			buildConfigurationList = "___RootConfs_" /* Build configuration list for PBXProject "Base32" */;
 			compatibilityVersion = "Xcode 3.2";
 			compatibilityVersion = "Xcode 3.2";
@@ -291,12 +291,9 @@
 			buildSettings = {
 			buildSettings = {
 				APPLICATION_EXTENSION_API_ONLY = YES;
 				APPLICATION_EXTENSION_API_ONLY = YES;
 				INFOPLIST_FILE = Base32.xcodeproj/Base32_Info.plist;
 				INFOPLIST_FILE = Base32.xcodeproj/Base32_Info.plist;
-				OTHER_LDFLAGS = "$(inherited)";
-				OTHER_SWIFT_FLAGS = "$(inherited)";
 				PRODUCT_BUNDLE_IDENTIFIER = Base32;
 				PRODUCT_BUNDLE_IDENTIFIER = Base32;
 				PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
 				PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
 				PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
 				PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
-				SWIFT_VERSION = 3.0;
 			};
 			};
 			name = Release;
 			name = Release;
 		};
 		};
@@ -306,9 +303,6 @@
 				ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
 				ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
 				INFOPLIST_FILE = Base32.xcodeproj/Base32Tests_Info.plist;
 				INFOPLIST_FILE = Base32.xcodeproj/Base32Tests_Info.plist;
 				LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks @loader_path/Frameworks";
 				LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks @loader_path/Frameworks";
-				OTHER_LDFLAGS = "$(inherited)";
-				OTHER_SWIFT_FLAGS = "$(inherited)";
-				SWIFT_VERSION = 3.0;
 			};
 			};
 			name = Release;
 			name = Release;
 		};
 		};
@@ -318,9 +312,6 @@
 				ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
 				ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
 				INFOPLIST_FILE = Base32.xcodeproj/SecEncodeTransformTests_Info.plist;
 				INFOPLIST_FILE = Base32.xcodeproj/SecEncodeTransformTests_Info.plist;
 				LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks @loader_path/Frameworks";
 				LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks @loader_path/Frameworks";
-				OTHER_LDFLAGS = "$(inherited)";
-				OTHER_SWIFT_FLAGS = "$(inherited)";
-				SWIFT_VERSION = 3.0;
 			};
 			};
 			name = Release;
 			name = Release;
 		};
 		};
@@ -329,12 +320,9 @@
 			buildSettings = {
 			buildSettings = {
 				APPLICATION_EXTENSION_API_ONLY = YES;
 				APPLICATION_EXTENSION_API_ONLY = YES;
 				INFOPLIST_FILE = Base32.xcodeproj/Base32_Info.plist;
 				INFOPLIST_FILE = Base32.xcodeproj/Base32_Info.plist;
-				OTHER_LDFLAGS = "$(inherited)";
-				OTHER_SWIFT_FLAGS = "$(inherited)";
 				PRODUCT_BUNDLE_IDENTIFIER = Base32;
 				PRODUCT_BUNDLE_IDENTIFIER = Base32;
 				PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
 				PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)";
 				PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
 				PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
-				SWIFT_VERSION = 3.0;
 			};
 			};
 			name = Debug;
 			name = Debug;
 		};
 		};
@@ -344,9 +332,6 @@
 				ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
 				ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
 				INFOPLIST_FILE = Base32.xcodeproj/Base32Tests_Info.plist;
 				INFOPLIST_FILE = Base32.xcodeproj/Base32Tests_Info.plist;
 				LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks @loader_path/Frameworks";
 				LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks @loader_path/Frameworks";
-				OTHER_LDFLAGS = "$(inherited)";
-				OTHER_SWIFT_FLAGS = "$(inherited)";
-				SWIFT_VERSION = 3.0;
 			};
 			};
 			name = Debug;
 			name = Debug;
 		};
 		};
@@ -356,9 +341,6 @@
 				ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
 				ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
 				INFOPLIST_FILE = Base32.xcodeproj/SecEncodeTransformTests_Info.plist;
 				INFOPLIST_FILE = Base32.xcodeproj/SecEncodeTransformTests_Info.plist;
 				LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks @loader_path/Frameworks";
 				LD_RUNPATH_SEARCH_PATHS = "@loader_path/../Frameworks @loader_path/Frameworks";
-				OTHER_LDFLAGS = "$(inherited)";
-				OTHER_SWIFT_FLAGS = "$(inherited)";
-				SWIFT_VERSION = 3.0;
 			};
 			};
 			name = Debug;
 			name = Debug;
 		};
 		};

+ 8 - 0
Base32.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>IDEDidComputeMac32BitWarning</key>
+	<true/>
+</dict>
+</plist>

+ 3 - 5
Base32.xcodeproj/xcshareddata/xcschemes/Base32.xcscheme

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
 <Scheme
-   LastUpgradeVersion = "9999"
+   LastUpgradeVersion = "0930"
    version = "1.3">
    version = "1.3">
    <BuildAction
    <BuildAction
       parallelizeBuildables = "YES"
       parallelizeBuildables = "YES"
@@ -26,9 +26,8 @@
       buildConfiguration = "Release"
       buildConfiguration = "Release"
       selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
       selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
-      language = ""
-      shouldUseLaunchSchemeArgsEnv = "YES"
-      codeCoverageEnabled = "YES">
+      codeCoverageEnabled = "YES"
+      shouldUseLaunchSchemeArgsEnv = "YES">
       <Testables>
       <Testables>
          <TestableReference
          <TestableReference
             skipped = "NO">
             skipped = "NO">
@@ -58,7 +57,6 @@
       buildConfiguration = "Debug"
       buildConfiguration = "Debug"
       selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
       selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
       selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
-      language = ""
       launchStyle = "0"
       launchStyle = "0"
       useCustomWorkingDirectory = "NO"
       useCustomWorkingDirectory = "NO"
       ignoresPersistentStateOnLaunch = "NO"
       ignoresPersistentStateOnLaunch = "NO"

+ 13 - 8
Package.swift

@@ -1,12 +1,17 @@
+// swift-tools-version:4.0
 import PackageDescription
 import PackageDescription
 
 
-let package = Package(
+var package = Package(
     name: "Base32",
     name: "Base32",
-    exclude: {
-        #if os(Linux)
-            return ["Tests/SecEncodeTransformTests"]
-        #else
-            return []
-        #endif
-    }()
+    products: [
+      .library(name: "Base32", targets: ["Base32"])
+    ],
+    targets: [
+        .target(name: "Base32"),
+        .testTarget(name: "Base32Tests", dependencies: ["Base32"])
+    ]
 )
 )
+
+#if os(macOS)
+    package.targets.append(.testTarget(name: "SecEncodeTransformTests", dependencies: ["Base32"]))
+#endif

+ 0 - 18
Package@swift-4.swift

@@ -1,18 +0,0 @@
-// swift-tools-version:4.0
-import PackageDescription
-
-var package = Package(
-    name: "Base32",
-    products: [
-      .library(name: "Base32", targets: ["Base32"])
-    ],
-    targets: [
-        .target(name: "Base32"),
-        .testTarget(name: "Base32Tests", dependencies: ["Base32"])
-    ],
-    swiftLanguageVersions: [3, 4]
-)
-
-#if os(macOS)
-    package.targets.append(.testTarget(name: "SecEncodeTransformTests", dependencies: ["Base32"]))
-#endif

+ 8 - 0
Sources/Base32/Base32.swift

@@ -224,10 +224,18 @@ private func base32encode(_ data: UnsafeRawPointer, _ length: Int, _ table: [Int
     
     
     // return
     // return
     if let base32Encoded = String(validatingUTF8: resultBuffer) {
     if let base32Encoded = String(validatingUTF8: resultBuffer) {
+#if swift(>=4.1)
+        resultBuffer.deallocate()
+#else
         resultBuffer.deallocate(capacity: resultBufferSize)
         resultBuffer.deallocate(capacity: resultBufferSize)
+#endif
         return base32Encoded
         return base32Encoded
     } else {
     } else {
+#if swift(>=4.1)
+        resultBuffer.deallocate()
+#else
         resultBuffer.deallocate(capacity: resultBufferSize)
         resultBuffer.deallocate(capacity: resultBufferSize)
+#endif
         fatalError("internal error")
         fatalError("internal error")
     }
     }
 }
 }

+ 2 - 6
Tests/Base32Tests/StringExtensionTests.swift

@@ -46,12 +46,8 @@ class StringExtensionTests: XCTestCase {
     }
     }
 
 
     func test_dataUsingUTF8StringEncoding_empty() {
     func test_dataUsingUTF8StringEncoding_empty() {
-        #if !os(Linux) || (os(Linux) && swift(>=3.1))
-            let emptyString = ""
-            XCTAssertEqual(emptyString.dataUsingUTF8StringEncoding, emptyString.data(using: .utf8, allowLossyConversion: false)!)
-        #else
-            print("\(#function) is skipped because that crashes on Swift 3.0.2 for Linux.")
-        #endif
+        let emptyString = ""
+        XCTAssertEqual(emptyString.dataUsingUTF8StringEncoding, emptyString.data(using: .utf8, allowLossyConversion: false)!)
     }
     }
 }
 }