自定義 fastlane 插件 yhpgyer

yhpgyer 是在 fastlane-plugin-pgyer 插件的基礎(chǔ)上,實現(xiàn) ipa 文件上傳到蒲公英后,返回安裝包二維碼下載鏈接的功能。本文以此來介紹如何創(chuàng)建自定義插件。創(chuàng)建方法參見官方文檔:Create your own fastlane plugin。

創(chuàng)建插件

打開終端,依次執(zhí)行如下命令:

# 定位到 home 目錄下。(可按自己喜好選擇目錄)。
cd ~
# 創(chuàng)建 yhpgyer 文件夾。
mkdir yhPgyer
# 定位到 yhpgyer 文件夾下。
cd yhpgyer
# 創(chuàng)建 yhpgyer 插件
fastlane new_plugin yhpgyer

然后根據(jù)終端提示輸入:y,以及插件的總結(jié)和描述。

[14:07:58]: Would 'yhpgyer' be okay to use for your plugin name? (y/n)
y
[14:07:58]: Please enter a short summary of this fastlane plugin:
distribute app to pgyer beta testing service
[14:09:15]: Please enter a detailed description of this fastlane plugin:
distribute app to pgyer beta testing service

執(zhí)行完上面的操作后,用文本編譯器打開 ~/yhpgyer/fastlane-plugin-yhpgyer/lib/fastlane/plugin/yhpgyer/actions/yhpgyer_action.rb 文件,實現(xiàn)文件內(nèi)的方法即可。

yhpgyer_action

yhpgyer 插件,復(fù)制了 pgyer 插件的實現(xiàn)代碼后,修改了 self.checkPublishStatus 方法,增加了上傳 ipa 文件成功后,返回安裝包二維碼下載鏈接的功能。
image.png

使用本地 fastlane 插件

打開終端,依次執(zhí)行如下命令:

# 定位到要使用本地 fastlane 插件的項目目錄下。
cd /path/projectName
# 添加插件
fastlane add_plugin

然后根據(jù)終端提示,依次輸入:yhpgyer、2、本地插件的路徑~/yhpgyer/fastlane-plugin-yhpgyer

[15:11:54]: Enter the name of the plugin to install: yhpgyer
[15:12:00]: Seems like the plugin is not available on RubyGems, what do you want to do?
1. Git URL
2. Local Path
3. RubyGems.org ('fastlane-plugin-yhpgyer' seems to not be available there)
4. Other Gem Server
?  2
[15:12:02]: Please enter the relative path to the plugin you want to use. It
has to point to the directory containing the .gemspec file
~/yhpgyer/fastlane-plugin-yhpgyer
[15:12:19]: Plugin 'fastlane-plugin-yhpgyer' was added to './fastlane/Pluginfile'

執(zhí)行完上面的命令,我們可以看到項目目錄下的./fastlane/Pluginfile文件被添加了gem "fastlane-plugin-yhpgyer", path: "~/yhpgyer/fastlane-plugin-yhpgyer",這個就是指定本地插件的路徑。

發(fā)布自定義 fastlane 插件

1.在RubyGems官網(wǎng)上注冊賬號
2.將你的插件發(fā)布到 github 上(整個fastlane-plugin-[plugin name]文件夾)
3.將.gemspec文件中的spec.homepage參數(shù)改為你的github地址
4.執(zhí)行以下指令,進行發(fā)布操作

bundle install
rake install
rake release

上述命令都執(zhí)行成功后,即可通過 fastlane add_plugin yhpgyer 安裝插件了。

通過 github 鏈接使用自定義插件

如果不想通過 RubyGems 發(fā)布插件,我們可以通過 github 上的插件倉庫地址來使用自定義插件。
只需要將項目目錄下的 ./fastlane/Pluginfile 文件添加 gem "fastlane-plugin-yhpgyer", git: "https://github.com/whoyoung/yhpgyer" 即可。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容