Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Native Moduleの作り方 / Creating Native Module in R...

Native Moduleの作り方 / Creating Native Module in React Native

Tatsuya Kitagawa

February 26, 2020
Tweet

More Decks by Tatsuya Kitagawa

Other Decks in Programming

Transcript

  1. About PAY.JP • https:#//pay.jp/ • γϯϓϧͰΘ͔Γ΍͍͢APIΛఏڙ͢ΔܾࡁαʔϏε • ڝ߹ͷαʔϏεͱͯ͠StripeͳͲ͕͋Γ·͢ • React

    Native޲͚ͷSDKϓϥάΠϯΛެ։͠·ͨ͠
 http:#//payjp-announce.hatenablog.com/entry/2020/02/14/113211
  2. CLI tools (2/3) • ެࣜυΩϡϝϯτͰ͸create-react-native-module • “To get set up

    with the basic project structure for a native module we will use a third party tool 
 create-react-native-module” • ͓͢͢Ί͸࠷খݶͷߏ੒͕΄͍͠ͳΒ
 "-> create-react-native-module • Linter΍FormatterͳͲͷॳظઃఆ·Ͱ͓·͔ͤ
 "-> react-native-community/bob
  3. react-native-my-library/ "## README.md "## android $ "## README.md $ "##

    build.gradle $ &## src $ &## main $ "## AndroidManifest.xml $ &## java $ &## com $ &## reactlibrary $ "## MyLibraryModule.java $ &## MyLibraryPackage.java "## index.js "## ios $ "## MyLibrary.h $ "## MyLibrary.m $ "## MyLibrary.xcodeproj $ $ &## project.pbxproj $ &## MyLibrary.xcworkspace $ &## contents.xcworkspacedata "## package.json &## react-native-my-library.podspec
  4. react-native.config.js const path = require('path'); module.exports = { dependency: {

    platforms: { ios: { podspecPath: path.join(#__dirname, 'ios', 'my.podspec') } } } };
  5. tips:2
 Sync modules (2/2) "scripts": { "dev-sync": "cp -r *podspec

    android ios example/ node_modules/react-native-my-library/“ }, • ର৅ͷίʔυ͚ͩࠩ͠ସ͑Δ • react-native-community/react-native-share