NativeScript

本页使用了标题或全文手工转换
维基百科,自由的百科全书
NativeScript
原作者Telerik by Progress.[1]
開發者社群
首次发布2014年 (2014)
当前版本
  • 7.0.0 (2020年9月3日)[2]
編輯維基數據鏈接
源代码库 編輯維基數據鏈接
编程语言JavaScriptTypeScript
平台跨平臺
许可协议Apache License 2.0
网站nativescript.org

NativeScript是一個提供開發Apple iOSAndroid流動應用程式开源软件,最初由Progress構思和開發。[4]2019 年底,Progress的長期合作夥伴nStudio接管NativeScript項目。[5]在nStudio的監督下,NativeScript於2020年12月成為OpenJS基金會的培育項目。[6]NativeScript可以使用JavaScript或是其他可以編譯成JavaScript的编程语言編寫,例如TypeScript。NativeScript同時也支援Angular[7]Vue[8]。使用NativeScript構建的行動應用程式會產生完整的原生應用程式,其使用了與XcodeAndroid Studio相同API。[9]此外,軟體開發人員可以加入CocoaPodsMavennpm.js的第三方程式庫到程式中而無須其他的包裝函數。[10][11][12]

發展[编辑]

NativeScript於2015年3月首次公開發布,並在兩個月後發布了1.0.0版本。[13]NativeScript在公開發布後不久就迅速流行起來,短期之內超過1500名Twitter用戶追蹤其Twitter,其Github儲存庫也獲得了3000顆以上的星星。[14]與此同時,NativeScript已有700個擴充功能,分別由Progress官方及開源社區開發。[15][16]除此之外,也可使用Angular來開發在Web平台和移動平台之間共用的應用程式原始碼。[17][18]

架構[编辑]

NativeScript和所有必需的擴充功能都使用套件管理器npm安裝。使用者可通過命令行或名為NativeScript Sidekick的GUI工具建立、配置和編譯項目。[19] NativeScript使用XML文件定義不同平台的用戶界面,再由XML文件中的抽象描述來呼叫不同平台的原生UI元素。使用Angular和TypeScript開發的應用程式可以於目標平台外進行開發。NativeScript使用node.js執行和構建行動版應用程式。[20]NativeScript的目標是在iOS和Android兩個平台之間實現90%的通用代碼。[1]

直接呼叫原生API及控件[编辑]

NativeScript使用XML文件定義不同平台的用戶界面[21],同時NativeScript使用了跨平台的抽象XML資料來觸發特定於平台的代碼,這些代碼直接與目標平台的原生物件交互,例如說當調用NativeScript Button API的UI抽象時,NativeScript會直接調用iOS上的UIButton[22]或Android上的com.android.widget.Button[23]

雖然應用程式可能使用JavaScript、TypeScript、Angular或Vue.js來編寫,但其源始碼不會被編譯或轉譯,而是按原樣直接在設備上執行。此構建方式免除了交叉編譯或轉譯的需求。[12]此外,雖然應用程式的源始碼是使用瀏覽器或包含WebView的行動應用程式中常見的語言編寫,但NativeScript應用程式直接在本機設備上執行,而非操作DOM或呼叫任何瀏覽器來執行。[7]

主要功能[编辑]

原生API對應[编辑]

NativeScript的另一個特性為使用映射來呼叫原生API端點。NativeScript不需要在框架和平台API之間單獨綑綁,而是使用映射來獲取有關原生平台API的信息和元數據,因此可以立即使用所有新加入的API。[7]

使用者也可以使用第三方庫來達成映射的效果。在NativeScript中JavaScript(或TypeScript/Angular)可以直接與呼叫原生代碼,因此無須使用Objective-C、Swift、Java或Kotlin編寫綑綁層(英語:binding layers)。[12][24]

與Angular一同使用[编辑]

自NativeScript 2.0起,開發人員可以使用Angular建置跨平台的專案。[25]除此之外,開發人員使用Angular時可以使用相同的原始碼製作網頁和行動版應用程式。[26]

與Vue.js一同使用[编辑]

開發人員可以使用nativescript-vue擴充功能進而在NativeScript使用Vue.js框架。[8]

支援的工具及服務[编辑]

  • NativeScript Sidekick是一個图形用户界面,建構於NativeScript CLI之上。開發人員可以使用NativeScript Sidekick來套用模板、雲端構建應用程式,並將應用程式發佈到公開的應用程式商店。
  • 開發人員可以使用NativeScript Playground在瀏覽器中測試NativeScript,並在實體設備上預覽應用程式。
  • 開發人員可以在NativeScript市集(英語:NativeScript Marketplace)獲取擴充功能、預構建應用程式模板和可執行的範例應用程式。

