C4iOS icon indicating copy to clipboard operation
C4iOS copied to clipboard

React-native import

Open boyswan opened this issue 8 years ago • 2 comments

I'm pretty new to Swift, so please bare with!

Is it possible with c4 to 'export' as a project (I think with a .framework...?), to be imported into other xcode projects?

I've been referencing Swift -> React Native via this tutorial http://browniefed.com/blog/react-native-how-to-bridge-a-swift-view/

However am unsure whether C4 can be used like this, or whether it was intended for standalone use only.

boyswan avatar Jul 29 '16 11:07 boyswan

Hey boyswan, I haven't had a look at react-native. I'll read through this article tonight and post an answer.

Apologies for the long delay in responding to your question. I was on vacation for a few weeks, and then took some time to get caught up with everything.

traviskirton avatar Aug 16 '16 23:08 traviskirton

From what I see on the tutorial you linked, C4 can be used like this.

We actually suggest building your projects by compiling C4 into a framework, so we're already achieving this step.

The real work is in creating the bindings... i.e. everything that allows you to get to doing this kind of stuff:

import React, { requireNativeComponent, processColor } from 'react-native';
let RNLinearGradient = requireNativeComponent('RNLinearGradientSwift', LinearGradient);
class LinearGradient extends React.Component {
  render() {
    let { colors, ...otherProps } = this.props;
    return <RNLinearGradient {...otherProps} colors={processColor(colors)} />;
  }
}
LinearGradient.propTypes = {
  colors: React.PropTypes.array.isRequired,
  locations: React.PropTypes.array,
}
export default LinearGradient;

I'd love to see C4 working with react native.

traviskirton avatar Aug 18 '16 08:08 traviskirton