Skip to content

Commit 5d6cf94

Browse files
authored
Merge pull request #304 from mohssenfathi/bundle-utility
Adds Bundle utility
2 parents cdb6394 + 60faf70 commit 5d6cf94

File tree

6 files changed

+64
-7
lines changed

6 files changed

+64
-7
lines changed

Sources/UberAuth/Button/LoginButton.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public final class LoginButton: UberButton {
9494
override public var image: UIImage? {
9595
UIImage(
9696
named: "uber_logo_white",
97-
in: .module,
97+
in: .resource(for: LoginButton.self),
9898
compatibleWith: nil
9999
)?.withRenderingMode(.alwaysTemplate)
100100
}
@@ -145,14 +145,14 @@ public final class LoginButton: UberButton {
145145
case .loggedIn:
146146
return NSLocalizedString(
147147
"Sign Out",
148-
bundle: .module,
148+
bundle: .resource(for: LoginButton.self),
149149
comment: "Login Button Sign Out Description"
150150
)
151151
.uppercased()
152152
case .loggedOut:
153153
return NSLocalizedString(
154154
"Sign In",
155-
bundle: .module,
155+
bundle: .resource(for: LoginButton.self),
156156
comment: "Login Button Sign In Description"
157157
)
158158
.uppercased()
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// Copyright © Uber Technologies, Inc. All rights reserved.
3+
//
4+
5+
6+
import Foundation
7+
8+
extension Bundle {
9+
10+
static func resource(for targetClass: AnyClass?) -> Bundle {
11+
#if SWIFT_PACKAGE
12+
return .module
13+
#endif
14+
if let targetClass {
15+
return Bundle(for: targetClass)
16+
}
17+
return .main
18+
}
19+
}

Sources/UberCore/Colors.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ extension UIColor {
99

1010
static let uberButtonBackground: UIColor = UIColor(
1111
named: "UberButtonBackground",
12-
in: .module,
12+
in: .resource(for: UberButton.self),
1313
compatibleWith: nil
1414
) ?? UIColor.darkText
1515

1616
static let uberButtonHighlightedBackground: UIColor = UIColor(
1717
named: "UberButtonHighlightedBackground",
18-
in: .module,
18+
in: .resource(for: UberButton.self),
1919
compatibleWith: nil
2020
) ?? UIColor.darkText
2121

2222
static let uberButtonForeground: UIColor = UIColor(
2323
named: "UberButtonForeground",
24-
in: .module,
24+
in: .resource(for: UberButton.self),
2525
compatibleWith: nil
2626
) ?? UIColor.lightText
2727
}
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// Copyright © Uber Technologies, Inc. All rights reserved.
3+
//
4+
5+
6+
import Foundation
7+
8+
extension Bundle {
9+
10+
static func resource(for targetClass: AnyClass?) -> Bundle {
11+
#if SWIFT_PACKAGE
12+
return .module
13+
#endif
14+
if let targetClass {
15+
return Bundle(for: targetClass)
16+
}
17+
return .main
18+
}
19+
}

Sources/UberRides/RideRequestButton.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ public class RideRequestButton: UberButton_DEPRECATED {
466466

467467
// get image from media directory
468468
private func getImage(name: String) -> UIImage {
469-
let image = UIImage(named: name, in: Bundle.module, compatibleWith: nil)
469+
let image = UIImage(named: name, in: .resource(for: RideRequestButton.self), compatibleWith: nil)
470470
return image!
471471
}
472472
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// Copyright © Uber Technologies, Inc. All rights reserved.
3+
//
4+
5+
6+
import Foundation
7+
8+
extension Bundle {
9+
10+
static func resource(for targetClass: AnyClass?) -> Bundle {
11+
#if SWIFT_PACKAGE
12+
return .module
13+
#endif
14+
if let targetClass {
15+
return Bundle(for: targetClass)
16+
}
17+
return .main
18+
}
19+
}

0 commit comments

Comments
 (0)