From 4c9eca2fcce065629529737a6e076c6cb7e5514f Mon Sep 17 00:00:00 2001 From: ainame Date: Wed, 15 Jan 2025 12:14:06 +0000 Subject: [PATCH 1/2] Support Bundle.module in hostingBundle option --- Sources/RswiftCore/Util/Struct+InternalProperties.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sources/RswiftCore/Util/Struct+InternalProperties.swift b/Sources/RswiftCore/Util/Struct+InternalProperties.swift index 7cc9eaae..7b1e00ca 100644 --- a/Sources/RswiftCore/Util/Struct+InternalProperties.swift +++ b/Sources/RswiftCore/Util/Struct+InternalProperties.swift @@ -11,7 +11,10 @@ import Foundation extension Struct { func addingInternalProperties(forBundleIdentifier bundleIdentifier: String, hostingBundle: String? = nil) -> Struct { let hostingBundleValue: String - if let bundleName = hostingBundle, !bundleName.isEmpty { + // This case is extended by the fork cookpad/R.swift to support SPM + if let bundleName = hostingBundle, bundleName == "Bundle.module" { + hostingBundleValue = "Bundle.module" + } else if let bundleName = hostingBundle, !bundleName.isEmpty { hostingBundleValue = "Bundle(for: R.Class.self).path(forResource: \"\(bundleName)\", ofType: \"bundle\").flatMap(Bundle.init(path:)) ?? Bundle(for: R.Class.self)" } else { hostingBundleValue = "Bundle(for: R.Class.self)" From ac19bb6d3f037132a6c765f4a48909bbcc1a7d0d Mon Sep 17 00:00:00 2001 From: ainame Date: Mon, 3 Mar 2025 20:56:19 +0000 Subject: [PATCH 2/2] Support iOS from iOS 16 --- Package.swift | 4 ++-- Sources/RswiftCore/Util/Struct+InternalProperties.swift | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Package.swift b/Package.swift index 4cd7c034..deaac044 100644 --- a/Package.swift +++ b/Package.swift @@ -1,10 +1,10 @@ -// swift-tools-version:5.0 +// swift-tools-version:5.7 import PackageDescription let package = Package( name: "rswift", platforms: [ - .macOS(.v10_11) + .iOS(.v16) ], products: [ .executable(name: "rswift", targets: ["rswift"]) diff --git a/Sources/RswiftCore/Util/Struct+InternalProperties.swift b/Sources/RswiftCore/Util/Struct+InternalProperties.swift index 7b1e00ca..ee1e1806 100644 --- a/Sources/RswiftCore/Util/Struct+InternalProperties.swift +++ b/Sources/RswiftCore/Util/Struct+InternalProperties.swift @@ -85,12 +85,12 @@ extension Struct { .prefix(1) .flatMap { locale -> [String] in if hostingBundle.localizations.contains(locale.identifier) { - if let language = locale.languageCode, hostingBundle.localizations.contains(language) { + if let language = locale.language.languageCode?.identifier, hostingBundle.localizations.contains(language) { return [locale.identifier, language] } else { return [locale.identifier] } - } else if let language = locale.languageCode, hostingBundle.localizations.contains(language) { + } else if let language = locale.language.languageCode?.identifier, hostingBundle.localizations.contains(language) { return [language] } else { return []