Skip to content

React-native import #679

Open
Open

Description

@boyswan

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.

Activity

  1. traviskirton commented on Aug 16, 2016

    @traviskirton
    Collaborator

    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.

  2. traviskirton commented on Aug 18, 2016

    @traviskirton
    Collaborator

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions