Skip to content

Commit a6ca825

Browse files
authored
fix: use resource_bundles when FLUENT_ICONS_USE_RESOURCE_BUNDLES=1 (#839)
1 parent a2dc301 commit a6ca825

3 files changed

Lines changed: 24 additions & 5 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,6 @@ packages/react-native-icons/package-lock.json
4242
# Some Fluent tooling generates this for internal tracking assistance. Make sure it doesn't get committed.
4343
SvgList.txt
4444

45-
.venv
45+
.venv
46+
47+
.build

ios/FluentIcons.podspec

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,19 @@ FluentIcons
3333
end
3434

3535
s.subspec 'Assets' do |sp|
36-
# Require this to be used as a dynamic framework
37-
# `resource_bundles` are unable to load around 1 in a thousand times
38-
# so we need to stick to `resources` here instead.
39-
sp.resource = 'ios/FluentIcons/Assets/IconAssets.xcassets'
36+
if ENV['FLUENT_ICONS_USE_RESOURCE_BUNDLES'] == '1'
37+
sp.resource_bundles = {
38+
'FluentIcons' => ['ios/FluentIcons/Assets/IconAssets.xcassets']
39+
}
40+
sp.pod_target_xcconfig = {
41+
'OTHER_SWIFT_FLAGS' => '-DFLUENT_ICONS_USE_RESOURCE_BUNDLES'
42+
}
43+
else
44+
# Require this to be used as a dynamic framework
45+
# `resource_bundles` are unable to load around 1 in a thousand times
46+
# so we need to stick to `resources` here instead.
47+
sp.resource = 'ios/FluentIcons/Assets/IconAssets.xcassets'
48+
end
4049
end
4150

4251
s.subspec 'RemovalScript' do |sp|

ios/FluentIcons/Classes/Image+FluentIcon.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ import AppKit
99
private class FluentIconsBundleCheck {}
1010

1111
public extension NSImage {
12+
#if FLUENT_ICONS_USE_RESOURCE_BUNDLES
13+
@objc static let fluentIconBundle = Bundle(path: Bundle(for: FluentIconsBundleCheck.self).path(forResource: "FluentIcons", ofType: "bundle")!)
14+
#else
1215
@objc static let fluentIconBundle = Bundle(for: FluentIconsBundleCheck.self)
16+
#endif
1317

1418
@objc static func fluentIcon(_ fluent: FluentIcon) -> NSImage {
1519
// Force unwrap here because the resource strings
@@ -31,7 +35,11 @@ import UIKit
3135
private class FluentIconsBundleCheck {}
3236

3337
public extension UIImage {
38+
#if FLUENT_ICONS_USE_RESOURCE_BUNDLES
39+
@objc static let fluentIconBundle = Bundle(path: Bundle(for: FluentIconsBundleCheck.self).path(forResource: "FluentIcons", ofType: "bundle")!)
40+
#else
3441
@objc static let fluentIconBundle = Bundle(for: FluentIconsBundleCheck.self)
42+
#endif
3543

3644
@objc convenience init(fluent: FluentIcon) {
3745
// Force unwrap here because the resource strings

0 commit comments

Comments
 (0)