From 99211fb5eabb6b4e6657db3101c3f48e21f2aeee Mon Sep 17 00:00:00 2001 From: Geordie Jay Date: Mon, 5 Dec 2022 17:34:09 +0100 Subject: [PATCH 01/14] SwiftPM --- Package.swift | 27 ++++++++++++++++ SDL | 2 +- Sources/AVPlayer+Android.swift | 2 ++ Sources/AVPlayerItem+Mac.swift | 2 ++ Sources/AVPlayerLayer+Android.swift | 2 ++ Sources/AVPlayerLayer+Mac.swift | 2 ++ Sources/AVURLAsset+Android.swift | 2 ++ Sources/Button.swift | 11 ++++--- Sources/CALayer+SDL.swift | 1 + Sources/Logging.swift | 7 ++-- Sources/NotificationCenter.swift | 7 ++++ Sources/SDL+JNIExtensions.swift | 2 ++ Sources/Switch.swift | 32 +++++++++---------- Sources/UIApplication+handleSDLEvents.swift | 4 ++- Sources/UIApplicationDelegate.swift | 2 +- Sources/UIApplicationMain+Mac.swift | 2 ++ Sources/UILabel.swift | 1 + Sources/UINavigationBar.swift | 9 +++--- Sources/UINavigationController.swift | 3 +- .../UINavigationControllerContainerView.swift | 1 + Sources/UIScreen.swift | 8 ++--- Sources/UIScrollView.swift | 4 ++- Sources/UITapGestureRecognizer.swift | 3 +- Sources/UIWindow+getSafeAreaInsets.swift | 3 +- Sources/androidNativeInit.swift | 2 ++ UIKitTests/TestSetup.swift | 5 ++- .../getting-started/DemoApp/AppDelegate.swift | 2 -- samples/getting-started/Package.swift | 27 ++++++++++++++++ .../getting-started/android/app/build.gradle | 14 +++----- .../src/main/java/com/example/MainActivity.kt | 2 +- src/main/java/org/libsdl/app/SDLActivity.kt | 2 +- swift-android-toolchain | 2 +- 32 files changed, 139 insertions(+), 56 deletions(-) create mode 100644 Package.swift create mode 100644 samples/getting-started/Package.swift diff --git a/Package.swift b/Package.swift new file mode 100644 index 00000000..5d3a606e --- /dev/null +++ b/Package.swift @@ -0,0 +1,27 @@ +// swift-tools-version:5.7 +import PackageDescription + +let package = Package( + name: "UIKit", + platforms: [.macOS(.v10_15)], + products: [ + .library(name: "UIKit", type: .dynamic, targets: ["UIKit"]) + ], + dependencies: [ + .package(path: "./swift-jni"), + .package(path: "./SDL"), + ], + targets: [ + .target( + name: "UIKit", + dependencies: [ + .product(name: "SDL_Android", package: "SDL", condition: .when(platforms: [.android])), + .product(name: "JNI", package: "swift-jni", condition: .when(platforms: [.android])), + ], + path: "Sources", + exclude: [ + "Mac-Info.plist", + ] + ) + ] +) diff --git a/SDL b/SDL index ab962c68..97a1aca7 160000 --- a/SDL +++ b/SDL @@ -1 +1 @@ -Subproject commit ab962c68b37cae017de42043bf983e3564480718 +Subproject commit 97a1aca7e7bc48733efbc15b49e0782f3ee9f7c6 diff --git a/Sources/AVPlayer+Android.swift b/Sources/AVPlayer+Android.swift index 050d0909..ebaa650e 100644 --- a/Sources/AVPlayer+Android.swift +++ b/Sources/AVPlayer+Android.swift @@ -1,3 +1,4 @@ +#if os(Android) // // JNIVideo.swift // UIKit @@ -82,3 +83,4 @@ public func nativeOnVideoSourceError(env: UnsafeMutablePointer, cls: Jav globalAVPlayer?.onLoaded?(AVPlayer.DataSourceError()) globalAVPlayer?.onLoaded = nil } +#endif diff --git a/Sources/AVPlayerItem+Mac.swift b/Sources/AVPlayerItem+Mac.swift index e651cc15..cc8bc63d 100644 --- a/Sources/AVPlayerItem+Mac.swift +++ b/Sources/AVPlayerItem+Mac.swift @@ -1,3 +1,4 @@ +#if os(macOS) // // AVPlayerItem+Mac.swift // UIKit @@ -17,3 +18,4 @@ extension AVPlayerItem { return duration.seconds * 1000 } } +#endif diff --git a/Sources/AVPlayerLayer+Android.swift b/Sources/AVPlayerLayer+Android.swift index 6a3d632f..0d01c5f9 100644 --- a/Sources/AVPlayerLayer+Android.swift +++ b/Sources/AVPlayerLayer+Android.swift @@ -1,3 +1,4 @@ +#if os(Android) // // JNIVideo.swift // UIKit @@ -51,3 +52,4 @@ public class AVPlayerLayer: JNIObject { } } } +#endif diff --git a/Sources/AVPlayerLayer+Mac.swift b/Sources/AVPlayerLayer+Mac.swift index 4d2032b5..8878d872 100644 --- a/Sources/AVPlayerLayer+Mac.swift +++ b/Sources/AVPlayerLayer+Mac.swift @@ -1,3 +1,4 @@ +#if os(macOS) // // AVPlayerLayer+Mac.swift // UIKit @@ -123,3 +124,4 @@ public final class AVPlayerLayer: CALayer { contents?.replacePixels(with: pixelBytes, bytesPerPixel: 4) } } +#endif diff --git a/Sources/AVURLAsset+Android.swift b/Sources/AVURLAsset+Android.swift index e399f6c8..20771623 100644 --- a/Sources/AVURLAsset+Android.swift +++ b/Sources/AVURLAsset+Android.swift @@ -1,3 +1,4 @@ +#if os(Android) // // AVPlayerItem+Android.swift // UIKit @@ -26,3 +27,4 @@ public class AVURLAsset: JNIObject { self.url = url } } +#endif diff --git a/Sources/Button.swift b/Sources/Button.swift index 11559bde..3aa45b51 100644 --- a/Sources/Button.swift +++ b/Sources/Button.swift @@ -11,6 +11,7 @@ fileprivate let labelVerticalPadding: CGFloat = 6 +@MainActor open class Button: UIControl { internal (set) public var imageView: UIImageView? { didSet { @@ -18,7 +19,7 @@ open class Button: UIControl { if let imageView = imageView { addSubview(imageView) } } } - + internal (set) public var titleLabel: UILabel? { didSet { oldValue?.removeFromSuperview() @@ -75,22 +76,24 @@ open class Button: UIControl { } } - public let tapGestureRecognizer = UITapGestureRecognizer() + public let tapGestureRecognizer: UITapGestureRecognizer public var onPress: (@MainActor () -> Void)? { get { return tapGestureRecognizer.onPress } set { tapGestureRecognizer.onPress = newValue } } + @MainActor public override init(frame: CGRect) { + tapGestureRecognizer = UITapGestureRecognizer(onPress: nil) super.init(frame: frame) - let titleLabel = UILabel() + let titleLabel = UILabel(frame: .zero) titleLabel.isHidden = true addSubview(titleLabel) setTitleColor(.white, for: .normal) self.titleLabel = titleLabel - let imageView = UIImageView() + let imageView = UIImageView(frame: .zero) imageView.isHidden = true imageView.contentMode = .scaleAspectFit addSubview(imageView) diff --git a/Sources/CALayer+SDL.swift b/Sources/CALayer+SDL.swift index 8168102e..3eb885a4 100644 --- a/Sources/CALayer+SDL.swift +++ b/Sources/CALayer+SDL.swift @@ -9,6 +9,7 @@ import SDL_gpu extension CALayer { + @MainActor final func sdlRender(parentAbsoluteOpacity: Float = 1) { guard let renderer = UIScreen.main else { return } let opacity = self.opacity * parentAbsoluteOpacity diff --git a/Sources/Logging.swift b/Sources/Logging.swift index d644c070..9d98eea8 100644 --- a/Sources/Logging.swift +++ b/Sources/Logging.swift @@ -1,3 +1,4 @@ +#if os(Android) // // Logging.swift // UIKit @@ -7,12 +8,7 @@ // import SDL - -#if os(Android) import Glibc -#else -import Darwin.C.stdio -#endif private let loggingTag = "Swift" @@ -48,3 +44,4 @@ public func fatalError(_ message: @autoclosure () -> String = "", file: StaticSt public enum LogPriority: Int32 { case `unknown`,`default`,`verbose`,`debug`,`info`,`warn`,`error`,`fatal`,`silent` } +#endif diff --git a/Sources/NotificationCenter.swift b/Sources/NotificationCenter.swift index cbd0bed7..bd4f0b21 100644 --- a/Sources/NotificationCenter.swift +++ b/Sources/NotificationCenter.swift @@ -1,4 +1,11 @@ +#if os(Android) import JNI +#elseif canImport(Darwin) +import class Foundation.Thread +private var isMainThread: Bool { + return Thread.isMainThread +} +#endif public class NotificationCenter { public internal(set) static var `default` = NotificationCenter() diff --git a/Sources/SDL+JNIExtensions.swift b/Sources/SDL+JNIExtensions.swift index e4b5beda..1374b780 100644 --- a/Sources/SDL+JNIExtensions.swift +++ b/Sources/SDL+JNIExtensions.swift @@ -1,3 +1,4 @@ +#if os(Android) // // SDL+JNIExtensions.swift // UIKit @@ -50,3 +51,4 @@ struct JavaSDLView: JavaParameterConvertible { return self.init(javaStringObject) } } +#endif diff --git a/Sources/Switch.swift b/Sources/Switch.swift index d6aab0fb..938a9b0e 100644 --- a/Sources/Switch.swift +++ b/Sources/Switch.swift @@ -2,7 +2,7 @@ // This allows us to have a somewhat custom API free of objc selectors etc. open class Switch: UIControl { - private let tapGestureRecognizer = UITapGestureRecognizer() + private let tapGestureRecognizer: UITapGestureRecognizer private var thumb = SwitchThumb() @@ -20,6 +20,8 @@ open class Switch: UIControl { } public init() { + tapGestureRecognizer = UITapGestureRecognizer(onPress: nil) + super.init( frame: CGRect(origin: CGPoint(x: 0, y: 0), size: frameSize) ) @@ -52,11 +54,11 @@ open class Switch: UIControl { } - +@MainActor private final class SwitchThumb: UIView { let thumb = UIView(frame: .zero) let shadow = UIView(frame: .zero) - + override var backgroundColor: UIColor? { get { thumb.backgroundColor } set { thumb.backgroundColor = newValue } @@ -65,32 +67,30 @@ private final class SwitchThumb: UIView { init() { thumb.frame.size = CGSize(width: thumbSize, height: thumbSize) thumb.layer.cornerRadius = thumbSize / 2 - + let shadowSize = thumbSize + 2 shadow.frame.size = CGSize(width: shadowSize, height: shadowSize) shadow.frame.midX = thumb.frame.midX shadow.frame.midY = thumb.frame.midY + 2 shadow.layer.cornerRadius = shadowSize / 2 shadow.backgroundColor = .lightGray.withAlphaComponent(0.4) - + super.init(frame: .zero) - + frame.size = CGSize(width: thumbSize, height: thumbSize) layer.cornerRadius = thumbSize / 2 - + self.addSubview(shadow) self.addSubview(thumb) } - } -private let frameSize = CGSize(width: 51, height: 21) -private let thumbSize = CGFloat(31.0) -private let animationTime = 0.25 - -private let defaultOnTintColor = CGColor(red: 169 / 255, green: 218 / 255 , blue: 214 / 255, alpha: 1) -private let defaultThumbColor = CGColor(red: 14 / 255, green: 136 / 255 , blue: 122 / 255, alpha: 1) +@MainActor private let frameSize = CGSize(width: 51, height: 21) +@MainActor private let thumbSize = CGFloat(31.0) +@MainActor private let animationTime = 0.25 -private let offThumbColor = CGColor(red: 176 / 255, green: 176 / 255 , blue: 176 / 255, alpha: 1) -private let offTrackColor = CGColor(red: 225 / 255, green: 225 / 255 , blue: 225 / 255, alpha: 1) +@MainActor private let defaultOnTintColor = CGColor(red: 169 / 255, green: 218 / 255 , blue: 214 / 255, alpha: 1) +@MainActor private let defaultThumbColor = CGColor(red: 14 / 255, green: 136 / 255 , blue: 122 / 255, alpha: 1) +@MainActor private let offThumbColor = CGColor(red: 176 / 255, green: 176 / 255 , blue: 176 / 255, alpha: 1) +@MainActor private let offTrackColor = CGColor(red: 225 / 255, green: 225 / 255 , blue: 225 / 255, alpha: 1) diff --git a/Sources/UIApplication+handleSDLEvents.swift b/Sources/UIApplication+handleSDLEvents.swift index ba17b4e2..45129e3e 100644 --- a/Sources/UIApplication+handleSDLEvents.swift +++ b/Sources/UIApplication+handleSDLEvents.swift @@ -5,9 +5,11 @@ // Created by Geordie Jay on 20.03.18. // Copyright © 2018 flowkey. All rights reserved. // +#if os(Android) +import JNI +#endif import SDL -import JNI extension UIApplication { @MainActor diff --git a/Sources/UIApplicationDelegate.swift b/Sources/UIApplicationDelegate.swift index 8ad808bb..462ebf1e 100644 --- a/Sources/UIApplicationDelegate.swift +++ b/Sources/UIApplicationDelegate.swift @@ -41,6 +41,6 @@ public extension UIApplicationDelegate { // That said, this function won't even be called on platforms like Android where the app is built as a library, not an executable. #endif - UIApplicationMain(UIApplication.self, Self.self) + _ = UIApplicationMain(UIApplication.self, Self.self) } } diff --git a/Sources/UIApplicationMain+Mac.swift b/Sources/UIApplicationMain+Mac.swift index 24ef06ec..b838b814 100644 --- a/Sources/UIApplicationMain+Mac.swift +++ b/Sources/UIApplicationMain+Mac.swift @@ -1,3 +1,4 @@ +#if os(macOS) // // UIApplication+Mac.swift // UIKit @@ -42,3 +43,4 @@ func setupRenderAndRunLoop() { RunLoop.current.run() } +#endif diff --git a/Sources/UILabel.swift b/Sources/UILabel.swift index e9b698b0..f97bfd78 100644 --- a/Sources/UILabel.swift +++ b/Sources/UILabel.swift @@ -20,6 +20,7 @@ public enum NSTextAlignment: Int { } } +@MainActor open class UILabel: UIView { open var numberOfLines: Int = 1 { didSet { if numberOfLines != oldValue { setNeedsDisplay() } } diff --git a/Sources/UINavigationBar.swift b/Sources/UINavigationBar.swift index f6fae8d6..4ea2241f 100644 --- a/Sources/UINavigationBar.swift +++ b/Sources/UINavigationBar.swift @@ -1,3 +1,4 @@ +@MainActor open class UINavigationBar: UIView { internal var barHeight: CGFloat { return 40 } internal var horizontalMargin: CGFloat { return 20 } @@ -42,7 +43,7 @@ open class UINavigationBar: UIView { backgroundColor = UIColor(red: 0.91, green: 0.91, blue: 0.91, alpha: 1) backButton.onPress = { [weak self] in - self?.popItem(animated: true) + _ = self?.popItem(animated: true) } rightButton.onPress = { [weak self] in @@ -73,9 +74,9 @@ open class UINavigationBar: UIView { rightButton.center.y = bounds.midY } - internal var titleLabel = UILabel() - internal var backButton = Button() - internal var rightButton = Button() + internal var titleLabel = UILabel(frame: .zero) + internal var backButton = Button(frame: .zero) + internal var rightButton = Button(frame: .zero) open func pushItem(_ item: UINavigationItem, animated: Bool) { items = items ?? [] diff --git a/Sources/UINavigationController.swift b/Sources/UINavigationController.swift index 41d17aac..078a9443 100644 --- a/Sources/UINavigationController.swift +++ b/Sources/UINavigationController.swift @@ -1,3 +1,4 @@ +@MainActor open class UINavigationController: UIViewController { /// Note: not currently implemented! open var modalPresentationStyle: UIModalPresentationStyle = .formSheet @@ -9,7 +10,7 @@ open class UINavigationController: UIViewController { } open override func loadView() { - view = UINavigationControllerContainerView() + view = UINavigationControllerContainerView(frame: .zero) view.addSubview(transitionView) view.addSubview(navigationBar) } diff --git a/Sources/UINavigationControllerContainerView.swift b/Sources/UINavigationControllerContainerView.swift index 7ce185a9..9fbaa9fa 100644 --- a/Sources/UINavigationControllerContainerView.swift +++ b/Sources/UINavigationControllerContainerView.swift @@ -6,4 +6,5 @@ // Copyright © 2018 flowkey. All rights reserved. // +@MainActor internal class UINavigationControllerContainerView: UIView {} diff --git a/Sources/UIScreen.swift b/Sources/UIScreen.swift index 0457ccb0..5045f341 100644 --- a/Sources/UIScreen.swift +++ b/Sources/UIScreen.swift @@ -179,13 +179,10 @@ fileprivate func getAndroidDeviceScale() -> CGFloat { } #endif - +@MainActor extension UIScreen { /// Used in tests only and doesn't actually render anything - static func dummyScreen( - bounds: CGRect = CGRect(origin: .zero, size: .samsungGalaxyS7), - scale: CGFloat - ) -> UIScreen { + static func dummyScreen(bounds: CGRect, scale: CGFloat) -> UIScreen { return UIScreen( renderTarget: nil, bounds: bounds, @@ -194,6 +191,7 @@ extension UIScreen { } } +@MainActor private extension CGSize { // smartphones: static let samsungGalaxyJ5 = CGSize(width: 1280 / 2.0, height: 720 / 2.0) diff --git a/Sources/UIScrollView.swift b/Sources/UIScrollView.swift index 96400c20..245bab2c 100644 --- a/Sources/UIScrollView.swift +++ b/Sources/UIScrollView.swift @@ -11,9 +11,10 @@ let UIScrollViewDecelerationRateNormal: CGFloat = 0.998 let UIScrollViewDecelerationRateFast: CGFloat = 0.99 +@MainActor open class UIScrollView: UIView { open weak var delegate: UIScrollViewDelegate? // TODO: change this to individually settable callbacks - open var panGestureRecognizer = UIPanGestureRecognizer() + open var panGestureRecognizer: UIPanGestureRecognizer var verticalScrollIndicator = UIView() var horizontalScrollIndicator = UIView() @@ -73,6 +74,7 @@ open class UIScrollView: UIView { var weightedAverageVelocity: CGPoint = .zero override public init(frame: CGRect) { + panGestureRecognizer = UIPanGestureRecognizer() super.init(frame: frame) panGestureRecognizer.onAction = { [weak self] in self?.onPan() } panGestureRecognizer.onStateChanged = { [weak self] in self?.onPanGestureStateChanged() } diff --git a/Sources/UITapGestureRecognizer.swift b/Sources/UITapGestureRecognizer.swift index 8763e98a..c46ffdc6 100644 --- a/Sources/UITapGestureRecognizer.swift +++ b/Sources/UITapGestureRecognizer.swift @@ -6,12 +6,13 @@ // Copyright © 2017 flowkey. All rights reserved. // +@MainActor open class UITapGestureRecognizer: UIGestureRecognizer { var onTouchesBegan: (() -> Void)? var onTouchesEnded: (() -> Void)? var onPress: (@MainActor () -> Void)? - public init(onPress: (() -> Void)? = nil) { + public init(onPress: (@MainActor () -> Void)? = nil) { self.onPress = onPress } diff --git a/Sources/UIWindow+getSafeAreaInsets.swift b/Sources/UIWindow+getSafeAreaInsets.swift index 45c77beb..8be6bea1 100644 --- a/Sources/UIWindow+getSafeAreaInsets.swift +++ b/Sources/UIWindow+getSafeAreaInsets.swift @@ -1,5 +1,6 @@ - +#if os(Android) import JNI +#endif extension UIWindow { static func getSafeAreaInsets() -> UIEdgeInsets { diff --git a/Sources/androidNativeInit.swift b/Sources/androidNativeInit.swift index bd4e5af7..1f1fbd5a 100644 --- a/Sources/androidNativeInit.swift +++ b/Sources/androidNativeInit.swift @@ -1,3 +1,4 @@ +#if os(Android) // // androidNativeInit.swift // UIKit @@ -43,3 +44,4 @@ public func nativeDestroyScreen(env: UnsafeMutablePointer, view: JavaObj UIApplication.onWillEnterBackground() UIApplication.onDidEnterBackground() } +#endif diff --git a/UIKitTests/TestSetup.swift b/UIKitTests/TestSetup.swift index d1fdb506..04eae13b 100644 --- a/UIKitTests/TestSetup.swift +++ b/UIKitTests/TestSetup.swift @@ -32,7 +32,10 @@ import Foundation #if os(iOS) FontLoader.loadBundledFonts() #else - UIScreen.main = UIScreen.dummyScreen(scale: 2) + UIScreen.main = UIScreen.dummyScreen( + bounds: CGRect(origin: .zero, size: .samsungGalaxyS7), + scale: 2 + ) UIFont.loadSystemFonts() #endif } diff --git a/samples/getting-started/DemoApp/AppDelegate.swift b/samples/getting-started/DemoApp/AppDelegate.swift index 0d13809a..0a5f7864 100644 --- a/samples/getting-started/DemoApp/AppDelegate.swift +++ b/samples/getting-started/DemoApp/AppDelegate.swift @@ -9,7 +9,6 @@ import UIKit final class AppDelegate: UIResponder, UIApplicationDelegate { - var window: UIWindow? func application( @@ -17,7 +16,6 @@ final class AppDelegate: UIResponder, UIApplicationDelegate { didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { - window = UIWindow() window?.rootViewController = UINavigationController(rootViewController: ViewController()) window?.makeKeyAndVisible() diff --git a/samples/getting-started/Package.swift b/samples/getting-started/Package.swift new file mode 100644 index 00000000..2f669084 --- /dev/null +++ b/samples/getting-started/Package.swift @@ -0,0 +1,27 @@ +// swift-tools-version:5.7 +import PackageDescription + +let package = Package( + name: "GettingStarted", + platforms: [.macOS(.v10_15)], + products: [ + .library(name: "GettingStarted", type: .dynamic, targets: ["GettingStarted"]), + ], + dependencies: [ + .package(path: "../.."), + ], + targets: [ + .target( + name: "GettingStarted", + dependencies: [ + .product(name: "UIKit", package: "UIKit"), + ], + path: "DemoApp", + exclude: [ + "Info.plist", + "Base.lproj", + "main.swift" + ] + ) + ] +) diff --git a/samples/getting-started/android/app/build.gradle b/samples/getting-started/android/app/build.gradle index 3925ce5d..630ac0a7 100644 --- a/samples/getting-started/android/app/build.gradle +++ b/samples/getting-started/android/app/build.gradle @@ -11,6 +11,7 @@ android { versionCode 1 versionName "1.0" } + packagingOptions.jniLibs.keepDebugSymbols += "**/libdispatch.so" buildTypes { release { minifyEnabled false @@ -34,23 +35,18 @@ task buildSwiftArm64(type: Exec) { commandLine 'sh', '-c', getSwiftBuildCommand('arm64-v8a') } -task buildSwiftIntel64(type: Exec) { - commandLine 'sh', '-c', getSwiftBuildCommand('x86_64') -} - task cleanSwift(type: Exec) { - commandLine 'sh', '-c', "rm -rf ../../build" + commandLine 'sh', '-c', "rm -rf ../../.build" } preBuild.dependsOn buildSwiftArm64 -preBuild.dependsOn buildSwiftIntel64 clean.dependsOn cleanSwift def getSwiftBuildCommand(abi) { - def cmakeBuildType = "RelWithDebInfo" - def buildScript = "../../../../swift-android-toolchain/swift-build.sh" - return "CMAKE_BUILD_TYPE=$cmakeBuildType ANDROID_ABI=$abi LIBRARY_OUTPUT_DIRECTORY='${projectDir}/src/main/jniLibs/${abi}' $buildScript ../../" + def BUILD_TYPE = "release" + def buildScript = "../../../../swift-android-toolchain/swiftpm.sh" + return "ANDROID_ABI=$abi LIBRARY_OUTPUT_DIRECTORY='${projectDir}/src/main/jniLibs/${abi}' $buildScript -c $BUILD_TYPE --package-path ../.." } dependencies { diff --git a/samples/getting-started/android/app/src/main/java/com/example/MainActivity.kt b/samples/getting-started/android/app/src/main/java/com/example/MainActivity.kt index 4c77c230..86e07abe 100644 --- a/samples/getting-started/android/app/src/main/java/com/example/MainActivity.kt +++ b/samples/getting-started/android/app/src/main/java/com/example/MainActivity.kt @@ -6,7 +6,7 @@ import com.flowkey.uikit.UIKitActivity class MainActivity: UIKitActivity() { companion object { init { - System.loadLibrary("DemoApp") + System.loadLibrary("GettingStarted") } } } diff --git a/src/main/java/org/libsdl/app/SDLActivity.kt b/src/main/java/org/libsdl/app/SDLActivity.kt index db94b066..734d51de 100644 --- a/src/main/java/org/libsdl/app/SDLActivity.kt +++ b/src/main/java/org/libsdl/app/SDLActivity.kt @@ -38,7 +38,7 @@ open class SDLActivity internal constructor (context: Context?) : RelativeLayout internal var mSeparateMouseAndTouch = false init { - arrayOf("JNI", "SDL", "UIKit").forEach { System.loadLibrary(it) } + arrayOf("JNI", "UIKit").forEach { System.loadLibrary(it) } } } diff --git a/swift-android-toolchain b/swift-android-toolchain index d7dc2d0c..b6bdc735 160000 --- a/swift-android-toolchain +++ b/swift-android-toolchain @@ -1 +1 @@ -Subproject commit d7dc2d0cfba9bc48dc46001d6ec3132c098d9fea +Subproject commit b6bdc7358f7c4d1ea5fbeeafc2e572eaf9ba2696 From c4a499dd4b5d189a366b7c50aa4283b7ebacd54c Mon Sep 17 00:00:00 2001 From: Geordie Jay Date: Tue, 6 Dec 2022 04:58:18 +1000 Subject: [PATCH 02/14] Use `@_implementationOnly` to avoid leaking SDL implementation details publicly --- Sources/CALayer+SDL.swift | 2 +- Sources/CALayer.swift | 2 +- Sources/CATransform3D+SDL_gpu.swift | 2 +- Sources/CATransform3D+animations.swift | 2 +- Sources/CGDataProvider.swift | 2 +- Sources/CGImage.swift | 4 +-- .../Data+fromRelativePathCrossPlatform.swift | 4 ++- .../FontRenderer+renderAttributedString.swift | 2 +- Sources/FontRenderer+singleLineSize.swift | 2 +- Sources/FontRenderer.swift | 2 +- Sources/Logging.swift | 2 +- Sources/Math.swift | 25 +++++++++++++ Sources/MeteringView.swift | 2 +- Sources/SDL2-Shims.swift | 27 ++------------ Sources/Shader.swift | 2 +- Sources/ShaderProgram+mask.swift | 2 +- Sources/ShaderProgram.swift | 2 +- Sources/UIApplication+handleSDLEvents.swift | 6 ++-- Sources/UIApplication.swift | 6 ++-- Sources/UIApplicationMain.swift | 2 +- Sources/UIColor.swift | 2 +- Sources/UIImage.swift | 4 +-- Sources/UIScreen+Errors.swift | 36 ++++++++----------- Sources/UIScreen+render.swift | 4 +-- Sources/UIScreen.swift | 17 ++++----- Sources/UIScrollView+velocity.swift | 2 +- Sources/UIView+SDL.swift | 2 +- Sources/UIView.swift | 2 +- Sources/UIWindow+TouchHandling.swift | 2 ++ Sources/VideoTexture+Mac.swift | 2 +- Sources/androidNativeInit.swift | 2 +- 31 files changed, 88 insertions(+), 87 deletions(-) create mode 100644 Sources/Math.swift diff --git a/Sources/CALayer+SDL.swift b/Sources/CALayer+SDL.swift index 3eb885a4..62f02e09 100644 --- a/Sources/CALayer+SDL.swift +++ b/Sources/CALayer+SDL.swift @@ -6,7 +6,7 @@ // Copyright © 2017 flowkey. All rights reserved. // -import SDL_gpu +@_implementationOnly import SDL_gpu extension CALayer { @MainActor diff --git a/Sources/CALayer.swift b/Sources/CALayer.swift index e74f7252..ce97fcb8 100644 --- a/Sources/CALayer.swift +++ b/Sources/CALayer.swift @@ -1,4 +1,4 @@ -import SDL +@_implementationOnly import SDL @MainActor open class CALayer { diff --git a/Sources/CATransform3D+SDL_gpu.swift b/Sources/CATransform3D+SDL_gpu.swift index c0419725..18a77c14 100644 --- a/Sources/CATransform3D+SDL_gpu.swift +++ b/Sources/CATransform3D+SDL_gpu.swift @@ -6,7 +6,7 @@ // Copyright © 2018 flowkey. All rights reserved. // -import SDL_gpu +@_implementationOnly import SDL_gpu extension CATransform3D { /// Set the current transformation as SDL_GPU's current transform matrix diff --git a/Sources/CATransform3D+animations.swift b/Sources/CATransform3D+animations.swift index 942299c4..019bcf6f 100644 --- a/Sources/CATransform3D+animations.swift +++ b/Sources/CATransform3D+animations.swift @@ -5,7 +5,7 @@ // Created by Michael Knoch on 19.01.18. // -import SDL_gpu +@_implementationOnly import SDL_gpu // It doesn't make sense to make these public, they're only to simplify our animation code: internal extension CATransform3D { diff --git a/Sources/CGDataProvider.swift b/Sources/CGDataProvider.swift index c00aae7d..0576ccb5 100644 --- a/Sources/CGDataProvider.swift +++ b/Sources/CGDataProvider.swift @@ -6,7 +6,7 @@ // Copyright © 2017 flowkey. All rights reserved. // -import SDL +@_implementationOnly import SDL public class CGDataProvider { public var data: [CChar] diff --git a/Sources/CGImage.swift b/Sources/CGImage.swift index d921dfa3..692a420e 100644 --- a/Sources/CGImage.swift +++ b/Sources/CGImage.swift @@ -1,5 +1,5 @@ -import SDL -import SDL_gpu +@_implementationOnly import SDL +@_implementationOnly import SDL_gpu public class CGImage { /// Be careful using this pointer e.g. for another CGImage instance. diff --git a/Sources/Data+fromRelativePathCrossPlatform.swift b/Sources/Data+fromRelativePathCrossPlatform.swift index 1963a3bb..310dcfa5 100644 --- a/Sources/Data+fromRelativePathCrossPlatform.swift +++ b/Sources/Data+fromRelativePathCrossPlatform.swift @@ -6,8 +6,10 @@ // Copyright © 2018 flowkey. All rights reserved. // +@_implementationOnly import SDL + extension Data { - public static func _fromPathCrossPlatform(_ path: String) -> Data? { + static func _fromPathCrossPlatform(_ path: String) -> Data? { guard let fileReader = SDL_RWFromFile(path, "r") else { return nil } diff --git a/Sources/FontRenderer+renderAttributedString.swift b/Sources/FontRenderer+renderAttributedString.swift index c6a55fde..0d12c76b 100644 --- a/Sources/FontRenderer+renderAttributedString.swift +++ b/Sources/FontRenderer+renderAttributedString.swift @@ -6,7 +6,7 @@ // Copyright © 2018 flowkey. All rights reserved. // -import SDL_ttf +@_implementationOnly import SDL_ttf extension FontRenderer { func getFontKerningOffset(between previousIndex: FT_UInt?, and currentIndex: FT_UInt) -> Int32 { diff --git a/Sources/FontRenderer+singleLineSize.swift b/Sources/FontRenderer+singleLineSize.swift index 5ef2cb1a..2b0d3dc5 100644 --- a/Sources/FontRenderer+singleLineSize.swift +++ b/Sources/FontRenderer+singleLineSize.swift @@ -6,7 +6,7 @@ // Copyright © 2018 flowkey. All rights reserved. // -import SDL_ttf +@_implementationOnly import SDL_ttf extension FontRenderer { // From `TTF_HANDLE_STYLE_BOLD` diff --git a/Sources/FontRenderer.swift b/Sources/FontRenderer.swift index a6b66b7a..3230087e 100644 --- a/Sources/FontRenderer.swift +++ b/Sources/FontRenderer.swift @@ -6,7 +6,7 @@ // Copyright © 2017 flowkey. All rights reserved. // -import SDL_ttf +@_implementationOnly import SDL_ttf extension FontRenderer { diff --git a/Sources/Logging.swift b/Sources/Logging.swift index 9d98eea8..06a34c82 100644 --- a/Sources/Logging.swift +++ b/Sources/Logging.swift @@ -7,7 +7,7 @@ // Copyright © 2017 flowkey. All rights reserved. // -import SDL +@_implementationOnly import SDL import Glibc private let loggingTag = "Swift" diff --git a/Sources/Math.swift b/Sources/Math.swift new file mode 100644 index 00000000..9e40ef38 --- /dev/null +++ b/Sources/Math.swift @@ -0,0 +1,25 @@ +#if os(WASI) +@_exported import func WASILibc.pow +@_exported import func WASILibc.log10 +@_exported import func WASILibc.log2 +@_exported import func WASILibc.sin +@_exported import func WASILibc.cos +#elseif canImport(Glibc) +@_exported import func Glibc.pow +@_exported import func Glibc.log10 +@_exported import func Glibc.log2 +@_exported import func Glibc.sin +@_exported import func Glibc.cos +@_exported import var Glibc.CLOCK_REALTIME +@_exported import func Glibc.clock_gettime +@_exported import struct Glibc.timespec +@_exported import struct Glibc.clockid_t +#elseif canImport(Darwin) +@_exported import func Foundation.pow +@_exported import func Foundation.log10 +@_exported import func Foundation.log2 +@_exported import func Foundation.sin +@_exported import func Foundation.cos +@_exported import func Foundation.clock_gettime +@_exported import struct Foundation.timespec +#endif diff --git a/Sources/MeteringView.swift b/Sources/MeteringView.swift index 3934c4f6..2371045b 100644 --- a/Sources/MeteringView.swift +++ b/Sources/MeteringView.swift @@ -35,7 +35,7 @@ class MeteringView: UILabel { private func updateDisplay(to value: Double) { guard value.isFinite else { return } - let value = Int(round(value)) + let value = Int(value.rounded()) self.text = metric + ": \(value)" self.sizeToFit() } diff --git a/Sources/SDL2-Shims.swift b/Sources/SDL2-Shims.swift index fb195622..6c1f6284 100644 --- a/Sources/SDL2-Shims.swift +++ b/Sources/SDL2-Shims.swift @@ -6,7 +6,7 @@ // Copyright © 2017 Geordie Jay. All rights reserved. // -import SDL +@_implementationOnly import SDL struct SDLError: Error { let description: String @@ -27,30 +27,7 @@ extension SDLDisplayMode { } } -extension SDLBool: ExpressibleByBooleanLiteral { +extension SDLBool { static let `true` = __SDL_TRUE static let `false` = __SDL_FALSE - - public init(booleanLiteral value: Bool) { - self = (value ? .true : .false) - } -} - -extension SDLRect: Equatable { - public func intersects(_ other: SDLRect) -> Bool { - var other = other - return self.intersects(&other) == .true - } - - public func intersection(with other: SDLRect) -> SDLRect { - var other = other - var result = SDLRect() - self.intersection(with: &other, result: &result) - return result - } - - public static func == (lhs: SDLRect, rhs: SDLRect) -> Bool { - var rhs = rhs - return lhs.equals(&rhs) == .true - } } diff --git a/Sources/Shader.swift b/Sources/Shader.swift index 73fc3c39..f3168bb9 100644 --- a/Sources/Shader.swift +++ b/Sources/Shader.swift @@ -6,7 +6,7 @@ // Copyright © 2017 flowkey. All rights reserved. // -import SDL_gpu +@_implementationOnly import SDL_gpu class VertexShader: Shader { // Some keywords have changed since the earlier shader language versions available on Android: diff --git a/Sources/ShaderProgram+mask.swift b/Sources/ShaderProgram+mask.swift index df3b14d9..aa4eb912 100644 --- a/Sources/ShaderProgram+mask.swift +++ b/Sources/ShaderProgram+mask.swift @@ -6,7 +6,7 @@ // Copyright © 2017 flowkey. All rights reserved. // -import SDL_gpu +@_implementationOnly import SDL_gpu extension ShaderProgram { static let mask = try! MaskShaderProgram() diff --git a/Sources/ShaderProgram.swift b/Sources/ShaderProgram.swift index c722e43b..b062990d 100644 --- a/Sources/ShaderProgram.swift +++ b/Sources/ShaderProgram.swift @@ -6,7 +6,7 @@ // Copyright © 2017 flowkey. All rights reserved. // -import SDL_gpu +@_implementationOnly import SDL_gpu // A ShaderProgram consists of a VertexShader and a FragmentShader linked together // This is a class because Shaders need to be freed after use diff --git a/Sources/UIApplication+handleSDLEvents.swift b/Sources/UIApplication+handleSDLEvents.swift index 45129e3e..2451ec74 100644 --- a/Sources/UIApplication+handleSDLEvents.swift +++ b/Sources/UIApplication+handleSDLEvents.swift @@ -9,7 +9,7 @@ import JNI #endif -import SDL +@_implementationOnly import SDL extension UIApplication { @MainActor @@ -150,7 +150,7 @@ extension SDL_Scancode { static let androidHardwareBackButton = SDL_Scancode(rawValue: 270) } -extension SDL_Keymod: OptionSet {} +// extension SDL_Keymod: OptionSet {} extension SDL_Event { var timestampInSeconds: Double { @@ -277,7 +277,7 @@ public func onNativeTouch( } extension SDL_EventType { - public static func eventFrom(androidAction: JavaInt) -> SDL_EventType? { + static func eventFrom(androidAction: JavaInt) -> SDL_EventType? { switch androidAction { case 0, 5: return SDL_FINGERDOWN case 1, 6: return SDL_FINGERUP diff --git a/Sources/UIApplication.swift b/Sources/UIApplication.swift index 33e9d10e..0ffa5bd4 100644 --- a/Sources/UIApplication.swift +++ b/Sources/UIApplication.swift @@ -1,4 +1,4 @@ -import SDL +@_implementationOnly import SDL @MainActor open class UIApplication { @@ -56,8 +56,8 @@ open class UIApplication { } -import SDL -import SDL_gpu +@_implementationOnly import SDL +@_implementationOnly import SDL_gpu extension UIApplication { func handleSDLQuit() { diff --git a/Sources/UIApplicationMain.swift b/Sources/UIApplicationMain.swift index 568105b8..d89bf1e4 100644 --- a/Sources/UIApplicationMain.swift +++ b/Sources/UIApplicationMain.swift @@ -1,4 +1,4 @@ -import SDL +@_implementationOnly import SDL // This function doesn't exist in the actual UIKit of course, // but the app entrypoint is easily customizable, so it doesn't diff --git a/Sources/UIColor.swift b/Sources/UIColor.swift index 542d3674..e53a1cad 100644 --- a/Sources/UIColor.swift +++ b/Sources/UIColor.swift @@ -6,7 +6,7 @@ // Copyright © 2017 Geordie Jay. All rights reserved. // -import SDL +@_implementationOnly import SDL public class UIColor: Hashable { let redValue: UInt8 diff --git a/Sources/UIImage.swift b/Sources/UIImage.swift index fd8681d6..1cb26456 100644 --- a/Sources/UIImage.swift +++ b/Sources/UIImage.swift @@ -1,5 +1,5 @@ -import SDL -import SDL_gpu +@_implementationOnly import SDL +@_implementationOnly import SDL_gpu #if os(macOS) import Foundation diff --git a/Sources/UIScreen+Errors.swift b/Sources/UIScreen+Errors.swift index 7442552a..bbec640f 100644 --- a/Sources/UIScreen+Errors.swift +++ b/Sources/UIScreen+Errors.swift @@ -6,7 +6,7 @@ // Copyright © 2018 flowkey. All rights reserved. // -import SDL_gpu +@_implementationOnly import SDL_gpu extension UIScreen { func clearErrors() { @@ -17,7 +17,7 @@ extension UIScreen { } /// `throw`s errors of the given type, asserts in debug if another error was present - func throwOnErrors(ofType errorType: Set) throws { + func throwOnErrors(ofType errorType: [GPU_ErrorEnum]) throws { let lastError = GPU_PopErrorCode() if lastError.error == GPU_ERROR_NONE { return @@ -25,7 +25,7 @@ extension UIScreen { if errorType.contains(lastError.error) { clearErrors() // clear all others - throw lastError.error + try lastError.error.throwAsSwiftGPUError() } #if DEBUG @@ -36,36 +36,30 @@ extension UIScreen { } } -extension GPU_ErrorEnum: Equatable, Hashable { - public func hash(into hasher: inout Hasher) { - hasher.combine(self.rawValue) - } - - public static func == (lhs: GPU_ErrorEnum, rhs: GPU_ErrorEnum) -> Bool { - return lhs.rawValue == rhs.rawValue - } +enum GPUError: Error { + case dataError, nullArgument, backendError, none, userError, fileNotFound, unsupportedFunction, unknown } -extension GPU_ErrorEnum: Error, CustomStringConvertible { - public var description: String { +private extension GPU_ErrorEnum { + func throwAsSwiftGPUError() throws { switch self { case GPU_ERROR_DATA_ERROR: - return "GPU_ERROR_DATA_ERROR" + throw GPUError.dataError case GPU_ERROR_NULL_ARGUMENT: - return "GPU_ERROR_NULL_ARGUMENT" + throw GPUError.nullArgument case GPU_ERROR_BACKEND_ERROR: - return "GPU_ERROR_BACKEND_ERROR" + throw GPUError.backendError case GPU_ERROR_NONE: - return "GPU_ERROR_NONE" + throw GPUError.none case GPU_ERROR_USER_ERROR: - return "GPU_ERROR_USER_ERROR" + throw GPUError.userError case GPU_ERROR_FILE_NOT_FOUND: - return "GPU_ERROR_FILE_NOT_FOUND" + throw GPUError.fileNotFound case GPU_ERROR_UNSUPPORTED_FUNCTION: - return "GPU_ERROR_UNSUPPORTED_FUNCTION" + throw GPUError.unsupportedFunction default: assertionFailure("Unknown GPU_ErrorEnum error type") - return "Unknown" + throw GPUError.unknown } } } diff --git a/Sources/UIScreen+render.swift b/Sources/UIScreen+render.swift index 6253527e..bff9beec 100644 --- a/Sources/UIScreen+render.swift +++ b/Sources/UIScreen+render.swift @@ -6,8 +6,8 @@ // Copyright © 2017 flowkey. All rights reserved. // -import SDL -import SDL_gpu +@_implementationOnly import SDL +@_implementationOnly import SDL_gpu extension UIScreen { @MainActor diff --git a/Sources/UIScreen.swift b/Sources/UIScreen.swift index 5045f341..a9d05f99 100644 --- a/Sources/UIScreen.swift +++ b/Sources/UIScreen.swift @@ -6,10 +6,14 @@ // Copyright © 2017 flowkey. All rights reserved. // -import SDL -import SDL_gpu +@_implementationOnly import SDL +@_implementationOnly import SDL_gpu -extension SDLWindowFlags: OptionSet {} +extension SDLWindowFlags { + func contains(_ flags: SDLWindowFlags) -> Bool { + return (self.rawValue & flags.rawValue) != 0 // FIXME? + } +} public extension UIScreen { @MainActor @@ -49,13 +53,10 @@ public final class UIScreen { #if os(Android) // height/width are determined by the window when fullscreen: var size = CGSize.zero - let options: SDLWindowFlags = [SDL_WINDOW_FULLSCREEN] + let options: SDLWindowFlags = SDL_WINDOW_FULLSCREEN #else var size = CGSize.samsungGalaxyS7.landscape - let options: SDLWindowFlags = [ - SDL_WINDOW_ALLOW_HIGHDPI, - //SDL_WINDOW_FULLSCREEN - ] + let options: SDLWindowFlags = SDL_WINDOW_ALLOW_HIGHDPI #endif SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) diff --git a/Sources/UIScrollView+velocity.swift b/Sources/UIScrollView+velocity.swift index 6ded6e75..44cf093c 100644 --- a/Sources/UIScrollView+velocity.swift +++ b/Sources/UIScrollView+velocity.swift @@ -34,7 +34,7 @@ extension UIScrollView { let animationTimeConstant = 0.325 * dampingFactor // This calculation is a weird approximation but it's close enough for now... - let animationTime = log(Double(distanceToBoundsCheckedTarget.magnitude)) * animationTimeConstant + let animationTime = log2(Double(distanceToBoundsCheckedTarget.magnitude)) * animationTimeConstant UIView.animate( withDuration: animationTime, diff --git a/Sources/UIView+SDL.swift b/Sources/UIView+SDL.swift index a150a782..9fbcb1ea 100644 --- a/Sources/UIView+SDL.swift +++ b/Sources/UIView+SDL.swift @@ -6,7 +6,7 @@ // Copyright © 2017 flowkey. All rights reserved. // -@_exported import SDL +@_implementationOnly import SDL extension UIView { final func sdlDrawAndLayoutTreeIfNeeded(parentAlpha: CGFloat = 1.0) { diff --git a/Sources/UIView.swift b/Sources/UIView.swift index 448ac858..eabdadab 100644 --- a/Sources/UIView.swift +++ b/Sources/UIView.swift @@ -1,4 +1,4 @@ -import SDL +@_implementationOnly import SDL @MainActor open class UIView: UIResponder, CALayerDelegate, UIAccessibilityIdentification { diff --git a/Sources/UIWindow+TouchHandling.swift b/Sources/UIWindow+TouchHandling.swift index 6a5e368d..6398b7b7 100644 --- a/Sources/UIWindow+TouchHandling.swift +++ b/Sources/UIWindow+TouchHandling.swift @@ -6,6 +6,8 @@ // Copyright © 2017 flowkey. All rights reserved. // +@_implementationOnly import SDL + protocol SDLEventWithCoordinates { var x: Int32 { get } var y: Int32 { get } diff --git a/Sources/VideoTexture+Mac.swift b/Sources/VideoTexture+Mac.swift index 74421a91..297f68d1 100644 --- a/Sources/VideoTexture+Mac.swift +++ b/Sources/VideoTexture+Mac.swift @@ -8,7 +8,7 @@ #if os(macOS) -import SDL_gpu +@_implementationOnly import SDL_gpu internal final class VideoTexture: CGImage { convenience init?(width: Int, height: Int, format: GPU_FormatEnum) { diff --git a/Sources/androidNativeInit.swift b/Sources/androidNativeInit.swift index 1f1fbd5a..7a7db407 100644 --- a/Sources/androidNativeInit.swift +++ b/Sources/androidNativeInit.swift @@ -7,7 +7,7 @@ // Copyright © 2017 flowkey. All rights reserved. // -import SDL +@_implementationOnly import SDL import JNI public struct UIKitAndroid { From e908c0f50e4189d9c8ccce192a046525d1dcd4ce Mon Sep 17 00:00:00 2001 From: Geordie Jay Date: Tue, 6 Dec 2022 11:43:55 +1000 Subject: [PATCH 03/14] Allow static build --- Package.swift | 9 +++++++-- SDL | 2 +- Sources/UIApplication.swift | 1 + src/main/java/org/libsdl/app/SDLActivity.kt | 4 ---- swift-jni | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Package.swift b/Package.swift index 5d3a606e..106d019d 100644 --- a/Package.swift +++ b/Package.swift @@ -5,7 +5,7 @@ let package = Package( name: "UIKit", platforms: [.macOS(.v10_15)], products: [ - .library(name: "UIKit", type: .dynamic, targets: ["UIKit"]) + .library(name: "UIKit", targets: ["UIKit"]) ], dependencies: [ .package(path: "./swift-jni"), @@ -17,11 +17,16 @@ let package = Package( dependencies: [ .product(name: "SDL_Android", package: "SDL", condition: .when(platforms: [.android])), .product(name: "JNI", package: "swift-jni", condition: .when(platforms: [.android])), + .target(name: "UIKit_C_API", condition: .when(platforms: [.android])), ], path: "Sources", exclude: [ "Mac-Info.plist", ] - ) + ), + .target( + name: "UIKit_C_API", + path: "UIKit_C_API" + ), ] ) diff --git a/SDL b/SDL index 97a1aca7..9ccf8955 160000 --- a/SDL +++ b/SDL @@ -1 +1 @@ -Subproject commit 97a1aca7e7bc48733efbc15b49e0782f3ee9f7c6 +Subproject commit 9ccf8955a77cbf0d8fc5e86acc50564345bc64e0 diff --git a/Sources/UIApplication.swift b/Sources/UIApplication.swift index 0ffa5bd4..1b011c5c 100644 --- a/Sources/UIApplication.swift +++ b/Sources/UIApplication.swift @@ -1,4 +1,5 @@ @_implementationOnly import SDL +@_exported import UIKit_C_API @MainActor open class UIApplication { diff --git a/src/main/java/org/libsdl/app/SDLActivity.kt b/src/main/java/org/libsdl/app/SDLActivity.kt index 734d51de..8c6b3716 100644 --- a/src/main/java/org/libsdl/app/SDLActivity.kt +++ b/src/main/java/org/libsdl/app/SDLActivity.kt @@ -36,10 +36,6 @@ open class SDLActivity internal constructor (context: Context?) : RelativeLayout // and it is a major overhaul to change the native C code (there are a lot of dependencies) @JvmStatic internal var mSeparateMouseAndTouch = false - - init { - arrayOf("JNI", "UIKit").forEach { System.loadLibrary(it) } - } } private var mSurface: SurfaceView diff --git a/swift-jni b/swift-jni index 894237c1..43d813c8 160000 --- a/swift-jni +++ b/swift-jni @@ -1 +1 @@ -Subproject commit 894237c1e1cb874c5b1e07a28c649be0cfb9e548 +Subproject commit 43d813c84b79ea026f7e8ede43ce0ff8bd034d55 From 984d0b1e5e40e4334c9b146f1c27fa5eb2c0b15e Mon Sep 17 00:00:00 2001 From: Geordie Jay Date: Tue, 6 Dec 2022 13:23:53 +1000 Subject: [PATCH 04/14] Add UIKit_C_API --- UIKit_C_API/dummy.c | 0 UIKit_C_API/include/uikit.h | 3 +++ 2 files changed, 3 insertions(+) create mode 100644 UIKit_C_API/dummy.c create mode 100644 UIKit_C_API/include/uikit.h diff --git a/UIKit_C_API/dummy.c b/UIKit_C_API/dummy.c new file mode 100644 index 00000000..e69de29b diff --git a/UIKit_C_API/include/uikit.h b/UIKit_C_API/include/uikit.h new file mode 100644 index 00000000..751c963d --- /dev/null +++ b/UIKit_C_API/include/uikit.h @@ -0,0 +1,3 @@ +#import "jni.h" + +JNIEXPORT jint JNICALL SDLJNI_OnLoad(JavaVM * _Nonnull vm, void * _Nullable reserved); \ No newline at end of file From 35a9d0ea8205328b0df6a94bf4d83216f5487d85 Mon Sep 17 00:00:00 2001 From: Geordie Jay Date: Tue, 6 Dec 2022 17:14:01 +1000 Subject: [PATCH 05/14] Working towards mac build again --- Package.swift | 10 +++------- SDL | 2 +- swift-android-toolchain | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Package.swift b/Package.swift index 106d019d..5c215a4d 100644 --- a/Package.swift +++ b/Package.swift @@ -15,18 +15,14 @@ let package = Package( .target( name: "UIKit", dependencies: [ + .product(name: "SDL_macOS", package: "SDL", condition: .when(platforms: [.macOS])), .product(name: "SDL_Android", package: "SDL", condition: .when(platforms: [.android])), .product(name: "JNI", package: "swift-jni", condition: .when(platforms: [.android])), .target(name: "UIKit_C_API", condition: .when(platforms: [.android])), ], path: "Sources", - exclude: [ - "Mac-Info.plist", - ] - ), - .target( - name: "UIKit_C_API", - path: "UIKit_C_API" + exclude: ["Mac-Info.plist"] ), + .target(name: "UIKit_C_API", path: "UIKit_C_API"), ] ) diff --git a/SDL b/SDL index 9ccf8955..1a68982f 160000 --- a/SDL +++ b/SDL @@ -1 +1 @@ -Subproject commit 9ccf8955a77cbf0d8fc5e86acc50564345bc64e0 +Subproject commit 1a68982ff5bad0690a9ee89a2aa6188f6e31b762 diff --git a/swift-android-toolchain b/swift-android-toolchain index b6bdc735..bbc1d6cb 160000 --- a/swift-android-toolchain +++ b/swift-android-toolchain @@ -1 +1 @@ -Subproject commit b6bdc7358f7c4d1ea5fbeeafc2e572eaf9ba2696 +Subproject commit bbc1d6cb3938db35a9c11bc08093fa0069cd4a15 From a9481148075e81dec775f4c155692edf8999cd1d Mon Sep 17 00:00:00 2001 From: Geordie Jay Date: Fri, 9 Dec 2022 14:12:06 +1100 Subject: [PATCH 06/14] Don't export SDL symbols unnecessarily --- Sources/UIApplication+handleSDLEvents.swift | 39 ++++++++++++--------- Sources/UIScreen.swift | 2 +- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/Sources/UIApplication+handleSDLEvents.swift b/Sources/UIApplication+handleSDLEvents.swift index 2451ec74..b99850c7 100644 --- a/Sources/UIApplication+handleSDLEvents.swift +++ b/Sources/UIApplication+handleSDLEvents.swift @@ -150,7 +150,11 @@ extension SDL_Scancode { static let androidHardwareBackButton = SDL_Scancode(rawValue: 270) } -// extension SDL_Keymod: OptionSet {} +extension SDL_Keymod { + func contains(_ other: SDL_Keymod) -> Bool { + return (self.rawValue & other.rawValue) == other.rawValue + } +} extension SDL_Event { var timestampInSeconds: Double { @@ -256,23 +260,27 @@ public func onNativeTouch( else { return } Task { @MainActor in + guard let screenScale = UIScreen.main?.scale else { + return + } + var event = SDL_Event(tfinger: - SDL_TouchFingerEvent( - type: eventType.rawValue, - timestamp: UInt32(timestampMs), - touchId: Int64(touchDeviceId), // some arbitrary number, stays the same per device - fingerId: Int64(pointerFingerId), - x: x / Float(UIScreen.main.scale), - y: y / Float(UIScreen.main.scale), - dx: 0, - dy: 0, - pressure: pressure + SDL_TouchFingerEvent( + type: eventType.rawValue, + timestamp: UInt32(timestampMs % JavaLong(UInt32.max - 1)), + touchId: Int64(touchDeviceId), // some arbitrary number, stays the same per device + fingerId: Int64(pointerFingerId), + x: x / Float(screenScale), + y: y / Float(screenScale), + dx: 0, + dy: 0, + pressure: pressure + ) ) - ) - // add the event to SDL's event stack - // don't use SDL_PushEvent because it overrides `event.timestamp` with its own: - SDL_PeepEvents(&event, 1, SDL_ADDEVENT, 0, 0) + // add the event to SDL's event stack + // don't use SDL_PushEvent because it overrides `event.timestamp` with its own: + SDL_PeepEvents(&event, 1, SDL_ADDEVENT, 0, 0) } } @@ -286,5 +294,4 @@ extension SDL_EventType { } } } - #endif diff --git a/Sources/UIScreen.swift b/Sources/UIScreen.swift index a9d05f99..1c49235f 100644 --- a/Sources/UIScreen.swift +++ b/Sources/UIScreen.swift @@ -11,7 +11,7 @@ extension SDLWindowFlags { func contains(_ flags: SDLWindowFlags) -> Bool { - return (self.rawValue & flags.rawValue) != 0 // FIXME? + return (self.rawValue & flags.rawValue) == flags.rawValue } } From a91aa479d8961407f9fbd71f851cc430153dcce1 Mon Sep 17 00:00:00 2001 From: Geordie Jay Date: Fri, 9 Dec 2022 17:42:42 +1100 Subject: [PATCH 07/14] Update submodules --- SDL | 2 +- swift-android-toolchain | 2 +- swift-jni | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SDL b/SDL index 1a68982f..cdf09ad7 160000 --- a/SDL +++ b/SDL @@ -1 +1 @@ -Subproject commit 1a68982ff5bad0690a9ee89a2aa6188f6e31b762 +Subproject commit cdf09ad7d270ee980d9463bcb4636467354b038f diff --git a/swift-android-toolchain b/swift-android-toolchain index bbc1d6cb..2a843980 160000 --- a/swift-android-toolchain +++ b/swift-android-toolchain @@ -1 +1 @@ -Subproject commit bbc1d6cb3938db35a9c11bc08093fa0069cd4a15 +Subproject commit 2a8439804ef0f39d9de1172407b20d13ff4f6202 diff --git a/swift-jni b/swift-jni index 43d813c8..f03a5a15 160000 --- a/swift-jni +++ b/swift-jni @@ -1 +1 @@ -Subproject commit 43d813c84b79ea026f7e8ede43ce0ff8bd034d55 +Subproject commit f03a5a15b9cf6d05f48ff8047999c7f0856bae46 From 6141a54d943046d91b63e2d9f389b3efc3cd4b87 Mon Sep 17 00:00:00 2001 From: Geordie Jay Date: Fri, 9 Dec 2022 18:39:05 +1100 Subject: [PATCH 08/14] Match potentiallyFixNativeTouchCrash implementation of handleSDLEvents fix --- Sources/UIApplication+handleSDLEvents.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/UIApplication+handleSDLEvents.swift b/Sources/UIApplication+handleSDLEvents.swift index b99850c7..34f7b45d 100644 --- a/Sources/UIApplication+handleSDLEvents.swift +++ b/Sources/UIApplication+handleSDLEvents.swift @@ -267,7 +267,7 @@ public func onNativeTouch( var event = SDL_Event(tfinger: SDL_TouchFingerEvent( type: eventType.rawValue, - timestamp: UInt32(timestampMs % JavaLong(UInt32.max - 1)), + timestamp: UInt32(truncatingIfNeeded: timestampMs), touchId: Int64(touchDeviceId), // some arbitrary number, stays the same per device fingerId: Int64(pointerFingerId), x: x / Float(screenScale), From 30f89e936aedf8a15782311c620f380759b9afc6 Mon Sep 17 00:00:00 2001 From: Geordie Jay Date: Tue, 12 Nov 2024 23:37:08 +0100 Subject: [PATCH 09/14] Revert log2 -> log --- Sources/Math.swift | 6 +++--- Sources/UIScrollView+velocity.swift | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/Math.swift b/Sources/Math.swift index 5b28713f..0e3dd30e 100644 --- a/Sources/Math.swift +++ b/Sources/Math.swift @@ -1,14 +1,14 @@ #if os(WASI) @_exported import func WASILibc.pow @_exported import func WASILibc.log10 -@_exported import func WASILibc.log2 +@_exported import func WASILibc.log @_exported import func WASILibc.sin @_exported import func WASILibc.cos #elseif canImport(Bionic) @_exported import func Bionic.pow @_exported import func Bionic.acosf @_exported import func Bionic.log10 -@_exported import func Bionic.log2 +@_exported import func Bionic.log @_exported import func Bionic.sin @_exported import func Bionic.sinf @_exported import func Bionic.cos @@ -19,7 +19,7 @@ #elseif canImport(Darwin) @_exported import func Foundation.pow @_exported import func Foundation.log10 -@_exported import func Foundation.log2 +@_exported import func Foundation.log @_exported import func Foundation.sin @_exported import func Foundation.cos @_exported import func Foundation.clock_gettime diff --git a/Sources/UIScrollView+velocity.swift b/Sources/UIScrollView+velocity.swift index 44cf093c..6ded6e75 100644 --- a/Sources/UIScrollView+velocity.swift +++ b/Sources/UIScrollView+velocity.swift @@ -34,7 +34,7 @@ extension UIScrollView { let animationTimeConstant = 0.325 * dampingFactor // This calculation is a weird approximation but it's close enough for now... - let animationTime = log2(Double(distanceToBoundsCheckedTarget.magnitude)) * animationTimeConstant + let animationTime = log(Double(distanceToBoundsCheckedTarget.magnitude)) * animationTimeConstant UIView.animate( withDuration: animationTime, From 563c8f097b60a8749998f525fa87ad51369d02ce Mon Sep 17 00:00:00 2001 From: Geordie Jay Date: Tue, 12 Nov 2024 23:40:26 +0100 Subject: [PATCH 10/14] Remove reference to deleted DispatchQueue+syncSafe --- UIKit.xcodeproj/project.pbxproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/UIKit.xcodeproj/project.pbxproj b/UIKit.xcodeproj/project.pbxproj index fe40484f..62fde576 100644 --- a/UIKit.xcodeproj/project.pbxproj +++ b/UIKit.xcodeproj/project.pbxproj @@ -20,7 +20,6 @@ 5B71D7472292B68E008CEC66 /* UIAccessibilityIdentification.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B71D7462292B68E008CEC66 /* UIAccessibilityIdentification.swift */; }; 5B8053DF1F39EE0E00BAF074 /* UIViewAnimationGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B8053DE1F39EE0E00BAF074 /* UIViewAnimationGroup.swift */; }; 5B840BB71F42FCBD0010AC95 /* AnimatableProperty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B840BB61F42FCBC0010AC95 /* AnimatableProperty.swift */; }; - 5B8B85EF2940EF7900881E7F /* DispatchQueue+syncSafe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B8B85EA2940EF7400881E7F /* DispatchQueue+syncSafe.swift */; }; 5BA1FC4E1F6694CA005843B9 /* UITextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BA1FC4D1F6694CA005843B9 /* UITextView.swift */; }; 5BA7B40B1F45A6AD0040CB58 /* CABasicAnimationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BA7B40A1F45A6AD0040CB58 /* CABasicAnimationTests.swift */; }; 5BA87A9C2018FC990080C876 /* CATransform3D+animations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5BA87A942018FC980080C876 /* CATransform3D+animations.swift */; }; @@ -289,7 +288,6 @@ 5B71D7462292B68E008CEC66 /* UIAccessibilityIdentification.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIAccessibilityIdentification.swift; sourceTree = ""; }; 5B8053DE1F39EE0E00BAF074 /* UIViewAnimationGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = UIViewAnimationGroup.swift; path = Sources/UIViewAnimationGroup.swift; sourceTree = SOURCE_ROOT; }; 5B840BB61F42FCBC0010AC95 /* AnimatableProperty.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AnimatableProperty.swift; path = Sources/AnimatableProperty.swift; sourceTree = SOURCE_ROOT; }; - 5B8B85EA2940EF7400881E7F /* DispatchQueue+syncSafe.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DispatchQueue+syncSafe.swift"; sourceTree = ""; }; 5BA1FC4D1F6694CA005843B9 /* UITextView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = UITextView.swift; path = Sources/UITextView.swift; sourceTree = SOURCE_ROOT; }; 5BA7B40A1F45A6AD0040CB58 /* CABasicAnimationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CABasicAnimationTests.swift; sourceTree = ""; }; 5BA87A942018FC980080C876 /* CATransform3D+animations.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "CATransform3D+animations.swift"; path = "Sources/CATransform3D+animations.swift"; sourceTree = SOURCE_ROOT; }; @@ -627,7 +625,6 @@ 833075381F697613002089AC /* Video */, 60D6D8A1275E6CEC00892A7E /* Switch.swift */, 5CBEB3E32914A75C00D0CC3F /* Data.swift */, - 5B8B85EA2940EF7400881E7F /* DispatchQueue+syncSafe.swift */, ); name = UIKit; path = Sources; @@ -1115,7 +1112,6 @@ 5BA87A9C2018FC990080C876 /* CATransform3D+animations.swift in Sources */, 5C6AB71F1ED3BECD006F90AC /* UIWindow.swift in Sources */, 5CB6E1C32033460C001FEAC9 /* CATransform3D+SDL_gpu.swift in Sources */, - 5B8B85EF2940EF7900881E7F /* DispatchQueue+syncSafe.swift in Sources */, 5C8E6A21203A089A00D1DBE0 /* CALayer+ContentsGravity.swift in Sources */, 5BF666A01F4AEC6800BF698C /* CASpringAnimationPrototype.swift in Sources */, 5B840BB71F42FCBD0010AC95 /* AnimatableProperty.swift in Sources */, From fe2eeaf07db268c2d781a1ad77e9c48a2c144e7b Mon Sep 17 00:00:00 2001 From: Geordie Jay Date: Thu, 14 Nov 2024 00:39:36 +0100 Subject: [PATCH 11/14] Working Mac SwiftPM build --- Package.swift | 3 +- SDL | 2 +- Sources/AVPlayerLayer+Mac.swift | 2 +- Sources/CALayer+SDL.swift | 2 +- Sources/CALayer.swift | 2 +- Sources/CATransform3D+SDL_gpu.swift | 2 +- Sources/CATransform3D+animations.swift | 2 +- Sources/CGDataProvider.swift | 2 +- Sources/CGImage.swift | 4 +- .../Data+fromRelativePathCrossPlatform.swift | 2 +- .../FontRenderer+renderAttributedString.swift | 2 +- Sources/FontRenderer+singleLineSize.swift | 2 +- Sources/FontRenderer.swift | 2 +- Sources/Logging.swift | 2 +- Sources/Math.swift | 2 + Sources/SDL2-Shims.swift | 2 +- Sources/Shader.swift | 2 +- Sources/ShaderProgram+mask.swift | 2 +- Sources/ShaderProgram.swift | 2 +- Sources/UIApplication+handleSDLEvents.swift | 2 +- Sources/UIApplication.swift | 11 +- Sources/UIApplicationMain.swift | 2 +- Sources/UIColor.swift | 2 +- Sources/UIImage.swift | 4 +- Sources/UIScreen+Errors.swift | 2 +- Sources/UIScreen+render.swift | 4 +- Sources/UIScreen.swift | 10 +- Sources/UIView+SDL.swift | 2 +- Sources/UIView.swift | 2 +- Sources/UIWindow+TouchHandling.swift | 2 +- Sources/VideoTexture+Mac.swift | 2 +- Sources/androidNativeInit.swift | 2 +- UIKit.xcodeproj/project.pbxproj | 246 ++++-------------- 33 files changed, 101 insertions(+), 233 deletions(-) diff --git a/Package.swift b/Package.swift index 5c215a4d..4ca33f5e 100644 --- a/Package.swift +++ b/Package.swift @@ -15,8 +15,7 @@ let package = Package( .target( name: "UIKit", dependencies: [ - .product(name: "SDL_macOS", package: "SDL", condition: .when(platforms: [.macOS])), - .product(name: "SDL_Android", package: "SDL", condition: .when(platforms: [.android])), + .product(name: "SDL", package: "SDL"), .product(name: "JNI", package: "swift-jni", condition: .when(platforms: [.android])), .target(name: "UIKit_C_API", condition: .when(platforms: [.android])), ], diff --git a/SDL b/SDL index adc03319..b939db00 160000 --- a/SDL +++ b/SDL @@ -1 +1 @@ -Subproject commit adc03319b53f1842b2ff9e10cc9e4dce3fc36f40 +Subproject commit b939db0001890433092b118e8a4fdabc23652255 diff --git a/Sources/AVPlayerLayer+Mac.swift b/Sources/AVPlayerLayer+Mac.swift index 8878d872..565d3508 100644 --- a/Sources/AVPlayerLayer+Mac.swift +++ b/Sources/AVPlayerLayer+Mac.swift @@ -8,7 +8,7 @@ // import AVFoundation -import var SDL_gpu.GPU_FORMAT_RGBA +internal import var SDL_gpu.GPU_FORMAT_RGBA public typealias AVPlayer = AVFoundation.AVPlayer diff --git a/Sources/CALayer+SDL.swift b/Sources/CALayer+SDL.swift index 62f02e09..ce039aff 100644 --- a/Sources/CALayer+SDL.swift +++ b/Sources/CALayer+SDL.swift @@ -6,7 +6,7 @@ // Copyright © 2017 flowkey. All rights reserved. // -@_implementationOnly import SDL_gpu +internal import SDL_gpu extension CALayer { @MainActor diff --git a/Sources/CALayer.swift b/Sources/CALayer.swift index 73d6733a..86f858dc 100644 --- a/Sources/CALayer.swift +++ b/Sources/CALayer.swift @@ -1,4 +1,4 @@ -@_implementationOnly import SDL +internal import SDL @MainActor open class CALayer { diff --git a/Sources/CATransform3D+SDL_gpu.swift b/Sources/CATransform3D+SDL_gpu.swift index 18a77c14..0f311afc 100644 --- a/Sources/CATransform3D+SDL_gpu.swift +++ b/Sources/CATransform3D+SDL_gpu.swift @@ -6,7 +6,7 @@ // Copyright © 2018 flowkey. All rights reserved. // -@_implementationOnly import SDL_gpu +internal import SDL_gpu extension CATransform3D { /// Set the current transformation as SDL_GPU's current transform matrix diff --git a/Sources/CATransform3D+animations.swift b/Sources/CATransform3D+animations.swift index 019bcf6f..e7250b58 100644 --- a/Sources/CATransform3D+animations.swift +++ b/Sources/CATransform3D+animations.swift @@ -5,7 +5,7 @@ // Created by Michael Knoch on 19.01.18. // -@_implementationOnly import SDL_gpu +internal import SDL_gpu // It doesn't make sense to make these public, they're only to simplify our animation code: internal extension CATransform3D { diff --git a/Sources/CGDataProvider.swift b/Sources/CGDataProvider.swift index 0576ccb5..541a4871 100644 --- a/Sources/CGDataProvider.swift +++ b/Sources/CGDataProvider.swift @@ -6,7 +6,7 @@ // Copyright © 2017 flowkey. All rights reserved. // -@_implementationOnly import SDL +internal import SDL public class CGDataProvider { public var data: [CChar] diff --git a/Sources/CGImage.swift b/Sources/CGImage.swift index 692a420e..b04dfcaa 100644 --- a/Sources/CGImage.swift +++ b/Sources/CGImage.swift @@ -1,5 +1,5 @@ -@_implementationOnly import SDL -@_implementationOnly import SDL_gpu +internal import SDL +internal import SDL_gpu public class CGImage { /// Be careful using this pointer e.g. for another CGImage instance. diff --git a/Sources/Data+fromRelativePathCrossPlatform.swift b/Sources/Data+fromRelativePathCrossPlatform.swift index 310dcfa5..6c28a591 100644 --- a/Sources/Data+fromRelativePathCrossPlatform.swift +++ b/Sources/Data+fromRelativePathCrossPlatform.swift @@ -6,7 +6,7 @@ // Copyright © 2018 flowkey. All rights reserved. // -@_implementationOnly import SDL +internal import SDL extension Data { static func _fromPathCrossPlatform(_ path: String) -> Data? { diff --git a/Sources/FontRenderer+renderAttributedString.swift b/Sources/FontRenderer+renderAttributedString.swift index 0d12c76b..49bd654a 100644 --- a/Sources/FontRenderer+renderAttributedString.swift +++ b/Sources/FontRenderer+renderAttributedString.swift @@ -6,7 +6,7 @@ // Copyright © 2018 flowkey. All rights reserved. // -@_implementationOnly import SDL_ttf +internal import SDL_ttf extension FontRenderer { func getFontKerningOffset(between previousIndex: FT_UInt?, and currentIndex: FT_UInt) -> Int32 { diff --git a/Sources/FontRenderer+singleLineSize.swift b/Sources/FontRenderer+singleLineSize.swift index 2b0d3dc5..6e1bd5a3 100644 --- a/Sources/FontRenderer+singleLineSize.swift +++ b/Sources/FontRenderer+singleLineSize.swift @@ -6,7 +6,7 @@ // Copyright © 2018 flowkey. All rights reserved. // -@_implementationOnly import SDL_ttf +internal import SDL_ttf extension FontRenderer { // From `TTF_HANDLE_STYLE_BOLD` diff --git a/Sources/FontRenderer.swift b/Sources/FontRenderer.swift index 3230087e..a328f04d 100644 --- a/Sources/FontRenderer.swift +++ b/Sources/FontRenderer.swift @@ -6,7 +6,7 @@ // Copyright © 2017 flowkey. All rights reserved. // -@_implementationOnly import SDL_ttf +internal import SDL_ttf extension FontRenderer { diff --git a/Sources/Logging.swift b/Sources/Logging.swift index bc6e85cb..2a98ec27 100644 --- a/Sources/Logging.swift +++ b/Sources/Logging.swift @@ -7,7 +7,7 @@ // Copyright © 2017 flowkey. All rights reserved. // -@_implementationOnly import SDL +internal import SDL #if os(Android) import Bionic diff --git a/Sources/Math.swift b/Sources/Math.swift index 0e3dd30e..d9ec736c 100644 --- a/Sources/Math.swift +++ b/Sources/Math.swift @@ -17,10 +17,12 @@ @_exported import struct Bionic.timespec @_exported import struct Bionic.clockid_t #elseif canImport(Darwin) +@_exported import func Foundation.acosf @_exported import func Foundation.pow @_exported import func Foundation.log10 @_exported import func Foundation.log @_exported import func Foundation.sin +@_exported import func Foundation.sinf @_exported import func Foundation.cos @_exported import func Foundation.clock_gettime @_exported import struct Foundation.timespec diff --git a/Sources/SDL2-Shims.swift b/Sources/SDL2-Shims.swift index 6c1f6284..210c3935 100644 --- a/Sources/SDL2-Shims.swift +++ b/Sources/SDL2-Shims.swift @@ -6,7 +6,7 @@ // Copyright © 2017 Geordie Jay. All rights reserved. // -@_implementationOnly import SDL +internal import SDL struct SDLError: Error { let description: String diff --git a/Sources/Shader.swift b/Sources/Shader.swift index f3168bb9..116e66c4 100644 --- a/Sources/Shader.swift +++ b/Sources/Shader.swift @@ -6,7 +6,7 @@ // Copyright © 2017 flowkey. All rights reserved. // -@_implementationOnly import SDL_gpu +internal import SDL_gpu class VertexShader: Shader { // Some keywords have changed since the earlier shader language versions available on Android: diff --git a/Sources/ShaderProgram+mask.swift b/Sources/ShaderProgram+mask.swift index aa4eb912..05f00052 100644 --- a/Sources/ShaderProgram+mask.swift +++ b/Sources/ShaderProgram+mask.swift @@ -6,7 +6,7 @@ // Copyright © 2017 flowkey. All rights reserved. // -@_implementationOnly import SDL_gpu +internal import SDL_gpu extension ShaderProgram { static let mask = try! MaskShaderProgram() diff --git a/Sources/ShaderProgram.swift b/Sources/ShaderProgram.swift index b062990d..9961927a 100644 --- a/Sources/ShaderProgram.swift +++ b/Sources/ShaderProgram.swift @@ -6,7 +6,7 @@ // Copyright © 2017 flowkey. All rights reserved. // -@_implementationOnly import SDL_gpu +internal import SDL_gpu // A ShaderProgram consists of a VertexShader and a FragmentShader linked together // This is a class because Shaders need to be freed after use diff --git a/Sources/UIApplication+handleSDLEvents.swift b/Sources/UIApplication+handleSDLEvents.swift index c7dc8311..2ee43e2d 100644 --- a/Sources/UIApplication+handleSDLEvents.swift +++ b/Sources/UIApplication+handleSDLEvents.swift @@ -9,7 +9,7 @@ import JNI #endif -@_implementationOnly import SDL +internal import SDL extension UIApplication { @MainActor diff --git a/Sources/UIApplication.swift b/Sources/UIApplication.swift index be3448a2..420295df 100644 --- a/Sources/UIApplication.swift +++ b/Sources/UIApplication.swift @@ -1,7 +1,10 @@ -@_implementationOnly import SDL -@_exported import UIKit_C_API +internal import SDL import Dispatch +#if canImport(UIKit_C_API) +@_exported import UIKit_C_API +#endif + @MainActor open class UIApplication { public static var shared: UIApplication! // set via UIApplicationMain(_:_:_:_:) @@ -58,8 +61,8 @@ open class UIApplication { } -@_implementationOnly import SDL -@_implementationOnly import SDL_gpu +internal import SDL +internal import SDL_gpu extension UIApplication { func handleSDLQuit() { diff --git a/Sources/UIApplicationMain.swift b/Sources/UIApplicationMain.swift index d89bf1e4..b897c761 100644 --- a/Sources/UIApplicationMain.swift +++ b/Sources/UIApplicationMain.swift @@ -1,4 +1,4 @@ -@_implementationOnly import SDL +internal import SDL // This function doesn't exist in the actual UIKit of course, // but the app entrypoint is easily customizable, so it doesn't diff --git a/Sources/UIColor.swift b/Sources/UIColor.swift index 651b93cc..3bbc0167 100644 --- a/Sources/UIColor.swift +++ b/Sources/UIColor.swift @@ -6,7 +6,7 @@ // Copyright © 2017 Geordie Jay. All rights reserved. // -@_implementationOnly import SDL +internal import SDL public class UIColor: Hashable { let redValue: UInt8 diff --git a/Sources/UIImage.swift b/Sources/UIImage.swift index 1cb26456..41485932 100644 --- a/Sources/UIImage.swift +++ b/Sources/UIImage.swift @@ -1,5 +1,5 @@ -@_implementationOnly import SDL -@_implementationOnly import SDL_gpu +internal import SDL +internal import SDL_gpu #if os(macOS) import Foundation diff --git a/Sources/UIScreen+Errors.swift b/Sources/UIScreen+Errors.swift index bbec640f..d22fdad7 100644 --- a/Sources/UIScreen+Errors.swift +++ b/Sources/UIScreen+Errors.swift @@ -6,7 +6,7 @@ // Copyright © 2018 flowkey. All rights reserved. // -@_implementationOnly import SDL_gpu +internal import SDL_gpu extension UIScreen { func clearErrors() { diff --git a/Sources/UIScreen+render.swift b/Sources/UIScreen+render.swift index bff9beec..82390885 100644 --- a/Sources/UIScreen+render.swift +++ b/Sources/UIScreen+render.swift @@ -6,8 +6,8 @@ // Copyright © 2017 flowkey. All rights reserved. // -@_implementationOnly import SDL -@_implementationOnly import SDL_gpu +internal import SDL +internal import SDL_gpu extension UIScreen { @MainActor diff --git a/Sources/UIScreen.swift b/Sources/UIScreen.swift index 37ee5a56..bcae61fd 100644 --- a/Sources/UIScreen.swift +++ b/Sources/UIScreen.swift @@ -6,14 +6,10 @@ // Copyright © 2017 flowkey. All rights reserved. // -@_implementationOnly import SDL -@_implementationOnly import SDL_gpu +internal import SDL +internal import SDL_gpu -extension SDLWindowFlags { - func contains(_ flags: SDLWindowFlags) -> Bool { - return (self.rawValue & flags.rawValue) == flags.rawValue - } -} +extension SDLWindowFlags: @retroactive OptionSet {} public extension UIScreen { @MainActor diff --git a/Sources/UIView+SDL.swift b/Sources/UIView+SDL.swift index 9fbcb1ea..f041d35a 100644 --- a/Sources/UIView+SDL.swift +++ b/Sources/UIView+SDL.swift @@ -6,7 +6,7 @@ // Copyright © 2017 flowkey. All rights reserved. // -@_implementationOnly import SDL +internal import SDL extension UIView { final func sdlDrawAndLayoutTreeIfNeeded(parentAlpha: CGFloat = 1.0) { diff --git a/Sources/UIView.swift b/Sources/UIView.swift index 19fa828b..972334d2 100644 --- a/Sources/UIView.swift +++ b/Sources/UIView.swift @@ -1,4 +1,4 @@ -@_implementationOnly import SDL +internal import SDL @MainActor open class UIView: UIResponder, CALayerDelegate, UIAccessibilityIdentification { diff --git a/Sources/UIWindow+TouchHandling.swift b/Sources/UIWindow+TouchHandling.swift index 6398b7b7..709b2f1a 100644 --- a/Sources/UIWindow+TouchHandling.swift +++ b/Sources/UIWindow+TouchHandling.swift @@ -6,7 +6,7 @@ // Copyright © 2017 flowkey. All rights reserved. // -@_implementationOnly import SDL +internal import SDL protocol SDLEventWithCoordinates { var x: Int32 { get } diff --git a/Sources/VideoTexture+Mac.swift b/Sources/VideoTexture+Mac.swift index 297f68d1..5a5cbbf6 100644 --- a/Sources/VideoTexture+Mac.swift +++ b/Sources/VideoTexture+Mac.swift @@ -8,7 +8,7 @@ #if os(macOS) -@_implementationOnly import SDL_gpu +internal import SDL_gpu internal final class VideoTexture: CGImage { convenience init?(width: Int, height: Int, format: GPU_FormatEnum) { diff --git a/Sources/androidNativeInit.swift b/Sources/androidNativeInit.swift index 7a7db407..6345d792 100644 --- a/Sources/androidNativeInit.swift +++ b/Sources/androidNativeInit.swift @@ -7,7 +7,7 @@ // Copyright © 2017 flowkey. All rights reserved. // -@_implementationOnly import SDL +internal import SDL import JNI public struct UIKitAndroid { diff --git a/UIKit.xcodeproj/project.pbxproj b/UIKit.xcodeproj/project.pbxproj index 62fde576..51b8d2e3 100644 --- a/UIKit.xcodeproj/project.pbxproj +++ b/UIKit.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 60; objects = { /* Begin PBXBuildFile section */ @@ -107,12 +107,8 @@ 5CB6E1B62031D801001FEAC9 /* CGRect+TransformTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CB6E1B52031D801001FEAC9 /* CGRect+TransformTests.swift */; }; 5CB6E1B72031D801001FEAC9 /* CGRect+TransformTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CB6E1B52031D801001FEAC9 /* CGRect+TransformTests.swift */; }; 5CB6E1C02031ECCE001FEAC9 /* TransformTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CB6E1BF2031ECCE001FEAC9 /* TransformTests.swift */; }; - 5CB6E1C12031EDF2001FEAC9 /* SDL_gpu.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5CFFF8C4201635AF00D989BC /* SDL_gpu.framework */; }; 5CB6E1C32033460C001FEAC9 /* CATransform3D+SDL_gpu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CB6E1C22033460C001FEAC9 /* CATransform3D+SDL_gpu.swift */; }; 5CB6E1C52035BC4F001FEAC9 /* CGPoint+animations.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CB6E1C42035BC4E001FEAC9 /* CGPoint+animations.swift */; }; - 5CBC301320D22145000388D1 /* SDL_gpu.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5CFFF8C4201635AF00D989BC /* SDL_gpu.framework */; }; - 5CBC301420D22145000388D1 /* SDL_ttf.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5CFFF98120163AF900D989BC /* SDL_ttf.framework */; }; - 5CBC301520D22145000388D1 /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5CFFF8632016328200D989BC /* SDL2.framework */; }; 5CBD836520F6584200AF4E8E /* UIApplicationMain.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CBD836020F6584200AF4E8E /* UIApplicationMain.swift */; }; 5CBEB3E229149DD900D0CC3F /* AffineTransform.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CBEB3E129149DD900D0CC3F /* AffineTransform.swift */; }; 5CBEB3E42914A75C00D0CC3F /* Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CBEB3E32914A75C00D0CC3F /* Data.swift */; }; @@ -130,6 +126,8 @@ 5CE5C5781EDDAD8200680154 /* CGRect.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CE5C5771EDDAD8200680154 /* CGRect.swift */; }; 5CE5C57A1EDDAE5000680154 /* CGPath.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CE5C5791EDDAE5000680154 /* CGPath.swift */; }; 5CF2BEEE1F8D1BD7009FCA1E /* UIFontTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CF2BEED1F8D1BD7009FCA1E /* UIFontTests.swift */; }; + 5CF33D692CE5561B00BCAC3C /* SDL in Frameworks */ = {isa = PBXBuildFile; productRef = 5CF33D682CE5561B00BCAC3C /* SDL */; }; + 5CF33D6B2CE556CE00BCAC3C /* Math.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CF33D6A2CE556CE00BCAC3C /* Math.swift */; }; 5CFBD23E1EF8145C00BC9EBB /* FontRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CFBD23D1EF8145C00BC9EBB /* FontRenderer.swift */; }; 5CFFFA172017457100D989BC /* UIViewTests+subviews.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CFFFA162017457100D989BC /* UIViewTests+subviews.swift */; }; 5CFFFA182017457100D989BC /* UIViewTests+subviews.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5CFFFA162017457100D989BC /* UIViewTests+subviews.swift */; }; @@ -209,69 +207,6 @@ remoteGlobalIDString = 5C27E7AD1ECB2F6500F5020D; remoteInfo = UIKit; }; - 5CBC301620D22174000388D1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 5CFFF97C20163AF900D989BC /* SDL_ttf.xcodeproj */; - proxyType = 1; - remoteGlobalIDString = 5CFFF97020163AC900D989BC; - remoteInfo = SDL_ttf; - }; - 5CBC301820D22174000388D1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 5CFFF87F201632FC00D989BC /* SDL-gpu.xcodeproj */; - proxyType = 1; - remoteGlobalIDString = 5CFFF873201632FC00D989BC; - remoteInfo = "SDL-gpu"; - }; - 5CBC301A20D22174000388D1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 5CFFF85B2016328200D989BC /* SDL.xcodeproj */; - proxyType = 1; - remoteGlobalIDString = BECDF5FE0761BA81005FE872; - remoteInfo = Framework; - }; - 5CFFF8622016328200D989BC /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 5CFFF85B2016328200D989BC /* SDL.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = BECDF66C0761BA81005FE872; - remoteInfo = Framework; - }; - 5CFFF8642016328200D989BC /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 5CFFF85B2016328200D989BC /* SDL.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = BECDF6B30761BA81005FE872; - remoteInfo = "Static Library"; - }; - 5CFFF8662016328200D989BC /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 5CFFF85B2016328200D989BC /* SDL.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = DB31407717554B71006C0E22; - remoteInfo = "Shared Library"; - }; - 5CFFF8682016328200D989BC /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 5CFFF85B2016328200D989BC /* SDL.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = BECDF6BE0761BA81005FE872; - remoteInfo = "Standard DMG"; - }; - 5CFFF8C3201635AF00D989BC /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 5CFFF87F201632FC00D989BC /* SDL-gpu.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 5CFFF874201632FC00D989BC; - remoteInfo = "SDL-gpu"; - }; - 5CFFF98020163AF900D989BC /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 5CFFF97C20163AF900D989BC /* SDL_ttf.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 5CFFF97120163AC900D989BC; - remoteInfo = SDL_ttf; - }; /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ @@ -396,10 +331,8 @@ 5CE5C5771EDDAD8200680154 /* CGRect.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CGRect.swift; path = Sources/CGRect.swift; sourceTree = SOURCE_ROOT; }; 5CE5C5791EDDAE5000680154 /* CGPath.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CGPath.swift; path = Sources/CGPath.swift; sourceTree = SOURCE_ROOT; }; 5CF2BEED1F8D1BD7009FCA1E /* UIFontTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIFontTests.swift; sourceTree = ""; }; + 5CF33D6A2CE556CE00BCAC3C /* Math.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Math.swift; sourceTree = ""; }; 5CFBD23D1EF8145C00BC9EBB /* FontRenderer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontRenderer.swift; sourceTree = ""; }; - 5CFFF85B2016328200D989BC /* SDL.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SDL.xcodeproj; path = SDL/external/SDL2/Xcode/SDL/SDL.xcodeproj; sourceTree = ""; }; - 5CFFF87F201632FC00D989BC /* SDL-gpu.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "SDL-gpu.xcodeproj"; path = "SDL/SDL-gpu.xcodeproj"; sourceTree = ""; }; - 5CFFF97C20163AF900D989BC /* SDL_ttf.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SDL_ttf.xcodeproj; path = SDL/SDL_ttf.xcodeproj; sourceTree = ""; }; 5CFFFA162017457100D989BC /* UIViewTests+subviews.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewTests+subviews.swift"; sourceTree = ""; }; 60D6D8A1275E6CEC00892A7E /* Switch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Switch.swift; sourceTree = ""; }; 61C9D3B821B052750012018B /* Notification.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Notification.swift; sourceTree = ""; }; @@ -457,15 +390,13 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 5CBC301320D22145000388D1 /* SDL_gpu.framework in Frameworks */, - 5CBC301420D22145000388D1 /* SDL_ttf.framework in Frameworks */, - 5CBC301520D22145000388D1 /* SDL2.framework in Frameworks */, 5CCF1BD32017821E00AAF598 /* AVFoundation.framework in Frameworks */, 5C27E7DC1ECB2F9100F5020D /* Cocoa.framework in Frameworks */, 5C27E7DD1ECB2F9100F5020D /* AudioToolbox.framework in Frameworks */, 5C27E7DE1ECB2F9100F5020D /* ForceFeedback.framework in Frameworks */, 5C27E7DF1ECB2F9100F5020D /* Carbon.framework in Frameworks */, 5C27E7E01ECB2F9100F5020D /* CoreFoundation.framework in Frameworks */, + 5CF33D692CE5561B00BCAC3C /* SDL in Frameworks */, 5C27E7E11ECB2F9100F5020D /* IOKit.framework in Frameworks */, 5C27E7E21ECB2F9100F5020D /* CoreVideo.framework in Frameworks */, 5C27E7E31ECB2F9100F5020D /* CoreAudio.framework in Frameworks */, @@ -478,7 +409,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 5CB6E1C12031EDF2001FEAC9 /* SDL_gpu.framework in Frameworks */, 5C27E7B81ECB2F6500F5020D /* UIKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -537,9 +467,6 @@ 5C27E7A41ECB2F6500F5020D = { isa = PBXGroup; children = ( - 5CFFF97C20163AF900D989BC /* SDL_ttf.xcodeproj */, - 5CFFF87F201632FC00D989BC /* SDL-gpu.xcodeproj */, - 5CFFF85B2016328200D989BC /* SDL.xcodeproj */, 5C27E7D11ECB2F9100F5020D /* Frameworks */, 5C27E7AF1ECB2F6500F5020D /* Products */, 5C27E7F51ECB301900F5020D /* SDL */, @@ -577,6 +504,7 @@ 5C6AB77B1ED70F97006F90AC /* DisplayLink.swift */, 83E5F7FF1EF826CC00279C59 /* Geometry */, 5BD476341F4D94F40055EE27 /* Logging.swift */, + 5CF33D6A2CE556CE00BCAC3C /* Math.swift */, 5C9037241F138B8A0058E592 /* MeteringView.swift */, 61C9D3B821B052750012018B /* Notification.swift */, 61C9D3BA21B052B30012018B /* NotificationCenter.swift */, @@ -730,33 +658,6 @@ name = UIViewController; sourceTree = ""; }; - 5CFFF85C2016328200D989BC /* Products */ = { - isa = PBXGroup; - children = ( - 5CFFF8632016328200D989BC /* SDL2.framework */, - 5CFFF8652016328200D989BC /* libSDL2.a */, - 5CFFF8672016328200D989BC /* libSDL2.dylib */, - 5CFFF8692016328200D989BC /* Standard DMG */, - ); - name = Products; - sourceTree = ""; - }; - 5CFFF8C0201635AF00D989BC /* Products */ = { - isa = PBXGroup; - children = ( - 5CFFF8C4201635AF00D989BC /* SDL_gpu.framework */, - ); - name = Products; - sourceTree = ""; - }; - 5CFFF97D20163AF900D989BC /* Products */ = { - isa = PBXGroup; - children = ( - 5CFFF98120163AF900D989BC /* SDL_ttf.framework */, - ); - name = Products; - sourceTree = ""; - }; 5CFFFA0E2017454300D989BC /* UIView */ = { isa = PBXGroup; children = ( @@ -857,9 +758,6 @@ buildRules = ( ); dependencies = ( - 5CBC301720D22174000388D1 /* PBXTargetDependency */, - 5CBC301920D22174000388D1 /* PBXTargetDependency */, - 5CBC301B20D22174000388D1 /* PBXTargetDependency */, ); name = UIKit; productName = UIKit; @@ -938,22 +836,11 @@ en, ); mainGroup = 5C27E7A41ECB2F6500F5020D; + packageReferences = ( + 5C204B932CE5456600428CC7 /* XCLocalSwiftPackageReference "SDL" */, + ); productRefGroup = 5C27E7AF1ECB2F6500F5020D /* Products */; projectDirPath = ""; - projectReferences = ( - { - ProductGroup = 5CFFF8C0201635AF00D989BC /* Products */; - ProjectRef = 5CFFF87F201632FC00D989BC /* SDL-gpu.xcodeproj */; - }, - { - ProductGroup = 5CFFF85C2016328200D989BC /* Products */; - ProjectRef = 5CFFF85B2016328200D989BC /* SDL.xcodeproj */; - }, - { - ProductGroup = 5CFFF97D20163AF900D989BC /* Products */; - ProjectRef = 5CFFF97C20163AF900D989BC /* SDL_ttf.xcodeproj */; - }, - ); projectRoot = ""; targets = ( 5C27E7AD1ECB2F6500F5020D /* UIKit */, @@ -963,51 +850,6 @@ }; /* End PBXProject section */ -/* Begin PBXReferenceProxy section */ - 5CFFF8632016328200D989BC /* SDL2.framework */ = { - isa = PBXReferenceProxy; - fileType = wrapper.framework; - path = SDL2.framework; - remoteRef = 5CFFF8622016328200D989BC /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 5CFFF8652016328200D989BC /* libSDL2.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libSDL2.a; - remoteRef = 5CFFF8642016328200D989BC /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 5CFFF8672016328200D989BC /* libSDL2.dylib */ = { - isa = PBXReferenceProxy; - fileType = "compiled.mach-o.dylib"; - path = libSDL2.dylib; - remoteRef = 5CFFF8662016328200D989BC /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 5CFFF8692016328200D989BC /* Standard DMG */ = { - isa = PBXReferenceProxy; - fileType = "compiled.mach-o.executable"; - path = "Standard DMG"; - remoteRef = 5CFFF8682016328200D989BC /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 5CFFF8C4201635AF00D989BC /* SDL_gpu.framework */ = { - isa = PBXReferenceProxy; - fileType = wrapper.framework; - path = SDL_gpu.framework; - remoteRef = 5CFFF8C3201635AF00D989BC /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 5CFFF98120163AF900D989BC /* SDL_ttf.framework */ = { - isa = PBXReferenceProxy; - fileType = wrapper.framework; - path = SDL_ttf.framework; - remoteRef = 5CFFF98020163AF900D989BC /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; -/* End PBXReferenceProxy section */ - /* Begin PBXResourcesBuildPhase section */ 5C27E7AC1ECB2F6500F5020D /* Resources */ = { isa = PBXResourcesBuildPhase; @@ -1144,6 +986,7 @@ 5C6AB7651ED5A0C3006F90AC /* UIEvent.swift in Sources */, 8337A8131F39F37500475F80 /* UIScreen.swift in Sources */, 83E5F8151EF8322800279C59 /* CGSize.swift in Sources */, + 5CF33D6B2CE556CE00BCAC3C /* Math.swift in Sources */, 5C4CD51120615FCF00217B4C /* UIApplication+handleSDLEvents.swift in Sources */, 5C27E80F1ECB301900F5020D /* SDL2-Shims.swift in Sources */, 83F8D4A21F028E6B008D3262 /* CALayer+SDL.swift in Sources */, @@ -1238,21 +1081,6 @@ target = 5C27E7AD1ECB2F6500F5020D /* UIKit */; targetProxy = 5C27E7B91ECB2F6500F5020D /* PBXContainerItemProxy */; }; - 5CBC301720D22174000388D1 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = SDL_ttf; - targetProxy = 5CBC301620D22174000388D1 /* PBXContainerItemProxy */; - }; - 5CBC301920D22174000388D1 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = "SDL-gpu"; - targetProxy = 5CBC301820D22174000388D1 /* PBXContainerItemProxy */; - }; - 5CBC301B20D22174000388D1 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = Framework; - targetProxy = 5CBC301A20D22174000388D1 /* PBXContainerItemProxy */; - }; /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ @@ -1366,7 +1194,8 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SUPPORTED_PLATFORMS = macosx; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -1383,7 +1212,11 @@ DYLIB_CURRENT_VERSION = 1; FRAMEWORK_VERSION = A; INFOPLIST_FILE = "Sources/Mac-Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@loader_path/../Frameworks", + ); LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/UIKit"; PRODUCT_BUNDLE_IDENTIFIER = com.flowkey.UIKit; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1406,7 +1239,11 @@ DYLIB_CURRENT_VERSION = 1; FRAMEWORK_VERSION = A; INFOPLIST_FILE = "Sources/Mac-Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@loader_path/../Frameworks", + ); LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/UIKit"; PRODUCT_BUNDLE_IDENTIFIER = com.flowkey.UIKit; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1430,7 +1267,11 @@ "$(PROJECT_DIR)/SDL/SDL_ttf/include", ); INFOPLIST_FILE = UIKitTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@loader_path/../Frameworks", + ); LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/UIKit"; PRODUCT_BUNDLE_IDENTIFIER = com.flowkey.UIKitTests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1450,7 +1291,11 @@ "$(PROJECT_DIR)/SDL/SDL_ttf/include", ); INFOPLIST_FILE = UIKitTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@loader_path/../Frameworks", + ); LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/UIKit"; PRODUCT_BUNDLE_IDENTIFIER = com.flowkey.UIKitTests; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -1469,7 +1314,11 @@ GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "UIKitTests/iOSTestTarget-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 11.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = com.christianhaug.iOSTestTarget; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; @@ -1490,7 +1339,11 @@ GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "UIKitTests/iOSTestTarget-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 11.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = com.christianhaug.iOSTestTarget; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; @@ -1541,6 +1394,21 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCLocalSwiftPackageReference section */ + 5C204B932CE5456600428CC7 /* XCLocalSwiftPackageReference "SDL" */ = { + isa = XCLocalSwiftPackageReference; + relativePath = SDL; + }; +/* End XCLocalSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 5CF33D682CE5561B00BCAC3C /* SDL */ = { + isa = XCSwiftPackageProductDependency; + package = 5C204B932CE5456600428CC7 /* XCLocalSwiftPackageReference "SDL" */; + productName = SDL; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = 5C27E7A51ECB2F6500F5020D /* Project object */; } From 94a6d07e2539ab6a30e044cd0ea30eefd88fbefd Mon Sep 17 00:00:00 2001 From: Geordie Jay Date: Thu, 14 Nov 2024 00:47:58 +0100 Subject: [PATCH 12/14] Update SDL to fix Android build --- SDL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDL b/SDL index b939db00..ba244872 160000 --- a/SDL +++ b/SDL @@ -1 +1 @@ -Subproject commit b939db0001890433092b118e8a4fdabc23652255 +Subproject commit ba2448723b5ba7483274add32f8c8ea9bbbb6485 From 0d89cc21a31d7ec4120a04745cd74e6045c4de50 Mon Sep 17 00:00:00 2001 From: Geordie Jay Date: Thu, 14 Nov 2024 17:32:21 +0100 Subject: [PATCH 13/14] Update SDL --- SDL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDL b/SDL index ba244872..d3856f9d 160000 --- a/SDL +++ b/SDL @@ -1 +1 @@ -Subproject commit ba2448723b5ba7483274add32f8c8ea9bbbb6485 +Subproject commit d3856f9de342528591b2bdc39efbb1ae9a5c6358 From de503db31b1ead967a90a4062cac9483943efc8c Mon Sep 17 00:00:00 2001 From: Geordie Jay Date: Thu, 14 Nov 2024 17:33:16 +0100 Subject: [PATCH 14/14] Update SDL --- SDL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDL b/SDL index d3856f9d..9da23591 160000 --- a/SDL +++ b/SDL @@ -1 +1 @@ -Subproject commit d3856f9de342528591b2bdc39efbb1ae9a5c6358 +Subproject commit 9da23591dc259fcf781b6fea9b4beebb8008c08b