參考文獻[编辑]

  1. ^ 1.0 1.1 Frequently asked questions about NativeScript. NativeScript.org. [2016-03-20]. (原始内容存档于2016-03-18). 
  2. ^ Release 7.0.0. 2020年9月3日 [2020年12月1日]. 
  3. ^ Releases · NativeScript/NativeScript. GitHub. [2018-06-03]. (原始内容存档于2021-08-31). 
  4. ^ Creating Mobile Native Apps in JavaScript with NativeScript. InfoQ. [2022-07-12]. (原始内容存档于2022-06-19). 
  5. ^ Saripella, Surya. The Next Chapter for NativeScript: nStudio. NativeScript. [2022-07-12]. (原始内容存档于2021-01-16). 
  6. ^ Romoff, Rachel. NativeScript joins OpenJS Foundation as Incubating Project. The Linux Foundation Projects. OpenJS Foundation. 7 December 2020 [4 March 2021]. (原始内容存档于25 January 2021). 
  7. ^ 7.0 7.1 7.2 Krill, Paul. JavaScript goes native for iOS, Android, and Windows Phone apps. InfoWorld. March 10, 2015 [July 12, 2022]. (原始内容存档于January 3, 2022). 
  8. ^ 8.0 8.1 NativeScript-Vue. nativescript-vue.org. [2017-10-31]. (原始内容存档于2021-10-04). 
  9. ^ NativeScript framework eases cross-platform app development woes. searchcloudcomputing.techtarget.com. [2021-08-06]. (原始内容存档于2021-08-06). 
  10. ^ Krill, Paul. NativeScript warms up to AngularJS for mobile dev. InfoWorld. May 6, 2016 [July 12, 2022]. (原始内容存档于June 12, 2022). 
  11. ^ SD Times GitHub Project of the Week: NativeScript. March 18, 2016 [July 12, 2022]. (原始内容存档于March 27, 2022). 
  12. ^ 12.0 12.1 12.2 Telerik's NativeScript Aims To Centralize Cross-Platform Mobile Development -. Visual Studio Magazine. [2016-11-21]. (原始内容存档于2017-11-07). 
  13. ^ NativeScript 1.0.0 Released. www.i-programmer.info. [2022-07-12]. (原始内容存档于2022-06-11). 
  14. ^ NativeScript 1.0.0 is now available. NativeScript.org. [2016-11-04]. (原始内容存档于2016-10-05). 
  15. ^ NativeScript Marketplace. market.nativescript.org. [2018-03-14]. (原始内容存档于2018-03-15). 
  16. ^ nativescript - npm search. www.npmjs.com. [2016-11-21]. (原始内容存档于2017-02-11). 
  17. ^ Review, C. I. O. Progress Releases NativeScript 2.0 with Cross-Platform Deployment Capabilities. CIOReview. [2022-07-12]. (原始内容存档于2022-06-21). 
  18. ^ Getting to Know Angular 2. mobile.htmlgoodies.com. 15 November 2016 [12 July 2022]. (原始内容存档于27 September 2019). 
  19. ^ NativeScript Sidekick - your faithful companion for app development. NativeScript.org. [2017-10-31]. (原始内容存档于2017-11-07) (英语). 
  20. ^ Hanna, Tam. Mit JavaScript wie hausgemacht: NativeScript. Developer. [2022-07-12]. (原始内容存档于2021-07-25). 
  21. ^ The Basics - NativeScript Docs. docs.nativescript.org. [2016-11-21]. (原始内容存档于2016-11-21). 
  22. ^ NativeScript/NativeScript. github.com. [2022-06-20]. (原始内容存档于2022-06-20). 
  23. ^ NativeScript/NativeScript. github.com. [2022-06-20]. (原始内容存档于2022-06-20). 
  24. ^ Accessing Native APIs through JavaScript - NativeScript Docs. docs.nativescript.org. [2016-11-21]. (原始内容存档于2016-11-24). 
  25. ^ NativeScript 2.0 - the best way to build cross-platform native mobile apps. NativeScript.org. [2016-11-21]. (原始内容存档于2016-12-20). 
  26. ^ Witalec, Sebastian. Apps That Work Natively on the Web and Mobile. Medium. 2018-08-24 [2021-08-06]. (原始内容存档于2022-01-03) (英语). 

外部連結[编辑]