Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Native Moduleの作り方 / Creating Native Module in R...
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Tatsuya Kitagawa
February 26, 2020
Programming
790
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Native Moduleの作り方 / Creating Native Module in React Native
https://ducklings.connpass.com/event/164844/
の発表資料です。
Tatsuya Kitagawa
February 26, 2020
More Decks by Tatsuya Kitagawa
See All by Tatsuya Kitagawa
LiveData with RxJava2
yatatsu
0
800
Other Decks in Programming
See All in Programming
Vibes Containers 〜AIで変わるコンテナ設計と運用〜
tkikuc
1
470
【デモ】Kiroで体験する仕様駆動開発|設計からコーディングまでAIと進める開発フロー
cmkudo
0
570
Go 1.27からのGODEBUG / Go 1.27 リリースパーティ #go127party
mazrean
0
300
[PyCon KR 2026] More Variants, More Diversity for AI Accelerators
achimnol
0
130
変化を抱擁するドキュメントの作り方 - ビジネスルール駆動開発がもたらす、コードとの新しい関係
ioki
2
110
MySQLとPostgreSQLって何が違うの?
akagami
PRO
0
160
不幸な GC
chencmd
0
870
{ Android | Kotlin } Gradle Plugin in 2026
ryunen344
1
280
My Marp Sample
sinoue0108
0
140
数年滞っていたダークモード対応をおよそ2週間で完了させる
chigichan24
0
670
自分的「カンファレンスの楽しみ方」
syumai
0
190
バグを直したら useEffect が消えた
colorful12
3
830
Featured
See All Featured
Crafting Experiences
bethany
1
280
Building Applications with DynamoDB
mza
96
7.2k
Building Flexible Design Systems
yeseniaperezcruz
330
41k
Navigating Team Friction
lara
192
16k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
Skip the Path - Find Your Career Trail
mkilby
1
220
How to train your dragon (web standard)
notwaldorf
97
6.8k
Navigating Weather and Climate Data
rabernat
0
510
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.9k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Transcript
Native Module ͷ࡞Γํ React Native Tech Blog meetup#1 2020-02-26
About me? • ୡʢTatsuya KITAGAWAʣ • PAY.JP • https:#//github.com/yatatsu
• https:#//twitter.com/tatsuyakit
About PAY.JP • https:#//pay.jp/ • γϯϓϧͰΘ͔Γ͍͢APIΛఏڙ͢ΔܾࡁαʔϏε • ڝ߹ͷαʔϏεͱͯ͠StripeͳͲ͕͋Γ·͢ • React
Native͚ͷSDKϓϥάΠϯΛެ։͠·ͨ͠ http:#//payjp-announce.hatenablog.com/entry/2020/02/14/113211
Native Modules? (1/2) • ඪ४Ͱଟ͘ͷωΠςΟϒͷػೳ͕ར༻Ͱ͖Δ • Alert.alert(…)ͰΞϥʔτ͕දࣔ͞ΕΔͱ͔ • ඪ४Ͱ༻ҙ͞Ε͍ͯͳ͍ωΠςΟϒͷػೳΛར༻͍ͨ͠ •
ಉ͡Α͏ʹJS͔Βར༻Ͱ͖ΔΑ͏ʹ͢ΔΈ
Native Modules? (2/2) • react-native-community/react-native-webview • react-native-community/react-native-maps • ϥΠϒϥϦͱͯ͠ఏڙ͞Ε͍ͯΔͷ͕ଟ •
͜ΕΒΛ࡞ΔଆͷΛ͠·͢
CLI tools (1/3) • brodybits/create-react-native-module • react-native-community/bob • frostney/react-native-create-library •
peggyrayzis/react-native-create-bridge
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 • LinterFormatterͳͲͷॳظઃఆ·Ͱ͓·͔ͤ "-> react-native-community/bob
CLI tools (3/3) • `npx create-react-native-module MyLibrary` • ϓϩδΣΫτͷܗ͕࡞͞ΕΔ
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
Auto Linking (1/2) • RN 0.60ΑΓಋೖ͞ΕͨAutoLinking • `react-native config`ͰಘΒΕΔ ϓϩδΣΫτͷϝλใΛར༻ͯ͠Link͢Δ
• https:#//github.com/react-native-community/ cli/blob/master/docs/autolinking.md
Auto Linking (2/2) • σΟϨΫτϦߏσϑΥϧτͷconfigʹҰக • *.podspec͕ϓϩδΣΫτԼʹ͋Δ etc. • มߋ͢Δ߹
react-native.config.js ΛՃ
react-native.config.js const path = require('path'); module.exports = { dependency: {
platforms: { ios: { podspecPath: path.join(#__dirname, 'ios', 'my.podspec') } } } };
tips:1 Xcode (1/4) • iOSωΠςΟϒͷ։ൃ͢Δͱ͖Xcode͕ศར • ͔͠͠ϥΠϒϥϦͷϓϩδΣΫτΛͦͷ··ಡΈࠐΉͱ…
tips:1 Xcode (2/4) • iOSωΠςΟϒͷ։ൃ͢Δͱ͖Xcode͕ศར • ͔͠͠ϥΠϒϥϦͷϓϩδΣΫτΛͦͷ··ಡΈࠐΉͱ…
tips:1 Xcode (3/4) • example/ios/example.xcworkspace Λ։͘ ʢpod install͔ͯ͠Βʣ
tips:1 Android Studio (4/4) • example/android/build.gradle Λ։͘
tips:2 Sync modules (1/2) • ios/ android/ Λมߋͯ͠ • ಈ࡞֬ೝexampleҎԼͰ͓͜ͳ͏
• ຖճ yarn install ͢͠ͷ͕͔͔࣌ؒΔ
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
·ͱΊ • Native ModuleΛ։ൃ͢ΔࡍCLIπʔϧ͕ศར • XcodeAndroid StudioͰ։ൃ͢Δ • ࡉ͔͍։ൃͷTipsଞͷOSS͕ࢀߟʹͳΔ •
ಛʹ react-native-community ͕๛
Blog • Native Moduleͷ࡞Γํ - React Native Tech Blog https:#//tech.maricuru.com/entry/2020/02/20/052054