2024. 5. 12. 21:14ㆍ블로그/ios
아이폰 빌드는 너무 귀찮은 작업도 많고 jenkins,circleci,github action 마다 처리 하는게 너무 제각각이어서 fastlane이 필수 아닌 필수가 되었습니다.
몇년간 아이폰 개발을 진행하면 정리하여서 템플릿화 된 fastlane 파일을 정리하고자 합니다.
fastlane은 command line으로 아이폰을 빌드 및 배포를 할수 있도록 도와주는 도구입니다.
fastlane docs
fastlane fastlane is the easiest way to automate beta deployments and releases for your iOS and Android apps. 🚀 It handles all tedious tasks, like generating screenshots, dealing with code signing, and releasing your application. You can start by creati
docs.fastlane.tools
fastlane 빌드시 반드시 필요한것
1.개발자 계정
2.인증서 p12파일
3.api token
*아이폰 빌드는 인증서 설정까지 포함해서 항상 클린 빌드를 한다고 생각하시면 됩니다.
패키지 매니저는 cocoapods을 사용한다고 가정하고 진행하오니 다른 툴을 쓰시는 분은 파일을 수정하시면 됩니다.
1.fastlane init
What would you like to use fastlane for? 을 물어보면 그냥 4번으로 해서 직접 설치하는게 속편합니다.
fastlane 자체서 제공해주는 template은 그다지 사용성이 좋지를 못해서 직접 수정하는 방향으로 진행합니다.
test fastlane init
[✔] 🚀
[✔] Looking for iOS and Android projects in current directory...
[15:47:26]: Created new folder './fastlane'.
[15:47:26]: Detected an iOS/macOS project in the current directory: 'test.xcworkspace'
[15:47:26]: -----------------------------
[15:47:26]: --- Welcome to fastlane 🚀 ---
[15:47:26]: -----------------------------
[15:47:26]: fastlane can help you with all kinds of automation for your mobile app
[15:47:26]: We recommend automating one task first, and then gradually automating more over time
[15:47:28]: What would you like to use fastlane for?
1. 📸 Automate screenshots
2. 👩✈️ Automate beta distribution to TestFlight
3. 🚀 Automate App Store distribution
4. 🛠 Manual setup - manually setup your project to automate your tasks
? 4
[15:47:35]: ------------------------------------------------------------
[15:47:35]: --- Setting up fastlane so you can manually configure it ---
[15:47:35]: ------------------------------------------------------------
[15:47:35]: Installing dependencies for you...
[15:47:35]: $ bundle update
[15:47:52]: --------------------------------------------------------
[15:47:52]: --- ✅ Successfully generated fastlane configuration ---
[15:47:52]: --------------------------------------------------------
[15:47:52]: Generated Fastfile at path `./fastlane/Fastfile`
[15:47:52]: Generated Appfile at path `./fastlane/Appfile`
[15:47:52]: Gemfile and Gemfile.lock at path `Gemfile`
[15:47:52]: Please check the newly generated configuration files into git along with your project
[15:47:52]: This way everyone in your team can benefit from your fastlane setup
[15:47:52]: Continue by pressing Enter ⏎
[15:47:55]: fastlane will collect the number of errors for each action to detect integration issues
[15:47:55]: No sensitive/private information will be uploaded, more information: https://docs.fastlane.tools/#metrics
[15:47:55]: ----------------------
[15:47:55]: --- fastlane lanes ---
[15:47:55]: ----------------------
[15:47:55]: fastlane uses a `Fastfile` to store the automation configuration
[15:47:55]: Within that, you'll see different lanes.
[15:47:55]: Each is there to automate a different task, like screenshots, code signing, or pushing new releases
[15:47:55]: Continue by pressing Enter ⏎
[15:47:55]: --------------------------------------
[15:47:55]: --- How to customize your Fastfile ---
[15:47:55]: --------------------------------------
[15:47:55]: Use a text editor of your choice to open the newly created Fastfile and take a look
[15:47:55]: You can now edit the available lanes and actions to customize the setup to fit your needs
[15:47:55]: To get a list of all the available actions, open https://docs.fastlane.tools/actions
[15:47:55]: Continue by pressing Enter ⏎
[15:47:56]: ------------------------------
[15:47:56]: --- Where to go from here? ---
[15:47:56]: ------------------------------
[15:47:56]: 📸 Learn more about how to automatically generate localized App Store screenshots:
[15:47:56]: https://docs.fastlane.tools/getting-started/ios/screenshots/
[15:47:56]: 👩✈️ Learn more about distribution to beta testing services:
[15:47:56]: https://docs.fastlane.tools/getting-started/ios/beta-deployment/
[15:47:56]: 🚀 Learn more about how to automate the App Store release process:
[15:47:56]: https://docs.fastlane.tools/getting-started/ios/appstore-deployment/
[15:47:56]: 👩⚕️ Learn more about how to setup code signing with fastlane
[15:47:56]: https://docs.fastlane.tools/codesigning/getting-started/
[15:47:56]:
[15:47:56]: To try your new fastlane setup, just enter and run
[15:47:56]: $ fastlane custom_lane
2.플러그인 설치
당사에서는 appcenter와 slack,cocoapods binary cache,fastlane-plugin-semantic_release을 사용하기 때문에 Pluginfile을 생성해줍니다.
faselane/Pluginfile
# Autogenerated by fastlane
#
# Ensure this file is checked in to source control!
gem 'cocoapods'
gem "cocoapods-binary-cache"
gem 'fastlane-plugin-appcenter'
gem 'fastlane-plugin-semantic_release'
gem 'fastlane-plugin-sentry'
Gemfile도 수정해줍니다.
source "https://rubygems.org"
gem "fastlane"
plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
eval_gemfile(plugins_path) if File.exist?(plugins_path)
3.Fastfile
먼저 Fastfile의 내용을 싹 비우고 시작하면 됩니다.
아이폰을 빌드 하는 순서를 알아봅시다.
- 임시 인증서 생성
- 임시 인증서에 p12 파일 import
- api token 생성
- 인증서 sigh 및 provisioning 설정
- cocoapods install
- appcenter 혹은 testflight 배포
- sentry dsym upload
전체 코드 입니다.
###############################################################
# FASTLANE
###############################################################
update_fastlane
fastlane_version "2.205.1"
default_platform(:ios)
#keychain
TEMP_KEYCHAIN_NAME = "{임시 키체인 이름 }"
TEMP_KEYCHAIN_PASSWORD = "{임시 키체인 비밀번호}"
#apple key
APPLE_ISSUER_ID = "{apple issuer id}"
APPLE_KEY_ID = "{apple issuer key}"
APPLE_KEY_CONTENT = "{apple issue p8 content}"
#code sign
CERT_ID = "{cert id}"
CODE_SIGN_IDENTIFIER="{cert identifier}"
#appcenter
APPCENTER_API_TOKEN = "{appcenter api token}"
APPCENTER_OWNER_TYPE = "{appcenter owner type}"
APPCENTER_PROJECT_SLUG = "{appcenter project slug}"
APPCENTER_APP_NAME = "{appcenter app name}"
#sentry
SENTRY_AUTH_TOKEN = "{sentry token}"
SENTRY_ORG_SLUG = '{sentry org slug}'
SENTRY_PROJECT_SLUG= '{sentry project slug}'
#slack
SLACK_URL = "{slack incommint webhook url}"
###############################################################
# PROJECT VARIABLE
###############################################################
XCODE_PROJECT="{iphone.xcodeproj}"
XCODE_WORKSPACE="{iphone.xcworkspace}"
APP_TARGET="{iphone}"
PUSH_TARGET="{push}"
APP_GROUP_IDENTIFIER="{group.identifier}"
APP_IDENTIFIER="{identifier}"
APP_PUSH_IDENTIFIER="{push_identifier}"
APP_INFO_PLIST="{info.plist path}"
APP_BUILD_CONF="Release"
APP_OUTPUT_NAME="iphone.ipa"
APP_DSYM_OUTPUT_PATH = "./iphone.app.dSYM.zip"
P12_FILE_PATH="{p12 path}"
P12_PASSWORD="{p12 비밀번호}"
###############################################################
# FASTLANE BUILD CONFIG
###############################################################
BUILD_APP_NAME_APPCENTER = "{앱센터에 배포할 이름}"
BUILD_APP_NAME_TESTFLIGHT = "{production 앱 이름}"
BUILD_TYPE_APPCENTER="appcenter"
BUILD_TYPE_TESTFLIGHT="testflight"
###############################################################
# FASTLANE BUILD GLOBAL VARIABLE
###############################################################
@BUILD_TYPE = ""
@BUILD_EXPORT_METHOD="" #ad-hoc,app-store
@IS_AD_HOC = false
@VERSION = ""
@BUILD_NUMBER = 0
@BUILD_APP_NAME = ""
@API_KEY = nil
@KEYCHAIN_PATH = nil
@GIT_COMMIT = nil
###############################################################
# FOR BUILD
###############################################################
ENV["DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS"] = "-t Signiant"
ENV["FASTLANE_XCODEBUILD_SETTINGS_RETRIES"] = "6"
ENV["IS_POD_BINARY_CACHE_ENABLED"] = "true"
하나씩 살펴보겠습니다.
###############################################################
# DEFAULT VALUE
###############################################################
keychain
TEMP_KEYCHAIN_NAME | 임시 키체인 이름입니다. ci 툴에서 빌드를 하게 되면 임시로 키체인이 필요하기 때문에 생성이 필수 |
TEMP_KEYCHAIN_PASSWORD | 임시 키체인 비밀번호: 아무 비밀번호를 적으시면 됩니다. |
apple key
APPLE_ISSUER_ID | apple app key의 아이디 입니다. |
APPLE_KEY_ID | 애플 키아이디를 적으시면 됩니다. |
APPLE_KEY_CONTENT | 다운 받으신 p8파일을 테스트로 붙여넣으시면 됩니다. |
2022.06.17 - [기술블로그/ios] - 애플 앱 키 생성하는 방법
애플 앱 키 생성하는 방법
애플의 fastlane 빌드를 하기위해선 apple app key가 필수적으로 생성이 되어야합니다. 아래는 apple app key 생성을 하기 위한 방법입니다. 1. https://appstoreconnect.apple.com/ 접속한다 2.사용자 및 access..
blog.mint-soft.com
위의 문서를 확인하시고 애플키를 생성하시면 됩니다.
CERT_ID | cert의 ID 입니다. (개발자 사이트의 cert의 아이디를 확인할수 있습니다. ) 주소창의 ID를 가져오시면 됩니다. |
CODE_SIGN_IDENTIFIER | iPhone Distribution: company (123adasdf) |
appcenter
APPCENTER_API_TOKEN | appcenter의 api token 입니다. |
APPCENTER_OWNER_TYPE | 애플 키아이디를 적으시면 됩니다. |
APPCENTER_PROJECT_SLUG | 프로젝트 slug입니다. |
APPCENTER_APP_NAME | 앱 이름입니다. |
sentry
SENTRY_AUTH_TOKEN | sentry auth token 입니다. |
SENTRY_ORG_SLUG | sentry org slug 입니다. |
SENTRY_PROJECT_SLUG | sentry project slug 입니다. |
entry
SLACK_URL | slack icomming webhook 입니다. |
###############################################################
# PROJECT VARIABLE
###############################################################
XCODE_PROJECT | xcode project 파일 이름입니다. |
XCODE_WORKSPACE | xcworkspace 파일 이름입니다. |
APP_TARGET | target 이름입니다. |
PUSH_TARGET | 푸쉬를 사용한다면 푸쉬의 target 이름입니다. |
APP_GROUP_IDENTIFIER | app group identifier 입니다. |
APP_IDENTIFIER | app identifier 입니다. |
APP_PUSH_IDENTIFIER | app push identifier 입니다. |
APP_INFO_PLIST | info.plist 파일 경로를 적어주시면 됩니다. |
APP_BUILD_CONF | Release로 픽스해주시면 됩니다. |
APP_OUTPUT_NAME | ipa 파일 이름을 적어주시면 됩니다. |
APP_DSYM_OUTPUT_PATH | dsym 파일이름을 적어주시면 됩니다. sentry에 dsym을 업로드해야하므로 반드시 정확한 이름을 입력해주세요 |
P12_FILE_PATH | p12 파일을 프로젝트 안으로 넣으셔서 경로를 적어주시면 됩니다. |
P12_PASSWORD | p12 파일을 내보낼때 사용한 비밀번호를 입력합니다. |
###############################################################
# FASTLANE BUILD CONFIG
###############################################################
BUILD_APP_NAME_APPCENTER | 앱센터에 업로드 할 앱 이름입니다. |
BUILD_APP_NAME_TESTFLIGHT | 테스트플라이트에 업로드 될 앱 이름입니다. |
BUILD_TYPE_APPCENTER | appcenter 픽스 |
BUILD_TYPE_TESTFLIGHT | testflight 픽스 |
###############################################################
# FASTLANE BUILD GLOBAL VARIABLE
###############################################################
동적으로 변경되는 변수 이므로 그대로 픽스 하면 됩니다.
###############################################################
# FOR BUILD
###############################################################
fastlane 에서 빌드 되는 변수이므로 그대로 픽스 하시면 됩니다.
실제 함수는 2회차에서 적어보도록 하겠습니다.
민트소프트는 모바일 앱 개발 전문회사입니다. 하이브리드앱,크로스플랫폼,네이티브영역 전반에 걸친 모바일 앱을 개발하고 있습니다.
하이브리드는 민트앱이라는 솔루션을 보유하고 있어서 Time To Market에 매우 유리합니다.
언제는 찾아주시면 신속하고 빠른 상담을 진행하도록 하겠습니다.
'블로그 > ios' 카테고리의 다른 글
(2).swift fastlane (0) | 2024.05.12 |
---|---|
애플 앱 키 생성하는 방법 (0) | 2024.05.12 |
테스트 플라이트 사용법 (0) | 2024.05.12 |
ios UDID 얻는 방법 (0) | 2024.05.12 |