DanMotzenbecker,MITLicense@dcmotz
Natalisasimplecommand-lineutilitythatautomatesmostoftheprocessofsettingupaReactNativeapprunningonClojureScript.
Itstandsfirmlyontheshouldersofgiants,specificallythoseofMikeFikeswhocreatedAmblyandthedocumentationonsettingupaClojureScriptReactNativeapp.
UsageBeforegettingstarted,makesureyouhavetherequireddependenciesinstalled.
Then,installtheCLIusingnpm:
$npminstall-gnatalTobootstrapanewapp,runnatalinitwithyourapp'snameasanargument:
$natalinitFutureAppIfyourapp'snameismorethanasingleword,besuretotypeitinCamelCase.AcorrespondinghyphenatedClojurenamespacewillbecreated.
BydefaultNatalwillcreateasimpleskeletonbasedonthecurrentstableversionofOm(akaOmNow).Ifyou'dliketobaseyourappuponOmNext,youcanspecifyaReactinterfacetemplateduringinit:
$natalinitFutureApp--interfaceom-nextKeepinmindyourappisn'tlimitedtotheReactinterfacesNatalprovidestemplatesfor;thesearejustforconvenience.
Ifallgoeswellyourappshouldcompileandbootinthesimulator.
FromthereyoucanbeginaninteractiveworkflowbystartingtheREPL.
$cdfuture-app$rlwrapnatalrepl(Ifyoudon'thaverlwrapinstalled,youcansimplyrunnatalrepl,butusingrlwrapallowstheuseofarrowkeys).
Iftherearenoissues,theREPLshouldconnecttothesimulatorautomatically.Tomanuallychoosewhichdeviceitconnectsto,youcanrunrlwrapnatalrepl--choose.
Attheprompt,tryloadingyourapp'snamespace:
(in-ns'future-app.core)ChangesyoumakeviatheREPLorbychangingyour.cljsfilesshouldappearliveinthesimulator.
Trythiscommandasanexample:
(swap!app-stateassoc:text"HelloNativeWorld")WhentheREPLconnectstothesimulatoritwillbegintoautomaticallylogsuccessmessages,warnings,anderrorswheneveryouupdateyour.cljsfiles.
TipsHavingrlwrapinstalledisoptionalbuthighlyrecommendedsinceitmakestheREPLamuchnicerexperiencewitharrowkeys.
Don'tpress⌘-Rinthesimulator;codechangesshouldbereflectedautomatically.SeethisissueinAmblyfordetails.
RunningmultipleReactNativeappsatoncecancauseproblemswiththeReactPackagersotrytoavoiddoingso.
YoucanlaunchyourapponthesimulatorwithoutopeningXcodebyrunningnatallaunchinyourapp'srootdirectory.
BydefaultnewNatalprojectswilllaunchontheiPhone6simulator.Tochangewhichdevicenatallaunchuses,youcanrunnatallistdevicestoseealistofavailablesimulators,thenselectonebyrunningnatalsetdevicewiththeindexofthedeviceonthelist.
TochangeadvancedsettingsrunnatalxcodetoquicklyopentheXcodeproject.
TheXcode-freeworkflowisforconvenience.Ifyou'reencounteringappcrashes,youshouldopentheXcodeprojectandrunitfromtheretoviewerrors.
Youcanrunanycommandwith--verboseor-vtoseeoutputthatmaybehelpfulindiagnosingerrors.
DependenciesAsNatalistheorchestrationofmanyindividualtools,therearequiteafewdependencies.Ifyou'vepreviouslydoneReactNativeorClojuredevelopment,youshouldhopefullyhavemostinstalledalready.Platformdependenciesarelistedundertheirrespectivetools.
npm>=1.4Node.js>=4.0.0Leiningen>=2.5.3Java8CocoaPods>=0.38.2Ruby>=2.0.0Xcode(+CommandLineTools)>=6.3OSX>=10.10Watchman>=3.7.0rlwrap>=0.42(optionalbutrecommendedforREPLuse)react-native-cli>=0.1.7(installwithnpminstall-greact-native-cli)UpdatingNatalYoucangetthelatestversionofNatalbyrunningnpminstall-gnatalagain.
AspirationsXcode-freeworkflowwithCLItoolsTemplatesforotherClojureScriptReactwrappersAutomaticwrappingofallReactNativecomponentfunctionsforClojureScriptAutomaticallytailcompilationlogandreporterrorstoREPLAutomaticallyrunReactpackagerinbackgroundWorkingdevtoolsAutomaticbundlingforofflinedeviceusageandAppStoredistributionAndroidsupportAutomaticsetupofJSmodulesExampleappsbootstrappedwithNatalOmNextappwithPythonserverbyDavidMohl,demonstratedinatalkattheTokyoiOSMeetup.
ZoobornsbyJearvonDharrie,demonstratedinatalkatClojure/conj2015.
CodaContributionsarewelcome.
FormoreClojureScriptReactNativeresourcesvisitcljsrn.org.
Ifyou'relookingforasimpleClojureScriptwrapperaroundtheReactNativeAPI,checkoutthecompanionlibraryNatalShell.ItisincludedbydefaultinprojectsgeneratedbyNatal.
评论