diff --git a/CHANGELOG.md b/CHANGELOG.md index 60f9c8d3..943a38fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Change Log - add **Swift Package Manager** support - add target for building binary framework +- macOS requirement is now 11.0 #### Breaking diff --git a/Docs/Documentation/Getting Started.md b/Docs/Documentation/Getting Started.md index ede54d92..777ae20e 100644 --- a/Docs/Documentation/Getting Started.md +++ b/Docs/Documentation/Getting Started.md @@ -23,7 +23,7 @@ - iOS 12 - tvOS 12 -- macOS 10.12 +- macOS 11 - Xcode 11/Swift 5 @@ -36,7 +36,7 @@ The **SKTiled** project contains six targets; three are demo applications for iO ### Framework Installation -To use the frameworks, build the appropriate framework target and add to your project. Make sure the **Minimum Deployment Target** is set correctly for your project (iOS11+/macOS 10.12+/tvOS12+). +To use the frameworks, build the appropriate framework target and add to your project. Make sure the **Minimum Deployment Target** is set correctly for your project (iOS11+/macOS 11+/tvOS12+). ![adding framework](images/framework.png) diff --git a/Package.swift b/Package.swift index 3718e15d..97310afd 100644 --- a/Package.swift +++ b/Package.swift @@ -44,7 +44,7 @@ let package = Package( .copy("Assets/monsters-16x16.png"), .copy("Assets/monsters-16x16.tsx"), .copy("Assets/portraits-8x8.png"), - .copy("Assets/portraits-8x8.tsx") + .copy("Assets/portraits-8x8.tsx"), ] ) ] diff --git a/README.md b/README.md index 829d54f0..9620dea8 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ Check out the [**Official Documentation**][sktiled-12-doc-url]. - iOS 12 - tvOS 12 -- macOS 10.12 +- macOS 11 - Xcode 11/Swift 5 ## Installation diff --git a/SKTiled.podspec b/SKTiled.podspec index 73fd85ec..9584af0a 100644 --- a/SKTiled.podspec +++ b/SKTiled.podspec @@ -3,13 +3,13 @@ Pod::Spec.new do |s| s.version = "1.23" s.summary = "SKTiled is a framework for using Tiled content with Apple's SpriteKit." s.description = <<-DESC - SKTiled is a framework for using Tiled content with Apple's SpriteKit, allowing the creation of game assets from .tmx files. + SKTiled is a framework for using Tiled content with Apple's SpriteKit, allowing the creation of game assets from Tiled .tmx files. DESC s.author = { "Michael Fessenden" => "michael.fessenden@gmail.com" } s.homepage = "https://github.com/mfessenden/SKTiled" s.license = { :type => 'MIT', :file => 'LICENSE.md' } - s.osx.deployment_target = '10.12' + s.osx.deployment_target = '11.0' s.ios.deployment_target = '12.0' s.tvos.deployment_target = '12.0' s.source = { :git => "https://github.com/mfessenden/SKTiled.git", :tag => s.version } @@ -17,6 +17,6 @@ Pod::Spec.new do |s| s.source_files = 'Sources/*.swift' s.requires_arc = true - s.swift_versions = [5, 5.2, 5.3] + s.swift_versions = [5, 5.2, 5.3, 5.4, 5.5] end diff --git a/SKTiled.xcodeproj/project.pbxproj b/SKTiled.xcodeproj/project.pbxproj index 4398ec47..c3b063ed 100644 --- a/SKTiled.xcodeproj/project.pbxproj +++ b/SKTiled.xcodeproj/project.pbxproj @@ -1074,7 +1074,6 @@ 4CA6A7FD21875FD9002BC924 /* TilemapTests.swift */, 4CA6A8032188C9A0002BC924 /* TilesetTests.swift */, 4C1D689021932E6200D2D042 /* QueryTests.swift */, - 4CA6A8072188CD93002BC924 /* Tests+Extensions.swift */, ); path = Tests; sourceTree = ""; @@ -1203,6 +1202,7 @@ 4CF1D2692555E57900A6CC25 /* Supporting Files */ = { isa = PBXGroup; children = ( + 4CA6A8072188CD93002BC924 /* Tests+Extensions.swift */, 4CF1D2372555E39300A6CC25 /* TestMapDelegate.swift */, 4CF1D2382555E39300A6CC25 /* TestTilesetDelegate.swift */, ); @@ -2426,7 +2426,6 @@ SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 12.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -2458,7 +2457,6 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 12.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -2489,7 +2487,6 @@ SDKROOT = appletvos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 12.0; }; name = Debug; }; @@ -2517,7 +2514,6 @@ PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = appletvos; TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 12.0; }; name = Release; }; @@ -2681,7 +2677,6 @@ DEBUG_INFORMATION_FORMAT = dwarf; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Tests/Info-iOS.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; @@ -2704,7 +2699,6 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Tests/Info-iOS.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_FAST_MATH = YES; PRODUCT_NAME = SKTiledTests; @@ -2731,7 +2725,6 @@ SDKROOT = appletvos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 12.0; }; name = Debug; }; @@ -2753,7 +2746,6 @@ PRODUCT_NAME = SKTiledTests; SDKROOT = appletvos; TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 12.0; }; name = Release; }; @@ -2771,7 +2763,6 @@ GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Tests/Info-macOS.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.14; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_NAME = SKTiledTests; @@ -2795,7 +2786,6 @@ GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Tests/Info-macOS.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.14; MTL_FAST_MATH = YES; PRODUCT_NAME = SKTiledTests; SDKROOT = macosx; @@ -2850,7 +2840,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 12.0; - MACOSX_DEPLOYMENT_TARGET = 10.12; + MACOSX_DEPLOYMENT_TARGET = 11.3; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = "-lz"; @@ -2904,7 +2894,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 12.0; - MACOSX_DEPLOYMENT_TARGET = 10.12; + MACOSX_DEPLOYMENT_TARGET = 11.3; MTL_ENABLE_DEBUG_INFO = NO; OTHER_LDFLAGS = "-lz"; OTHER_SWIFT_FLAGS = "-DRENDER_STATS"; diff --git a/Sources/SKTiled+Debug.swift b/Sources/SKTiled+Debug.swift index 39431ea8..34a3e9de 100644 --- a/Sources/SKTiled+Debug.swift +++ b/Sources/SKTiled+Debug.swift @@ -206,7 +206,7 @@ extension SKTiledDebugDrawNode: Loggable {} /// :nodoc: -protocol CustomDebugReflectable: class { +protocol CustomDebugReflectable: AnyObject { func dumpStatistics() } diff --git a/Sources/SKTiledObject.swift b/Sources/SKTiledObject.swift index ac756c33..4b4688bc 100644 --- a/Sources/SKTiledObject.swift +++ b/Sources/SKTiledObject.swift @@ -69,7 +69,7 @@ import SpriteKit [sktiledobject-url]:Protocols/SKTiledObject.html */ -@objc public protocol SKTiledObject: class { +@objc public protocol SKTiledObject: AnyObject { /// Unique object id (layer & object names may not be unique). var uuid: String { get set } diff --git a/Sources/SKTileset.swift b/Sources/SKTileset.swift index 7e38fdf8..97b047cd 100644 --- a/Sources/SKTileset.swift +++ b/Sources/SKTileset.swift @@ -461,28 +461,28 @@ public class SKTileset: NSObject, SKTiledObject { log("tile data exists at id: \(tileID)", level: .error) return nil } - + isImageCollection = true - let inputURL = URL(fileURLWithPath: source) - let filename = inputURL.deletingPathExtension().lastPathComponent - let fileExtension = inputURL.pathExtension - - guard let urlPath = Bundle.main.url(forResource: filename, withExtension: fileExtension) else { + // standardize the url + let inputURL = URL(fileURLWithPath: source).standardized + + // check to see if + guard let imageDataProvider = CGDataProvider(url: inputURL as CFURL) else { + log("invalid image source '\(inputURL.path)'.", level: .error) return nil } - - // read image from file - let imageDataProvider = CGDataProvider(url: urlPath as CFURL)! - + // create a data provider let image = CGImage(pngDataProviderSource: imageDataProvider, decode: nil, shouldInterpolate: false, intent: .defaultIntent)! let sourceTexture = SKTexture(cgImage: image) sourceTexture.filteringMode = .nearest - + + // create the tile data and set the source size here (as tileset size won't be accurate) let data = SKTilesetData(id: tileID, texture: sourceTexture, tileSet: self) + data.sourceSize = sourceTexture.size() data.ignoreProperties = ignoreProperties - + // add the image name to the source attribute data.source = source self.tileData.insert(data) diff --git a/Sources/SKTilesetData.swift b/Sources/SKTilesetData.swift index c1215e98..b9215226 100644 --- a/Sources/SKTilesetData.swift +++ b/Sources/SKTilesetData.swift @@ -70,6 +70,9 @@ public class SKTilesetData: SKTiledObject { /// Source image name (collections tileset) public var source: String! = nil + + /// Source image size (collections tileset) + public var sourceSize: CGSize? /// Tile occurance probability (parsed from Tiled, not currently used). diff --git a/Sources/TiledSceneCameraDelegate.swift b/Sources/TiledSceneCameraDelegate.swift index 473d54c4..7f933933 100644 --- a/Sources/TiledSceneCameraDelegate.swift +++ b/Sources/TiledSceneCameraDelegate.swift @@ -61,7 +61,7 @@ import SpriteKit [tiled-scene-camera-delegate-image]:https://mfessenden.github.io/SKTiled/images/camera-delegate.svg */ -@objc public protocol SKTiledSceneCameraDelegate: class { +@objc public protocol SKTiledSceneCameraDelegate: AnyObject { /** Allow delegate to receive updates from camera. diff --git a/Sources/TiledSceneDelegate.swift b/Sources/TiledSceneDelegate.swift index 1c002bee..cb7c78eb 100644 --- a/Sources/TiledSceneDelegate.swift +++ b/Sources/TiledSceneDelegate.swift @@ -60,7 +60,7 @@ import GameplayKit [skscene-url]:https://developer.apple.com/reference/spritekit/skscene [sktiledscenedelegate-image-url]:https://mfessenden.github.io/SKTiled/images/scene-hierarchy.svg */ -public protocol SKTiledSceneDelegate: class { +public protocol SKTiledSceneDelegate: AnyObject { /// Root container node. Tiled assets are parented to this node. var worldNode: SKNode! { get set } diff --git a/Sources/TilemapDelegate.swift b/Sources/TilemapDelegate.swift index 90b54aae..b0913965 100644 --- a/Sources/TilemapDelegate.swift +++ b/Sources/TilemapDelegate.swift @@ -69,7 +69,7 @@ import GameplayKit } ``` */ -public protocol SKTilemapDelegate: class { +public protocol SKTilemapDelegate: AnyObject { var zDeltaForLayers: CGFloat { get } func didBeginParsing(_ tilemap: SKTilemap) func didAddTileset(_ tileset: SKTileset) diff --git a/Sources/TilesetDataSource.swift b/Sources/TilesetDataSource.swift index b5cad2a1..0eb2a2e5 100644 --- a/Sources/TilesetDataSource.swift +++ b/Sources/TilesetDataSource.swift @@ -63,7 +63,7 @@ import SpriteKit } ``` */ -public protocol SKTilesetDataSource: class { +public protocol SKTilesetDataSource: AnyObject { /** Provide an image name for the tileset before textures are generated. diff --git a/Tests/ColorTests.swift b/Tests/ColorTests.swift index 23099caf..0c8da2de 100644 --- a/Tests/ColorTests.swift +++ b/Tests/ColorTests.swift @@ -164,12 +164,13 @@ class ColorTests: XCTestCase { let firstTextColorHexValue = firstTestColor.hexString() // second value (4 characters) - let secondShortHexString = "#854" - let secondExpectedHexValue = "#885544" + let secondShortHexString = "#5ba" + let secondExpectedHexValue = "#55bbaa" let secondTestColor = SKColor(hexString: secondShortHexString) let secondTextColorHexValue = secondTestColor.hexString() XCTAssertEqual(firstTextColorHexValue, firstExpectedHexValue, "❗️ incorrect hex to color conversion, `\(firstShortHexString)` does not equal `\(firstExpectedHexValue)`") + XCTAssertEqual(secondTextColorHexValue, secondExpectedHexValue, "❗️ incorrect hex to color conversion, `\(secondShortHexString)` does not equal `\(secondExpectedHexValue)`") } } diff --git a/Tests/CoordinateTests.swift b/Tests/CoordinateTests.swift index 1576426e..36a6fd3f 100644 --- a/Tests/CoordinateTests.swift +++ b/Tests/CoordinateTests.swift @@ -46,7 +46,11 @@ class CoordinateTests: XCTestCase { if (testBundle == nil) { TiledGlobals.default.loggingLevel = .none + #if SWIFT_PACKAGE testBundle = Bundle.module + #else + testBundle = Bundle(for: type(of: self)) + #endif } if (tilemap == nil) { diff --git a/Tests/ParserTests.swift b/Tests/ParserTests.swift index 08f7121e..92d8f1e4 100644 --- a/Tests/ParserTests.swift +++ b/Tests/ParserTests.swift @@ -43,12 +43,15 @@ class ParserTests: XCTestCase { super.setUp() if (testBundle == nil) { + #if SWIFT_PACKAGE testBundle = Bundle.module + #else + testBundle = Bundle(for: type(of: self)) + #endif } if (tilemap == nil) { print("➜ loading test tilemap: \"\(tilemapName)\"...") - let mapurl = testBundle!.url(forResource: tilemapName, withExtension: "tmx")! tilemap = SKTilemap.load(tmxFile: mapurl.path, delegate: tilemapDelegate, tilesetDataSource: tilesetDelegate, loggingLevel: .none) diff --git a/Tests/PropertiesTests.swift b/Tests/PropertiesTests.swift index 0beaab2a..7e8d7229 100644 --- a/Tests/PropertiesTests.swift +++ b/Tests/PropertiesTests.swift @@ -39,7 +39,11 @@ class PropertiesTests: XCTestCase { if (testBundle == nil) { TiledGlobals.default.loggingLevel = .none + #if SWIFT_PACKAGE testBundle = Bundle.module + #else + testBundle = Bundle(for: type(of: self)) + #endif } if (tilemap == nil) { diff --git a/Tests/QueryTests.swift b/Tests/QueryTests.swift index 10633a0c..62e0decd 100644 --- a/Tests/QueryTests.swift +++ b/Tests/QueryTests.swift @@ -42,7 +42,11 @@ class QueryTests: XCTestCase { if (testBundle == nil) { TiledGlobals.default.loggingLevel = .none + #if SWIFT_PACKAGE testBundle = Bundle.module + #else + testBundle = Bundle(for: type(of: self)) + #endif } if (tilemap == nil) { diff --git a/Tests/TilemapTests.swift b/Tests/TilemapTests.swift index 2800e255..87276790 100644 --- a/Tests/TilemapTests.swift +++ b/Tests/TilemapTests.swift @@ -40,7 +40,11 @@ class TilemapTests: XCTestCase { if (testBundle == nil) { TiledGlobals.default.loggingLevel = .none + #if SWIFT_PACKAGE testBundle = Bundle.module + #else + testBundle = Bundle(for: type(of: self)) + #endif } if (tilemap == nil) { diff --git a/Tests/TilesetTests.swift b/Tests/TilesetTests.swift index a2309e2a..d8d77f3b 100644 --- a/Tests/TilesetTests.swift +++ b/Tests/TilesetTests.swift @@ -43,7 +43,11 @@ class TilesetTests: XCTestCase { if (testBundle == nil) { TiledGlobals.default.loggingLevel = .none + #if SWIFT_PACKAGE testBundle = Bundle.module + #else + testBundle = Bundle(for: type(of: self)) + #endif } if (tilemap == nil) {