Skip to content

Commit 900be84

Browse files
committed
feat: macos ci
1 parent 0ddcf00 commit 900be84

File tree

6 files changed

+97
-34
lines changed

6 files changed

+97
-34
lines changed

.github/workflows/ci.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,49 @@ jobs:
242242
- name: Build example for iOS
243243
run: |
244244
yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}"
245+
246+
build-macos:
247+
runs-on: macos-15
248+
env:
249+
TURBO_CACHE_DIR: .turbo/macos
250+
steps:
251+
- name: Checkout
252+
uses: actions/checkout@v3
253+
254+
- name: Setup
255+
uses: ./.github/actions/setup
256+
257+
- name: Build package
258+
run: yarn build
259+
260+
- name: Install xcbeautify
261+
run: |
262+
brew install xcbeautify
263+
264+
- name: Cache turborepo for macOS
265+
uses: actions/cache@v3
266+
with:
267+
path: ${{ env.TURBO_CACHE_DIR }}
268+
key: ${{ runner.os }}-turborepo-macos-${{ hashFiles('yarn.lock') }}
269+
restore-keys: |
270+
${{ runner.os }}-turborepo-macos-
271+
272+
- name: Check turborepo cache for macOS
273+
run: |
274+
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:macos --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:macos').cache.status")
275+
276+
if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
277+
echo "turbo_cache_hit=1" >> $GITHUB_ENV
278+
fi
279+
280+
- name: Install cocoapods
281+
if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true'
282+
run: |
283+
cd apps/example
284+
pod install --project-directory=macos
285+
env:
286+
NO_FLIPPER: 1
287+
288+
- name: Build example for macOS
289+
run: |
290+
yarn turbo run build:macos --cache-dir="${{ env.TURBO_CACHE_DIR }}"

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"build:android": "turbo run build:android",
1717
"build:android:fabric": "turbo run build:android:fabric",
1818
"build:ios": "turbo run build:ios",
19+
"build:macos": "turbo run build:macos",
1920
"build:ios-expo": "turbo run build:ios-expo",
2021
"build:android-expo": "turbo run build:android-expo",
2122
"publish-packages": "turbo run build lint && changeset version && changeset publish"

packages/react-native-bottom-tabs/ios/RCTTabViewViewManager.mm

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
#import <React/RCTUIManager.h>
33
#import <React/RCTImageLoader.h>
44
#import <React/RCTBridge.h>
5-
#if TARGET_OS_OSX
6-
#import <React/RCTUIKit.h>
7-
#endif
85

96
#if TARGET_OS_OSX
107
#import <AppKit/AppKit.h>

