瀏覽代碼

Fix watchOS error and update CI to contain watchOS build

onevcat 5 年之前
父節點
當前提交
4e512d3a4d
共有 3 個文件被更改,包括 38 次插入16 次删除
  1. 6 1
      .github/workflows/build.yaml
  2. 3 0
      Sources/Extensions/NSTextAttachment+Kingfisher.swift
  3. 29 15
      fastlane/Fastfile

+ 6 - 1
.github/workflows/build.yaml

@@ -7,7 +7,12 @@ jobs:
     runs-on: macOS-latest
     strategy:
       matrix:
-        destination: ['macOS', 'iOS Simulator,name=iPhone 8', 'tvOS Simulator,name=Apple TV']
+        destination: [
+          'macOS', 
+          'iOS Simulator,name=iPhone 8', 
+          'tvOS Simulator,name=Apple TV', 
+          'watchOS Simulator,name=Apple Watch Series 5 - 40mm'
+        ]
         swift-version: [5.0, 4.2, 4.0]
     steps:
       - uses: actions/checkout@v1

+ 3 - 0
Sources/Extensions/NSTextAttachment+Kingfisher.swift

@@ -24,6 +24,7 @@
 //  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 //  THE SOFTWARE.
 
+#if !os(watchOS)
 
 #if os(macOS)
 import AppKit
@@ -252,3 +253,5 @@ extension KingfisherWrapper where Base: NSTextAttachment {
         set { setRetainedAssociatedObject(base, &imageTaskKey, newValue)}
     }
 }
+
+#endif

+ 29 - 15
fastlane/Fastfile

@@ -7,23 +7,31 @@ platform :ios do
   desc "Runs all the tests"
   lane :tests do
     test(destination: "platform=macOS", swift_version: "5.0")
-    test(destination: "platform=iOS Simulator,name=iPhone 8", swift_version: "5.0")
-    test(destination: "platform=tvOS Simulator,name=Apple TV", swift_version: "5.0")
-    
     test(destination: "platform=macOS", swift_version: "4.2")
-    test(destination: "platform=iOS Simulator,name=iPhone 8", swift_version: "4.2")
-    test(destination: "platform=tvOS Simulator,name=Apple TV", swift_version: "4.2")
-    
     test(destination: "platform=macOS", swift_version: "4.0")
+
+    test(destination: "platform=iOS Simulator,name=iPhone 8", swift_version: "5.0")
+    test(destination: "platform=iOS Simulator,name=iPhone 8", swift_version: "4.2")
     test(destination: "platform=iOS Simulator,name=iPhone 8", swift_version: "4.0")
+    
+    test(destination: "platform=tvOS Simulator,name=Apple TV", swift_version: "5.0")
+    test(destination: "platform=tvOS Simulator,name=Apple TV", swift_version: "4.2")
     test(destination: "platform=tvOS Simulator,name=Apple TV", swift_version: "4.0")
+    
+    build(destination: "platform=watchOS Simulator,name=Apple Watch Series 5 - 40mm", swift_version: "4.0")
+    build(destination: "platform=watchOS Simulator,name=Apple Watch Series 5 - 40mm", swift_version: "4.2")
+    build(destination: "platform=watchOS Simulator,name=Apple Watch Series 5 - 40mm", swift_version: "5.0")
   end
-  
-  lane :test do |options|
-    _test(options)
+    
+  lane :test_ci do
+    if ENV["DESTINATION"].include? "watchOS" then
+        build_watch_os(destination: ENV["DESTINATION"], swift_version: ENV["SWIFT_VERSION"])
+    else
+        test(destination: ENV["DESTINATION"], swift_version: ENV["SWIFT_VERSION"])
+    end
   end
-  
-  private_lane :_test do |options|
+
+  lane :test do |options|
     scan(
       scheme: "Kingfisher", 
       clean: true, 
@@ -31,11 +39,17 @@ platform :ios do
       destination: options[:destination]
     )
   end
-  
-  lane :test_ci do
-    test(destination: ENV["DESTINATION"], swift_version: ENV["SWIFT_VERSION"])
+
+  lane :build do |options|
+    gym(
+      workspace: "Kingfisher.xcworkspace",
+      configuration: "Debug",
+      scheme: "Kingfisher",
+      xcargs: "SWIFT_VERSION=#{options[:swift_version]}",
+      destination: options[:destination]
+    )
   end
-  
+
   desc "Lint"
   lane :lint do
     carthage(command: "build", no_skip_current: true, platform: "iOS")