From 341620e53be2b06f2e55cdbefc41e0fcf113012a Mon Sep 17 00:00:00 2001 From: Roman Podymov Date: Thu, 30 Jul 2020 22:44:21 +0200 Subject: [PATCH] tvOS support (#81) * Supported in iOS only * Supported in iOS only * CreationPanelViewController is not supported in tvOS * refreshControl is not supported in tvOS * tvOS support * tvOS target * Create Info.plist * Add files via upload * tvOS 10.0 * Update MagazineLayout.podspec * tvOS 10.0+ * tvOS deployment target * tvOS deployment target * Fixing tvOS build errors * Fixing tvOS build errors * Update LaunchScreen.storyboard * Fixing Travis CI errors * Fixing Travis CI errors * Update .travis.yml * Update .travis.yml * Update .travis.yml * Update project.pbxproj * Update project.pbxproj * Update .travis.yml * Update project.pbxproj * Update project.pbxproj * SPM + tvOS --- .travis.yml | 2 +- .../project.pbxproj | 156 +++++++++++++++++- .../CreationPanelViewController.swift | 2 + .../ViewController.swift | 16 ++ .../Views/ItemCreationPanelView.swift | 2 + .../MagazineLayoutExampleAppleTV/Info.plist | 32 ++++ .../LaunchScreen.storyboard | 29 ++++ MagazineLayout.podspec | 1 + MagazineLayout.xcodeproj/project.pbxproj | 12 +- .../Types/MagazineLayoutSectionMetrics.swift | 2 +- MagazineLayout/Public/MagazineLayout.swift | 8 +- Package.swift | 3 +- README.md | 2 +- 13 files changed, 252 insertions(+), 15 deletions(-) create mode 100644 Example/MagazineLayoutExampleAppleTV/Info.plist create mode 100644 Example/MagazineLayoutExampleAppleTV/LaunchScreen.storyboard diff --git a/.travis.yml b/.travis.yml index e3633ad..3df9605 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,4 +10,4 @@ before_script: - carthage build --verbose --no-skip-current script: - xcodebuild -project MagazineLayout.xcodeproj -scheme MagazineLayout -sdk iphonesimulator -destination "platform=iOS Simulator,OS=12.0,name=iPhone XS" -configuration Debug -PBXBuildsContinueAfterErrors=0 SWIFT_VERSION=$SWIFT_VERSION build test - + - xcodebuild -project MagazineLayout.xcodeproj -scheme MagazineLayout -sdk appletvsimulator -destination "platform=tvOS Simulator,OS=12.0,name=Apple TV" -configuration Debug -PBXBuildsContinueAfterErrors=0 SWIFT_VERSION=$SWIFT_VERSION build test diff --git a/Example/MagazineLayoutExample.xcodeproj/project.pbxproj b/Example/MagazineLayoutExample.xcodeproj/project.pbxproj index 847fbb3..98a7951 100644 --- a/Example/MagazineLayoutExample.xcodeproj/project.pbxproj +++ b/Example/MagazineLayoutExample.xcodeproj/project.pbxproj @@ -8,6 +8,22 @@ /* Begin PBXBuildFile section */ 8F78E959225BD81000CAE309 /* Background.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F78E958225BD81000CAE309 /* Background.swift */; }; + DB68BA8324C7754400365AD4 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD23F60021AF519700AA78D4 /* AppDelegate.swift */; }; + DB68BA8424C7754700365AD4 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD23F60221AF519700AA78D4 /* ViewController.swift */; }; + DB68BA8524C7754B00365AD4 /* CreationPanelViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD138CE021B23D64006BFABC /* CreationPanelViewController.swift */; }; + DB68BA8624C7754E00365AD4 /* DataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD23F62921AF599000AA78D4 /* DataSource.swift */; }; + DB68BA8724C7755000365AD4 /* Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD138CD321B201D0006BFABC /* Data.swift */; }; + DB68BA8824C7755300365AD4 /* DataSourceCountsProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD138CDE21B2310A006BFABC /* DataSourceCountsProvider.swift */; }; + DB68BA8924C7755500365AD4 /* Colors.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD89ED1821BFAD7D00607E70 /* Colors.swift */; }; + DB68BA8A24C7755800365AD4 /* Header.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD138CD721B226A7006BFABC /* Header.swift */; }; + DB68BA8B24C7755B00365AD4 /* Footer.swift in Sources */ = {isa = PBXBuildFile; fileRef = FCAC64292208870300973F4C /* Footer.swift */; }; + DB68BA8C24C7755E00365AD4 /* Cell.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD138CD521B20875006BFABC /* Cell.swift */; }; + DB68BA8D24C7756100365AD4 /* Background.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F78E958225BD81000CAE309 /* Background.swift */; }; + DB68BA8E24C7756300365AD4 /* ItemCreationPanelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD138CDC21B22BBE006BFABC /* ItemCreationPanelView.swift */; }; + DB68BA8F24C7756600365AD4 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FD23F60721AF519900AA78D4 /* Assets.xcassets */; }; + DB68BA9224C775B200365AD4 /* MagazineLayout.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DB68BA9124C775B200365AD4 /* MagazineLayout.framework */; }; + DB68BA9324C775B200365AD4 /* MagazineLayout.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = DB68BA9124C775B200365AD4 /* MagazineLayout.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + DB68BA9624C7775F00365AD4 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DB68BA9524C7775F00365AD4 /* LaunchScreen.storyboard */; }; FCAC642A2208870300973F4C /* Footer.swift in Sources */ = {isa = PBXBuildFile; fileRef = FCAC64292208870300973F4C /* Footer.swift */; }; FD138CD421B201D0006BFABC /* Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD138CD321B201D0006BFABC /* Data.swift */; }; FD138CD621B20875006BFABC /* Cell.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD138CD521B20875006BFABC /* Cell.swift */; }; @@ -26,6 +42,17 @@ /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ + DB68BA9424C775B200365AD4 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + DB68BA9324C775B200365AD4 /* MagazineLayout.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; FD69EAB221BA2B17001E0650 /* Embed Frameworks */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -41,6 +68,10 @@ /* Begin PBXFileReference section */ 8F78E958225BD81000CAE309 /* Background.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Background.swift; sourceTree = ""; }; + DB68BA7124C7751100365AD4 /* MagazineLayoutExampleAppleTV.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MagazineLayoutExampleAppleTV.app; sourceTree = BUILT_PRODUCTS_DIR; }; + DB68BA7F24C7751400365AD4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + DB68BA9124C775B200365AD4 /* MagazineLayout.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MagazineLayout.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + DB68BA9524C7775F00365AD4 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = ""; }; FCAC64292208870300973F4C /* Footer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Footer.swift; sourceTree = ""; }; FD138CD321B201D0006BFABC /* Data.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Data.swift; sourceTree = ""; }; FD138CD521B20875006BFABC /* Cell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Cell.swift; sourceTree = ""; }; @@ -60,6 +91,14 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + DB68BA6E24C7751100365AD4 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + DB68BA9224C775B200365AD4 /* MagazineLayout.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; FD23F5FA21AF519700AA78D4 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -71,6 +110,15 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + DB68BA7224C7751100365AD4 /* MagazineLayoutExampleAppleTV */ = { + isa = PBXGroup; + children = ( + DB68BA7F24C7751400365AD4 /* Info.plist */, + DB68BA9524C7775F00365AD4 /* LaunchScreen.storyboard */, + ); + path = MagazineLayoutExampleAppleTV; + sourceTree = ""; + }; FD138CD921B22AE9006BFABC /* Views */ = { isa = PBXGroup; children = ( @@ -97,6 +145,7 @@ isa = PBXGroup; children = ( FD23F5FF21AF519700AA78D4 /* MagazineLayoutExample */, + DB68BA7224C7751100365AD4 /* MagazineLayoutExampleAppleTV */, FD23F5FE21AF519700AA78D4 /* Products */, FD23F62421AF548C00AA78D4 /* Frameworks */, ); @@ -106,6 +155,7 @@ isa = PBXGroup; children = ( FD23F5FD21AF519700AA78D4 /* MagazineLayoutExample.app */, + DB68BA7124C7751100365AD4 /* MagazineLayoutExampleAppleTV.app */, ); name = Products; sourceTree = ""; @@ -129,6 +179,7 @@ FD23F62421AF548C00AA78D4 /* Frameworks */ = { isa = PBXGroup; children = ( + DB68BA9124C775B200365AD4 /* MagazineLayout.framework */, FD23F62721AF578300AA78D4 /* MagazineLayout.framework */, ); name = Frameworks; @@ -137,6 +188,24 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ + DB68BA7024C7751100365AD4 /* MagazineLayoutExampleAppleTV */ = { + isa = PBXNativeTarget; + buildConfigurationList = DB68BA8224C7751400365AD4 /* Build configuration list for PBXNativeTarget "MagazineLayoutExampleAppleTV" */; + buildPhases = ( + DB68BA6D24C7751100365AD4 /* Sources */, + DB68BA6E24C7751100365AD4 /* Frameworks */, + DB68BA6F24C7751100365AD4 /* Resources */, + DB68BA9424C775B200365AD4 /* Embed Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = MagazineLayoutExampleAppleTV; + productName = MagazineLayoutExampleAppleTV; + productReference = DB68BA7124C7751100365AD4 /* MagazineLayoutExampleAppleTV.app */; + productType = "com.apple.product-type.application"; + }; FD23F5FC21AF519700AA78D4 /* MagazineLayoutExample */ = { isa = PBXNativeTarget; buildConfigurationList = FD23F60F21AF519900AA78D4 /* Build configuration list for PBXNativeTarget "MagazineLayoutExample" */; @@ -161,10 +230,13 @@ FD23F5F521AF519700AA78D4 /* Project object */ = { isa = PBXProject; attributes = { - LastSwiftUpdateCheck = 1010; + LastSwiftUpdateCheck = 1160; LastUpgradeCheck = 1010; ORGANIZATIONNAME = Airbnb; TargetAttributes = { + DB68BA7024C7751100365AD4 = { + CreatedOnToolsVersion = 11.6; + }; FD23F5FC21AF519700AA78D4 = { CreatedOnToolsVersion = 10.1; }; @@ -184,11 +256,21 @@ projectRoot = ""; targets = ( FD23F5FC21AF519700AA78D4 /* MagazineLayoutExample */, + DB68BA7024C7751100365AD4 /* MagazineLayoutExampleAppleTV */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + DB68BA6F24C7751100365AD4 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + DB68BA9624C7775F00365AD4 /* LaunchScreen.storyboard in Resources */, + DB68BA8F24C7756600365AD4 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; FD23F5FB21AF519700AA78D4 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -201,6 +283,25 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + DB68BA6D24C7751100365AD4 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + DB68BA8D24C7756100365AD4 /* Background.swift in Sources */, + DB68BA8B24C7755B00365AD4 /* Footer.swift in Sources */, + DB68BA8A24C7755800365AD4 /* Header.swift in Sources */, + DB68BA8424C7754700365AD4 /* ViewController.swift in Sources */, + DB68BA8724C7755000365AD4 /* Data.swift in Sources */, + DB68BA8E24C7756300365AD4 /* ItemCreationPanelView.swift in Sources */, + DB68BA8524C7754B00365AD4 /* CreationPanelViewController.swift in Sources */, + DB68BA8924C7755500365AD4 /* Colors.swift in Sources */, + DB68BA8624C7754E00365AD4 /* DataSource.swift in Sources */, + DB68BA8C24C7755E00365AD4 /* Cell.swift in Sources */, + DB68BA8324C7754400365AD4 /* AppDelegate.swift in Sources */, + DB68BA8824C7755300365AD4 /* DataSourceCountsProvider.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; FD23F5F921AF519700AA78D4 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -234,6 +335,42 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ + DB68BA8024C7751400365AD4 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image"; + CODE_SIGN_STYLE = Automatic; + INFOPLIST_FILE = MagazineLayoutExampleAppleTV/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.airbnb.MagazineLayoutExampleAppleTV; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = appletvos; + SWIFT_VERSION = 5.0; + TVOS_DEPLOYMENT_TARGET = 13.0; + }; + name = Debug; + }; + DB68BA8124C7751400365AD4 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image"; + CODE_SIGN_STYLE = Automatic; + INFOPLIST_FILE = MagazineLayoutExampleAppleTV/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.airbnb.MagazineLayoutExampleAppleTV; + PRODUCT_NAME = "$(TARGET_NAME)"; + SDKROOT = appletvos; + SWIFT_VERSION = 5.0; + TVOS_DEPLOYMENT_TARGET = 13.0; + }; + name = Release; + }; FD23F60D21AF519900AA78D4 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -289,9 +426,10 @@ MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + TARGETED_DEVICE_FAMILY = "1,2,3"; + TVOS_DEPLOYMENT_TARGET = 12.1; }; name = Debug; }; @@ -343,9 +481,10 @@ IPHONEOS_DEPLOYMENT_TARGET = 12.1; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; - SDKROOT = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; + TARGETED_DEVICE_FAMILY = "1,2,3"; + TVOS_DEPLOYMENT_TARGET = 12.1; VALIDATE_PRODUCT = YES; }; name = Release; @@ -366,6 +505,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.airbnb.MagazineLayoutExample; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; + SDKROOT = iphoneos; SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -387,6 +527,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.airbnb.MagazineLayoutExample; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; + SDKROOT = iphoneos; SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -395,6 +536,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + DB68BA8224C7751400365AD4 /* Build configuration list for PBXNativeTarget "MagazineLayoutExampleAppleTV" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + DB68BA8024C7751400365AD4 /* Debug */, + DB68BA8124C7751400365AD4 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; FD23F5F821AF519700AA78D4 /* Build configuration list for PBXProject "MagazineLayoutExample" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/Example/MagazineLayoutExample/CreationPanelViewController.swift b/Example/MagazineLayoutExample/CreationPanelViewController.swift index b693a4e..1c013d5 100644 --- a/Example/MagazineLayoutExample/CreationPanelViewController.swift +++ b/Example/MagazineLayoutExample/CreationPanelViewController.swift @@ -15,6 +15,7 @@ import UIKit +#if os(iOS) final class CreationPanelViewController: UIViewController { // MARK: Lifecycle @@ -89,3 +90,4 @@ final class CreationPanelViewController: UIViewController { } } +#endif diff --git a/Example/MagazineLayoutExample/ViewController.swift b/Example/MagazineLayoutExample/ViewController.swift index f558a2f..3079b50 100644 --- a/Example/MagazineLayoutExample/ViewController.swift +++ b/Example/MagazineLayoutExample/ViewController.swift @@ -78,7 +78,9 @@ final class ViewController: UIViewController { private lazy var dataSource = DataSource() + #if os(iOS) private var lastItemCreationPanelViewState: ItemCreationPanelViewState? + #endif private func removeAllData() { collectionView.performBatchUpdates({ @@ -355,6 +357,7 @@ final class ViewController: UIViewController { @objc private func addButtonTapped() { + #if os(iOS) let creationPanelViewController = CreationPanelViewController( dataSourceCountsProvider: dataSource, initialState: lastItemCreationPanelViewState) @@ -396,6 +399,19 @@ final class ViewController: UIViewController { let navigationController = UINavigationController( rootViewController: creationPanelViewController) present(navigationController, animated: true, completion: nil) + #else + let alertController = UIAlertController( + title: "Error", + message: "Not implemented for tvOS", + preferredStyle: .alert) + alertController.addAction( + UIAlertAction( + title: "OK", + style: .default, + handler: nil)) + + present(alertController, animated: true, completion: nil) + #endif } } diff --git a/Example/MagazineLayoutExample/Views/ItemCreationPanelView.swift b/Example/MagazineLayoutExample/Views/ItemCreationPanelView.swift index 2b59428..7c1a6d0 100644 --- a/Example/MagazineLayoutExample/Views/ItemCreationPanelView.swift +++ b/Example/MagazineLayoutExample/Views/ItemCreationPanelView.swift @@ -18,6 +18,7 @@ import UIKit // MARK: - ItemCreationPanelView +#if os(iOS) final class ItemCreationPanelView: UIView { // MARK: Lifecycle @@ -395,3 +396,4 @@ struct ItemCreationPanelViewState { let color: UIColor } +#endif diff --git a/Example/MagazineLayoutExampleAppleTV/Info.plist b/Example/MagazineLayoutExampleAppleTV/Info.plist new file mode 100644 index 0000000..2f0c6be --- /dev/null +++ b/Example/MagazineLayoutExampleAppleTV/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIRequiredDeviceCapabilities + + arm64 + + UIUserInterfaceStyle + Automatic + + diff --git a/Example/MagazineLayoutExampleAppleTV/LaunchScreen.storyboard b/Example/MagazineLayoutExampleAppleTV/LaunchScreen.storyboard new file mode 100644 index 0000000..3c7880a --- /dev/null +++ b/Example/MagazineLayoutExampleAppleTV/LaunchScreen.storyboard @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MagazineLayout.podspec b/MagazineLayout.podspec index 12f437d..12bef10 100644 --- a/MagazineLayout.podspec +++ b/MagazineLayout.podspec @@ -9,6 +9,7 @@ Pod::Spec.new do |s| s.swift_version = '4.0' s.source_files = 'MagazineLayout/**/*.{swift,h}' s.ios.deployment_target = '10.0' + s.tvos.deployment_target = '10.0' s.pod_target_xcconfig = { 'APPLICATION_EXTENSION_API_ONLY' => 'YES' diff --git a/MagazineLayout.xcodeproj/project.pbxproj b/MagazineLayout.xcodeproj/project.pbxproj index 6943ead..09b49cb 100644 --- a/MagazineLayout.xcodeproj/project.pbxproj +++ b/MagazineLayout.xcodeproj/project.pbxproj @@ -432,10 +432,12 @@ MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = "iphonesimulator iphoneos appletvsimulator appletvos"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2,3"; + TVOS_DEPLOYMENT_TARGET = 10.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -490,10 +492,12 @@ IPHONEOS_DEPLOYMENT_TARGET = 10.0; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; - SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = "iphonesimulator iphoneos appletvsimulator appletvos"; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2,3"; + TVOS_DEPLOYMENT_TARGET = 10.0; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -525,7 +529,6 @@ PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; SWIFT_VERSION = 4.0; - TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; @@ -555,7 +558,6 @@ SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-O"; SWIFT_VERSION = 4.0; - TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; }; @@ -576,7 +578,6 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 4.0; - TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; @@ -597,7 +598,6 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 4.0; - TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; }; diff --git a/MagazineLayout/LayoutCore/Types/MagazineLayoutSectionMetrics.swift b/MagazineLayout/LayoutCore/Types/MagazineLayoutSectionMetrics.swift index 2cf38a3..ea1a34f 100644 --- a/MagazineLayout/LayoutCore/Types/MagazineLayoutSectionMetrics.swift +++ b/MagazineLayout/LayoutCore/Types/MagazineLayoutSectionMetrics.swift @@ -28,7 +28,7 @@ struct MagazineLayoutSectionMetrics: Equatable { { collectionViewWidth = collectionView.bounds.width - if #available(iOS 11.0, *) { + if #available(iOS 11.0, tvOS 11.0, *) { collectionViewContentInset = collectionView.adjustedContentInset } else { collectionViewContentInset = collectionView.contentInset diff --git a/MagazineLayout/Public/MagazineLayout.swift b/MagazineLayout/Public/MagazineLayout.swift index 830ee59..6d7edcb 100755 --- a/MagazineLayout/Public/MagazineLayout.swift +++ b/MagazineLayout/Public/MagazineLayout.swift @@ -60,7 +60,7 @@ public final class MagazineLayout: UICollectionViewLayout { let width: CGFloat if let collectionView = collectionView { let contentInset: UIEdgeInsets - if #available(iOS 11.0, *) { + if #available(iOS 11.0, tvOS 11.0, *) { contentInset = collectionView.adjustedContentInset } else { contentInset = collectionView.contentInset @@ -886,13 +886,14 @@ public final class MagazineLayout: UICollectionViewLayout { // supporting pinned headers and footers. private var currentVisibleBounds: CGRect { let contentInset: UIEdgeInsets - if #available(iOS 11.0, *) { + if #available(iOS 11.0, tvOS 11.0, *) { contentInset = currentCollectionView.adjustedContentInset } else { contentInset = currentCollectionView.contentInset } let refreshControlHeight: CGFloat + #if os(iOS) if let refreshControl = currentCollectionView.refreshControl, refreshControl.isRefreshing @@ -901,6 +902,9 @@ public final class MagazineLayout: UICollectionViewLayout { } else { refreshControlHeight = 0 } + #else + refreshControlHeight = 0 + #endif return CGRect( x: currentCollectionView.bounds.minX + contentInset.left, diff --git a/Package.swift b/Package.swift index 41f6914..882fa6b 100644 --- a/Package.swift +++ b/Package.swift @@ -5,7 +5,8 @@ import PackageDescription let package = Package( name: "MagazineLayout", platforms: [ - .iOS(.v10) + .iOS(.v10), + .tvOS(.v10) ], products: [ .library(name: "MagazineLayout", targets: ["MagazineLayout"]) diff --git a/README.md b/README.md index 037072b..4920269 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ To delete an item, simple tap on the item in the collection view. The item will ## Getting Started ### Requirements -- Deployment target iOS 10.0+ +- Deployment target iOS 10.0+, tvOS 10.0+ - Swift 4+ - Xcode 10+