packages/react-native-bottom-tabs/ios/TabViewImpl.swift

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ struct TabViewImpl: View {
1414
#else
1515
@Weak var tabBar: UITabBar?
1616
#endif
17-
17+
1818
var onSelect: (_ key: String) -> Void
1919
var onLongPress: (_ key: String) -> Void
2020
var onLayout: (_ size: CGSize) -> Void
2121
var onTabBarMeasured: (_ height: Int) -> Void
22-
22+
2323
var body: some View {
2424
TabView(selection: $props.selectedPage) {
2525
ForEach(props.children.indices, id: \.self) { index in
@@ -34,7 +34,7 @@ struct TabViewImpl: View {
3434
guard let key = props.items.filter({
3535
!$0.hidden || $0.key == props.selectedPage
3636
})[safe: index]?.key else { return }
37-
37+
3838
if isLongPress {
3939
onLongPress(key)
4040
emitHapticFeedback(longPress: true)
@@ -73,17 +73,17 @@ struct TabViewImpl: View {
7373
#endif
7474
}
7575
}
76-
76+
7777
@ViewBuilder
7878
private func renderTabItem(at index: Int) -> some View {
7979
let tabData = props.items[safe: index]
8080
let isHidden = tabData?.hidden ?? false
8181
let isFocused = props.selectedPage == tabData?.key
82-
82+
8383
if !isHidden || isFocused {
8484
let child = props.children[safe: index] ?? PlatformView()
8585
let icon = props.icons[index]
86-
86+
8787
RepresentableView(view: child)
8888
.ignoresTopSafeArea(
8989
props.ignoresTopSafeArea,
@@ -103,7 +103,7 @@ struct TabViewImpl: View {
103103
#if !os(macOS)
104104
updateTabBarAppearance(props: props, tabBar: tabBar)
105105
#endif
106-
106+
107107
#if os(iOS)
108108
guard index >= 4,
109109
let key = tabData?.key,
@@ -113,13 +113,13 @@ struct TabViewImpl: View {
113113
}
114114
}
115115
}
116-
116+
117117
func emitHapticFeedback(longPress: Bool = false) {
118118
#if os(iOS)
119119
if !props.hapticFeedbackEnabled {
120120
return
121121
}
122-
122+
123123
if longPress {
124124
UINotificationFeedbackGenerator().notificationOccurred(.success)
125125
} else {
@@ -132,12 +132,12 @@ struct TabViewImpl: View {
132132
#if !os(macOS)
133133
private func updateTabBarAppearance(props: TabViewProps, tabBar: UITabBar?) {
134134
guard let tabBar else { return }
135-
135+
136136
if props.scrollEdgeAppearance == "transparent" {
137137
configureTransparentAppearance(tabBar: tabBar, props: props)
138138
return
139139
}
140-
140+
141141
configureStandardAppearance(tabBar: tabBar, props: props)
142142
}
143143
#endif
@@ -149,8 +149,8 @@ private func createFontAttributes(
149149
inactiveTintColor: PlatformColor?
150150
) -> [NSAttributedString.Key: Any] {
151151
var attributes: [NSAttributedString.Key: Any] = [:]
152-
153-
152+
153+
154154
if family != nil || weight != nil {
155155
attributes[.font] = RCTFont.update(
156156
nil,
@@ -164,7 +164,7 @@ private func createFontAttributes(
164164
} else {
165165
attributes[.font] = UIFont.boldSystemFont(ofSize: size)
166166
}
167-
167+
168168
return attributes
169169
}
170170

@@ -180,25 +180,25 @@ private func configureTransparentAppearance(tabBar: UITabBar, props: TabViewProp
180180
tabBar.barTintColor = props.barTintColor
181181
tabBar.isTranslucent = props.translucent
182182
tabBar.unselectedItemTintColor = props.inactiveTintColor
183-
183+
184184
guard let items = tabBar.items else { return }
185-
185+
186186
let fontSize = props.fontSize != nil ? CGFloat(props.fontSize!) : tabBarDefaultFontSize
187187
let attributes = createFontAttributes(
188188
size: fontSize,
189189
family: props.fontFamily,
190190
weight: props.fontWeight,
191191
inactiveTintColor: nil
192192
)
193-
193+
194194
items.forEach { item in
195195
item.setTitleTextAttributes(attributes, for: .normal)
196196
}
197197
}
198198

199199
private func configureStandardAppearance(tabBar: UITabBar, props: TabViewProps) {
200200
let appearance = UITabBarAppearance()
201-
201+
202202
// Configure background
203203
switch props.scrollEdgeAppearance {
204204
case "opaque":
@@ -207,33 +207,33 @@ private func configureStandardAppearance(tabBar: UITabBar, props: TabViewProps)
207207
appearance.configureWithDefaultBackground()
208208
}
209209
appearance.backgroundColor = props.barTintColor
210-
210+
211211
// Configure item appearance
212212
let itemAppearance = UITabBarItemAppearance()
213213
let fontSize = props.fontSize != nil ? CGFloat(props.fontSize!) : tabBarDefaultFontSize
214-
214+
215215
var attributes = createFontAttributes(
216216
size: fontSize,
217217
family: props.fontFamily,
218218
weight: props.fontWeight,
219219
inactiveTintColor: props.inactiveTintColor
220220
)
221-
221+
222222
if let inactiveTintColor = props.inactiveTintColor {
223223
attributes[.foregroundColor] = inactiveTintColor
224224
}
225-
225+
226226
if let inactiveTintColor = props.inactiveTintColor {
227227
itemAppearance.normal.iconColor = inactiveTintColor
228228
}
229-
229+
230230
itemAppearance.normal.titleTextAttributes = attributes
231-
231+
232232
// Apply item appearance to all layouts
233233
appearance.stackedLayoutAppearance = itemAppearance
234234
appearance.inlineLayoutAppearance = itemAppearance
235235
appearance.compactInlineLayoutAppearance = itemAppearance
236-
236+
237237
// Apply final appearance
238238
tabBar.standardAppearance = appearance
239239
if #available(iOS 15.0, *) {
@@ -259,7 +259,7 @@ extension View {
259259
self
260260
}
261261
}
262-
262+
263263
@ViewBuilder
264264
func tabBadge(_ data: String?) -> some View {
265265
if #available(iOS 15.0, macOS 15.0, visionOS 2.0, tvOS 15.0, *) {
@@ -276,7 +276,7 @@ extension View {
276276
self
277277
}
278278
}
279-
279+
280280
@ViewBuilder
281281
func ignoresTopSafeArea(
282282
_ flag: Bool,
@@ -290,7 +290,7 @@ extension View {
290290
.ignoresSafeArea(.container, edges: .bottom)
291291
}
292292
}
293-
293+
294294
#if !os(macOS)
295295
@ViewBuilder
296296
func configureAppearance(props: TabViewProps, tabBar: UITabBar?) -> some View {
@@ -321,7 +321,7 @@ extension View {
321321
}
322322
}
323323
#endif
324-
324+
325325
@ViewBuilder
326326
func tintColor(_ color: PlatformColor?) -> some View {
327327
if let color {
@@ -335,7 +335,7 @@ extension View {
335335
self
336336
}
337337
}
338-
338+
339339
// Allows TabView to use unfilled SFSymbols.
340340
// By default they are always filled.
341341
@ViewBuilder

packages/react-native-bottom-tabs/react-native-bottom-tabs.podspec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ Pod::Spec.new do |s|
1212
s.license = package["license"]
1313
s.authors = package["author"]
1414

15-
s.platforms = { :ios => "14.0", :visionos => "1.0", :tvos => "15.1", :macos => "11.0" }
15+
s.ios.deployment_target = "14.0"
16+
s.visionos.deployment_target = "1.0"
17+
s.tvos.deployment_target = "15.1"
18+
s.osx.deployment_target = "11.0"
19+
1620
s.source = { :git => "https://github.com/okwasniewski/react-native-bottom-tabs.git", :tag => "#{s.version}" }
1721

1822
s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"

turbo.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,21 @@
7373
],
7474
"outputs": []
7575
},
76+
"build:macos": {
77+
"env": ["RCT_NEW_ARCH_ENABLED"],
78+
"inputs": [
79+
"packages/*/package.json",
80+
"packages/*/*.podspec",
81+
"packages/*/ios",
82+
"packages/*/src/*.ts",
83+
"packages/*/src/*.tsx",
84+
"apps/example/package.json",
85+
"apps/example/macos",
86+
"!apps/example/macos/build",
87+
"!apps/example/macos/Pods"
88+
],
89+
"outputs": []
90+
},
7691
"build:ios-expo": {
7792
"env": ["RCT_NEW_ARCH_ENABLED"],
7893
"inputs": [

0 commit comments

Comments
 (0)