Buck sounds like a great tool for both iOS and Android projects but I have not been abel to find any information on how to use it for react-native projects.
Update 8/6/2017:
I tried following my steps below for integrating React Native into an iOS app with Buck but I ran into issues when using React Native 0.47. Instead I have a new simpler approach for getting React Native working with Buck on iOS by linking to prebuilt libraries. I forked the Buck sample project repo and have it working with React Native in this repo. I also updated the README in that repo with instructions for running the demo Buck React Native iOS app and how to integrate yourself.
Note there are a couple issues with this approach documented in the README that may or may not be a problem for using this in a production app.
That repo also doesn't bundle the JS for production yet.
Older answer:
I got Buck working with an iOS project. It is very much a work in progress, but works. A few notes:
node_modules/react-native/React
and
node_modules/react-native/Libraries
(see folder structure below).-w
and Wno-error
flags to each library because the main project had treat warnings as errors and I didn't want to see all of these React Native warnings in Xcode.reactnative.xcodeproj
in the vendor/reactnative
folder (see below).Here is my vendor/reactnative/BUCK
file:
apple_library(
name = 'ReactNative',
srcs = glob([
'React/**/*.m',
'React/**/*.mm',
'React/**/*.c',
'React/**/*.S',
]),
exported_headers = glob([
'React/**/*.h',
]),
system_frameworks = [
'JavaScriptCore'
],
exported_linker_flags = [
'-lc++',
],
compiler_flags = [
'-Wno-error',
'-w'
],
visibility = ['PUBLIC'],
)
apple_library(
name = 'RCTWebSocket',
srcs = glob([
'Libraries/WebSocket/*.m',
]),
headers = glob([
'React/**/*.h',
]),
exported_headers = glob([
'Libraries/WebSocket/*.h',
]),
compiler_flags = [
'-Wno-error',
'-w'
],
visibility = ['PUBLIC'],
deps = [
':ReactNative',
]
)
apple_library(
name = 'RCTNetwork',
srcs = glob([
'Libraries/Network/*.m',
]),
headers = glob([
'React/**/*.h',
]),
exported_headers = glob([
'Libraries/Network/*.h',
]),
compiler_flags = [
'-Wno-error',
'-w'
],
visibility = ['PUBLIC'],
deps = [
':ReactNative',
]
)
apple_library(
name = 'RCTText',
srcs = glob([
'Libraries/Text/*.m',
]),
headers = glob([
'React/**/*.h',
]),
exported_headers = glob([
'Libraries/Text/*.h',
]),
compiler_flags = [
'-Wno-error',
'-w'
],
visibility = ['PUBLIC'],
deps = [
':ReactNative',
]
)
apple_library(
name = 'RCTImage',
srcs = glob([
'Libraries/Image/*.m',
]),
headers = glob([
'React/**/*.h',
'Libraries/Network/*.h'
]),
exported_headers = glob([
'Libraries/Image/*.h',
]),
compiler_flags = [
'-Wno-error',
'-w'
],
visibility = ['PUBLIC'],
deps = [
':ReactNative',
':RCTNetwork'
]
)
Here is the folder structure inside a vendor folder in my project:
vendor/reactnative
├── BUCK
├── Libraries
│ ├── ART
│ ├── ActionSheetIOS
│ ├── AdSupport
│ ├── Animated
│ ├── AppRegistry
│ ├── AppState
│ ├── BatchedBridge
│ ├── BugReporting
│ ├── CameraRoll
│ ├── Components
│ ├── CustomComponents
│ ├── DebugComponentHierarchy
│ ├── Devtools
│ ├── EventEmitter
│ ├── Experimental
│ ├── Fetch
│ ├── Geolocation
│ ├── Image
│ ├── Inspector
│ ├── Interaction
│ ├── JavaScriptAppEngine
│ ├── LayoutAnimation
│ ├── Linking
│ ├── LinkingIOS
│ ├── Modal
│ ├── NativeAnimation
│ ├── NavigationExperimental
│ ├── Network
│ ├── Promise.js
│ ├── PushNotificationIOS
│ ├── QuickPerformanceLogger
│ ├── RCTTest
│ ├── RKBackendNode
│ ├── ReactIOS
│ ├── ReactNative
│ ├── Sample
│ ├── Settings
│ ├── Storage
│ ├── StyleSheet
│ ├── Text
│ ├── Utilities
│ ├── Vibration
│ ├── WebSocket
│ ├── promiseRejectionIsError.js
│ ├── react-native
│ └── vendor
├── React
│ ├── Base
│ ├── Executors
│ ├── Layout
│ ├── Modules
│ ├── Profiler
│ └── Views
└── reactnative.xcodeproj
├── project.pbxproj
└── xcuserdata
Then in the deps
of my main BUCK file I add:
'//vendor/reactnative:ReactNative',
'//vendor/reactnative:RCTWebSocket',
'//vendor/reactnative:RCTText',
'//vendor/reactnative:RCTNetwork',
'//vendor/reactnative:RCTImage'
There's no official documentation / template for building RN apps with Buck yet but it shouldn't be that hard. You'd need to add a BUCK file that does the equivalent of what your build.gradle file does.
It's mostly just: