Tshaj tawm cov ntawv thov iOS no rau App Store nrog GitLab thiab fastlane

Tshaj tawm cov ntawv thov iOS no rau App Store nrog GitLab thiab fastlane

Yuav ua li cas GitLab nrog fastlane sau, kos npe thiab tshaj tawm iOS daim ntawv thov mus rau App Store.

Peb nyuam qhuav muaj tshaj tawm txog yuav ua li cas sai tsim thiab khiav ib daim ntawv thov Android nrog GitLab thiab fastlane. Ntawm no peb yuav pom yuav ua li cas tsim thiab khiav ib qho iOS app thiab tshaj tawm rau TestFlight. Saib seb nws txias npaum li cas Kuv tab tom hloov pauv ntawm iPad Pro nrog GitLab Web IDE, Kuv coj lub rooj sib txoos thiab tau txais qhov hloov tshiab rau qhov kev sim version ntawm daim ntawv thov ntawm tib lub iPad Pro qhov twg kuv tsim nws.

Ntawm no peb yuav coj yooj yim iOS app ntawm Swift, nrog leej twg kuv kaw cov video.

Ob peb lo lus hais txog Apple Store configuration

Peb yuav xav tau App Store app, daim ntawv pov thawj xa tawm, thiab cov ntaub ntawv qhia kom khi txhua yam ua ke.

Qhov nyuaj tshaj plaws ntawm no yog teeb tsa cov cai kos npe hauv App Store. Kuv vam tias koj tuaj yeem paub qhov no rau koj tus kheej. Yog tias koj yog tus tshiab, kuv yuav taw tes rau koj kom raug, tab sis peb yuav tsis tham txog qhov tsis txaus ntseeg ntawm kev tswj hwm Apple daim ntawv pov thawj ntawm no, thiab lawv tau hloov tas li. Cov ncej no yuav pab koj pib.

Kuv Apps

Koj xav tau ib qho app hauv App Store Txuas yog li koj muaj tus ID rau kev teeb tsa .xcodebuild. Cov profile thiab daim ntawv thov ID muab cov lej tsim, tus nqi thiab muaj, thiab TestFlight teeb tsa rau kev faib cov ntawv xeem rau cov neeg siv. Tsis txhob sim pej xeem, kev sim ntiag tug yuav txaus yog tias koj muaj ib pab pawg me, teeb tsa yooj yim, thiab tsis xav tau kev tso cai ntxiv los ntawm Apple.

Pib qhov profile

Ntxiv nrog rau kev teeb tsa app, koj xav tau iOS faib thiab txhim kho cov yuam sij tsim nyob rau hauv Daim Ntawv Pov Thawj, Cov Ntawv Qhia & Cov Profiles ntawm Apple Developer console. Tag nrho cov ntawv pov thawj no tuaj yeem muab tso ua ke rau hauv ib qho profile.

Cov neeg siv uas yuav raug lees paub yuav tsum muaj peev xwm tsim cov ntawv pov thawj, txwv tsis pub cov kauj ruam cert thiab sigh koj yuav pom qhov yuam kev.

lwm yam kev xaiv

Dhau li ntawm txoj kev yooj yim no, muaj lwm txoj hauv kev los teeb tsa daim ntawv pov thawj thiab cov profiles. Yog li, yog tias koj ua haujlwm txawv, koj yuav tau hloov kho. Qhov tseem ceeb tshaj plaws yog tias koj xav tau kev teeb tsa .xcodebuild, uas yuav taw tes rau cov ntaub ntawv tsim nyog, thiab cov keychain yuav tsum muaj nyob rau ntawm lub khoos phis tawj tsim rau tus neeg siv raws li nws lub npe tus neeg khiav haujlwm. Rau kev kos npe digital peb siv fastlane, thiab yog tias muaj teeb meem lossis koj xav paub ntxiv, tshawb xyuas lawv cov ntsiab lus cov ntaub ntawv hais txog kev kos npe digital.

Hauv qhov piv txwv no kuv tab tom siv txoj hauv kev cert thiab sigh, tab sis rau kev siv tiag tiag nws yuav zoo dua match.

Npaj GitLab thiab fastlane

Npaj CI Runner

Tom qab sau tag nrho cov ntaub ntawv no, peb txav mus rau qhov teeb tsa ntawm GitLab khiav ntawm MacOS ntaus ntawv. Hmoov tsis zoo, koj tsuas tuaj yeem ua iOS apps ntawm MacOS. Tab sis txhua yam tuaj yeem hloov pauv, thiab yog tias koj xav tias kev vam meej hauv cheeb tsam no, ua tib zoo saib xyuas cov haujlwm zoo li xcbuild ΠΈ kos npe, thiab peb txoj haujlwm sab hauv gitlab-ce #57576.

Teeb tsa tus khiav yog qhov yooj yim heev. Ua raws li tam sim no cov lus qhia rau kev teeb tsa GitLab Runner ntawm macOS.

Nco tseg. Tus neeg khiav dej num yuav tsum siv qhov kev pab cuam executable shell. Qhov no yuav tsum tau tsim iOS no ntawm macOS ua haujlwm ncaj qha raws li tus neeg siv es tsis yog los ntawm cov thawv. Yog koj siv shell, lub tsev thiab kev sim yog ua raws li tus neeg siv khiav, ncaj qha rau ntawm tus tswv tsev tsim. Nws tsis zoo li cov thawv ntim khoom, yog li zoo dua tuaj cov ntaub ntawv kev nyab xeebyog li koj tsis nco dab tsi.

sudo curl --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-darwin-amd64
sudo chmod +x /usr/local/bin/gitlab-runner
cd ~
gitlab-runner install
gitlab-runner start

Apple Keychain yuav tsum tau teeb tsa ntawm tus tswv tsev no nrog kev nkag mus rau cov yuam sij uas Xcode xav tau los tsim. Qhov yooj yim tshaj plaws los ntsuas qhov no yog nkag mus rau hauv raws li tus neeg siv uas yuav khiav qhov tsim thiab sim tsim nws manually. Yog hais tias lub kaw lus nug txog keychain nkag, xaiv Ib txwm tso cai rau CI ua haujlwm. Tej zaum nws yuav tsim nyog mus rau hauv thiab saib thawj ob peb lub raj xa dej kom paub tseeb tias lawv tsis thov rau lub keychain ntxiv lawm. Qhov teeb meem yog tias Apple tsis ua kom yooj yim rau peb siv Auto hom, tab sis thaum koj tau mus, txhua yam yuav zoo.

fastlane ib

Txhawm rau siv fastlane hauv qhov project, khiav fastlane init. Cia li ua raws li cov lus qhia rau kev txhim kho thiab khiav fastlane, tshwj xeeb tshaj yog nyob rau hauv nqe lus hais txog Gemfile, vim tias peb xav tau kev tso tawm sai thiab kwv yees los ntawm kev siv lub tshuab CI .

Hauv koj qhov project directory, khiav cov lus txib no:

xcode-select --install
sudo gem install fastlane -NV
# Alternatively using Homebrew
# brew cask install fastlane
fastlane init

fastlane yuav nug txog kev teeb tsa yooj yim thiab tom qab ntawd tsim cov ntawv ceev ceev hauv qhov project nrog peb cov ntaub ntawv:

1. fastlane/Appfile

Tsis muaj dab tsi nyuab ntawm no. Tsuas yog xyuas kom koj Apple ID thiab App ID yog lawm.

app_identifier("com.vontrance.flappybird") # The bundle identifier of your app
apple_id("[email protected]") # Your Apple email address

2. fastlane/Fastfile

Fastfile txhais cov kauj ruam tsim. Peb siv ntau lub fastlane's built-in nta, yog li txhua yam yog qhov tseeb ntawm no thiab. Peb tsim ib kab uas tau txais daim ntawv pov thawj, ua qhov sib dhos thiab xa mus rau TestFlight. Koj tuaj yeem faib cov txheej txheem no ua haujlwm sib txawv yog tias tsim nyog. Tag nrho cov haujlwm no (get_certificates, get_provisioning_profile, gym ΠΈ upload_to_testflight) twb muaj nyob rau hauv fastlane.

Sau ntawv get_certificates ΠΈ get_provisioning_profile muaj feem xyuam rau txoj kev kos npe cert thiab sigh. Yog koj siv match lossis xijpeem, hloov pauv.

default_platform(:ios)

platform :ios do
  desc "Build the application"
  lane :flappybuild do
    get_certificates
    get_provisioning_profile
    gym
    upload_to_testflight
  end
end

3. fastlane/Gymfile

Qhov no yog ib qho kev xaiv cov ntaub ntawv, tab sis kuv tsim nws manually los hloov lub neej ntawd tso zis directory thiab tso cov zis nyob rau hauv lub tam sim no nplaub tshev. Qhov no simplifies CI. Yog xav paub, nyeem txog gym thiab nws cov parameter hauv cov ntaub ntawv.

https://docs.fastlane.tools/actions/gym/

peb .gitlab-ci.yml

Yog li, peb muaj CI khiav rau qhov project thiab peb npaj txhij los sim cov kav dej. Cia peb saib seb peb muaj dab tsi hauv .gitlab-ci.yml:

stages:
  - build

variables:
  LC_ALL: "en_US.UTF-8"
  LANG: "en_US.UTF-8"
  GIT_STRATEGY: clone

build:
  stage: build
  script:
    - bundle install
    - bundle exec fastlane flappybuild
  artifacts:
    paths:
    - ./FlappyBird.ipa

Yog! Peb teem hom ntawv rau UTF-8 rau fastlane raws li xav tau, siv lub tswv yim clone nrog executing program shell, kom peb muaj qhov chaw ua haujlwm huv rau txhua lub rooj sib txoos, thiab tsuas yog hu flappybuild fastlane, raws li pom saum toj no. Raws li qhov tshwm sim, peb tau txais kev sib dhos, kos npe thiab xa tawm ntawm kev sib dhos zaum kawg hauv TestFlight.

Peb kuj tau txais cov khoom cuav thiab khaws cia nrog lub rooj sib txoos. Thov nco ntsoov tias hom ntawv .ipa yog kos npe rau ARM executable uas tsis khiav hauv lub simulator. Yog tias koj xav tau cov zis rau lub simulator, tsuas yog ntxiv lub hom phiaj tsim uas tsim nws, thiab tom qab ntawd muab tso rau hauv txoj kev artifact.

Lwm yam kev hloov pauv ib puag ncig

Muaj ob peb qhov kev hloov pauv ib puag ncig ntawm no uas ua rau txhua yam ua haujlwm.

FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD ΠΈ FASTLANE_SESSION

Kev lees paub rau fastlane yuav tsum tau lees paub hauv App Store thiab xa mus rau TestFlight. Txhawm rau ua qhov no, tsim tus password rau daim ntawv thov uas yuav siv hauv CI. Paub meej no.

Yog tias koj muaj ob-factor authentication, tsim qhov sib txawv FASTLANE_SESSION (cov lus qhia muaj).

FASTLANE_USER ΠΈ FASTLANE_PASSWORD

uas cert thiab sigh hu ua qhov pib profile thiab daim ntawv pov thawj raws li qhov kev thov, koj yuav tsum tau teeb tsa qhov hloov pauv FASTLANE_USER ΠΈ FASTLANE_PASSWORD. Paub meej no. Qhov no tsis tsim nyog yog tias koj siv lwm txoj kev kos npe.

Nyob rau hauv xaus

Koj tuaj yeem pom tias nws ua haujlwm li cas hauv kuv qhov piv txwv yooj yim.

Kuv vam tias qhov no yuav pab tau thiab txhawb koj los ua haujlwm nrog iOS ua haujlwm hauv GitLab project. Nov yog lwm qhov CI cov lus qhia rau fastlane, tsuas yog nyob rau hauv rooj plaub. Tej zaum koj yuav xav siv CI_BUILD_ID (rau incremental builds) rau cia li increment version.

Lwm qhov zoo nkauj ntawm fastlane yog tsis siv neeg screenshots rau App Store, uas yooj yim heev rau kev teeb tsa.

Qhia rau peb hauv cov lus hais txog koj qhov kev paub dhau los thiab qhia koj cov tswv yim los txhim kho GitLab rau iOS app kev txhim kho.

Tau qhov twg los: www.hab.com

Ntxiv ib saib