File tree Expand file tree Collapse file tree 6 files changed +54
-1
lines changed
examples/resources_example
third_party/implicit_resource_localization Expand file tree Collapse file tree 6 files changed +54
-1
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ let package = Package(
77 dependencies: [
88 . package ( path: " ../third_party/another_package_with_resources " ) ,
99 . package ( path: " ../third_party/app_lovin_sdk " ) ,
10+ . package ( path: " ../third_party/implicit_resource_localization " ) ,
1011 . package ( path: " ../third_party/package_with_resources " ) ,
1112 . package ( path: " ../third_party/package_with_resources_swift_6 " ) ,
1213 . package ( url: " https://github.com/Iterable/swift-sdk " , from: " 6.5.12 " ) ,
Original file line number Diff line number Diff line change 1+ // swift-tools-version: 6.1
2+ // The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+ import PackageDescription
5+
6+ let package = Package (
7+ name: " implicit_resource_localization " ,
8+ defaultLocalization: " en " ,
9+ products: [
10+ . library( name: " implicit_resource_localization " , targets: [ " implicit_resource_localization " ] ) ,
11+ ] ,
12+ targets: [
13+ . target( name: " implicit_resource_localization " ) ,
14+ ]
15+ )
Original file line number Diff line number Diff line change 1+ This package includes resources with implicit localizations using a ` .lproj ` resource folder.
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <document type =" com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version =" 3.0" toolsVersion =" 17150" targetRuntime =" MacOSX.Cocoa" propertyAccessControl =" none" useAutolayout =" YES" >
3+ <dependencies >
4+ <plugIn identifier =" com.apple.InterfaceBuilder.CocoaPlugin" version =" 17150" />
5+ <capability name =" documents saved in the Xcode 8 format" minToolsVersion =" 8.0" />
6+ </dependencies >
7+ <scenes >
8+ <!-- View Controller-->
9+ <scene sceneID =" PEd-7d-5j0" >
10+ <objects >
11+ <viewController id =" bU7-R8-ocO" sceneMemberID =" viewController" >
12+ <view key =" view" id =" tOy-S4-hL0" >
13+ <rect key =" frame" x =" 0.0" y =" 0.0" width =" 450" height =" 300" />
14+ <autoresizingMask key =" autoresizingMask" />
15+ </view >
16+ </viewController >
17+ <customObject id =" 9uD-mB-xHs" userLabel =" First Responder" customClass =" NSResponder" sceneMemberID =" firstResponder" />
18+ </objects >
19+ </scene >
20+ </scenes >
21+ </document >
Original file line number Diff line number Diff line change 1+ // Stub file to make SPM happy
Original file line number Diff line number Diff line change @@ -1680,10 +1680,24 @@ def _new_resource_from_discovered_resource(path):
16801680 return _new_resource (
16811681 path = path ,
16821682 rule = _new_resource_rule (
1683- process = _new_resource_rule_process (),
1683+ process = _new_resource_rule_process (
1684+ localization = _localization_from (path ),
1685+ ),
16841686 ),
16851687 )
16861688
1689+ def _localization_from (path ):
1690+ # Extract the implict localization from the path if its parent folder ends in ".lproj"
1691+ # https://github.com/swiftlang/swift-package-manager/blob/2f03e7a16e2c4d08a3a16f16cca627ff53b70271/Sources/PackageLoading/TargetSourcesBuilder.swift#L312-L318
1692+ parent_dir = paths .basename (paths .dirname (path ))
1693+
1694+ (localization , extension ) = paths .split_extension (parent_dir )
1695+
1696+ if extension == ".lproj" :
1697+ return localization
1698+
1699+ return None
1700+
16871701# MARK: - Constants
16881702
16891703target_types = struct (
You can’t perform that action at this time.
0 commit comments