Fastlane을 이용하여 테스트플라이트에 앱 업로드 시키기.
개인앱을 만들때에는 수동으로 아카이빙하여 테스트플라이트에 올려도 되지만 일일히 클릭하여 하는것보단
fastlane을 이용하여 한번에 빌드 및 업로드를 하는게 편하다.
아래는 초기 fastlane을 설정하여 테스트 플라이트에 업로드 하는것까지 내용을 정리한내용이다.
아래 내용을 시작하기전에 필요한 내용은 아래와 같다.
- 해당 프로젝트 배포용 프로비저닝
- bundle 설치
- iOS 프로젝트 폴더로 이동하여 아래와 같은 명령어를 입력한다.
fastlane init
그렇다면 콘솔에 아래와 같이 찍힐텐데 나는 앱 자동 배포를 이용할것이기 때문에 3을 누르고 엔터를 눌러 다음으로 이동한다.
[✔] 🚀
[✔] Looking for iOS and Android projects in current directory...
[15:06:35]: Created new folder './fastlane'.
[15:06:35]: Detected an iOS/macOS project in the current directory: 'MukTubeMap.xcworkspace'
[15:06:35]: -----------------------------
[15:06:35]: --- Welcome to fastlane 🚀 ---
[15:06:35]: -----------------------------
[15:06:35]: fastlane can help you with all kinds of automation for your mobile app
[15:06:35]: We recommend automating one task first, and then gradually automating more over time
[15:06:35]: 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
?
그렇다면 뭔가가 쭉 내려오면서 애플계정 입력을 요구하는데 입력한다.
[15:07:52]: Apple ID Username:
[여기에 자신의 애플계정 ID가 입력된다~]
[15:08:20]: Logging in...
Available session is not valid any more. Continuing with normal login.
[15:08:25]: ✅ Logging in with your Apple ID was successful
[15:08:25]: Checking if the app 'com.ios.heogj.muktubemap' exists in your Apple Developer Portal...
[15:08:26]: ✅ Your app 'com.ios.heogj.muktubemap' is available in your Apple Developer Portal
[15:08:26]: Checking if the app 'com.ios.heogj.muktubemap' exists on App Store Connect...
[15:08:26]: ✅ Your app 'com.ios.heogj.muktubemap' is available on App Store Connect
[15:08:26]: ----------------------------
[15:08:26]: --- Manage app metadata? ---
[15:08:26]: ----------------------------
[15:08:26]: Would you like to have fastlane manage your app's metadata?
[15:08:26]: If you enable this feature, fastlane will download your existing metadata and screenshots.
[15:08:26]: This way, you'll be able to edit your app's metadata in local `.txt` files.
[15:08:26]: After editing the local `.txt` files, just run fastlane and all changes will be pushed up.
[15:08:26]: If you don't want to use this feature, you can still use fastlane to upload and distribute new builds to the App Store
[15:08:26]: Would you like fastlane to manage your app's metadata? (y/n)
MetaData를 매니징할것이냐고 묻는데 나는 y를 해주고 넘어갔다.
여기서 Bundle update를 진행하는데 너무 오래걸려서 Quit시키고 진행하였다.
- Fastfile 작성하기.
여기까지 완료되었으면 iOS 프로젝트 폴더내에 fastlane이라는 폴더가 생겼을것이고 그안에 Fastfile이라는 텍스트 파일이 생성된것을 알수있다.
실제 fastlane을 실행시키면 해당 파일내에 있는 구문이 실행되는것이므로 여기에 관련 내용을 입력해야한다.
간단하게 앱 배포를 진행하는것이기 때문에 절차는 아래와같이 두절차로 분리한다.
1. 앱 빌드
2. 테스트플라이트에 업로드
우선 1번의 내용을 구현해보자.
코드는 아래와 같다.
desc 'Build app'
lane :buildApp do
increment_build_number(
xcodeproj: '[AppName].xcodeproj',
build_number: '[AppBuild Number]'
)
build_app(
workspace: '[AppName].xcworkspace',
scheme: '[AppName]',
skip_package_pkg: true
)
end
increment_build_number를 이용하여 pod프로젝트의 빌드번호를 설정한뒤
pod프로젝트를 빌드하는 내용이다.
그 다음 테스트 플라이트에 업로드 하는 내용은 아래와같다.
desc 'Upload App'
lane :uploadApp do
upload_to_testflight(
verbose: true,
skip_waiting_for_build_processing: true
)
end
실제로 앱을 배포하려고 테스트플라이트에 올릴시 위의 2가지를 같이 호출해야 하는데
아래와 같이 하나를 호출하여 2가지를 모두 묶으면 된다.
desc "AppBuild -> TestFlight upload"
lane :runApp do
buildApp
uploadApp
end
앱 개발이 완료된후 테스트플라이트에 올릴때 'AppBuild -> TestFlight upload' 구문만 실행시켜주면 된다.
전체 코드는 아래와 같다.
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-plugins
#
# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane
default_platform(:ios)
platform :ios do
desc "AppBuild -> TestFlight upload"
lane :runApp do
buildApp
uploadApp
end
desc 'Build app'
lane :buildApp do
increment_build_number(
xcodeproj: '[AppName].xcodeproj',
build_number: '[AppBuild Number]'
)
build_app(
workspace: '[AppName].xcworkspace',
scheme: '[AppName]',
skip_package_pkg: true
)
end
desc 'Upload App'
lane :uploadApp do
upload_to_testflight(
verbose: true,
skip_waiting_for_build_processing: true
)
end
end
실제 사용 장면은 아래와 같다.
fastlane폴더가 있는 위치에서 아래의 명령어를 입력하여 fastlane을 실행시킨다.
bundle exec fastlane
1번을 선택하여 빌드 및 테스트플라이트 업로드를 진행한다.
빌드를 진행하고 업로드를 하다보면 빨간글씨로 아래와 같은 에러가 나타나는 경우가 있는데,
[15:45:27]: Transporter transfer failed.
[15:45:27]:
[15:45:27]: Sign in with the app-specific password you generated. If you forgot the app-specific password or need to create a new one, go to appleid.apple.com (-22938)
[15:45:27]:
[15:45:27]: Your account has 2 step verification enabled
[15:45:27]: Please go to https://appleid.apple.com/account/manage
[15:45:27]: and generate an application specific password for
[15:45:27]: the iTunes Transporter, which is used to upload builds
[15:45:27]:
[15:45:27]: To set the application specific password on a CI machine using
[15:45:27]: an environment variable, you can set the
[15:45:27]: FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD variable
fastlane파일 내에 Appfile을 열고 하단에
아래의 내용을 추가해주면 된다.
ENV['FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD'] = '~~~~~~~'
위에 들어갈 Value는 앱암호라는 값인데 이것은 https://support.apple.com/ko-kr/HT204397 를 통해 만들수있다.
한번 만들면 다시 볼수가 없으니 한번 만들고나면 잘기억해놔야 한다.
생성후 Appfile에 설정해놓으면 지속적으로 사용이 가능하다.
이후 다시 fastlane실행후 빌드 및 배포하면 정상적으로 테스트 플라이트에 업로드 되는것을 볼수있다.