search
HomeWeb Front-endHTML TutorialHow does react-native implement automatic packaging? React-native automatic packaging method

The content of this article is about how to implement automatic packaging in react-native? The react-native automatic packaging method has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Have you also imagined that after writing the code, you don’t need to open xcode and android studio, but just execute a shell script to package both android and ios? And it will automatically be uploaded to Dandelion and App Store for you, and then the product will be automatically downloaded for testing. And you~~~ went directly to drink coffee.

Note: This article only describes how to use automatic script processing, so it is assumed that readers can package manually normally. If there are more complicated details, another chapter will be required.

Preparation materials

A macos host monitor, such as: mac-mini

Automatic build tools, such as: gitlab-runner, travis-ci, jenkins

Apple Developer Certification

The macos host needs to be used as the node of the build tool, and the following software or operations need to be installed:

git

xcode 9.4

xcode -> Settings-> accounts -> Add app_id used for Apple authentication or personal authentication

android studio

android sdk

java jdk 8

Note: If you don’t want to build a platform and just want to be simple, then you can integrate the following codes into one shell script and then execute it on your computer.

Packaging android

cd android
rm -rf build/ app/build/
./gradlew assembleRelease

The final apk file is at: android/app/build/outputs/apk/app-release.apk

Packaging ios

Build the basic package app first

cd ios
# 必须先创建目录
mkdir -p build
rm -rf build/archive.xcarchive build/ipa-*

# 获取目录名
project_list=`ls | grep .xcodeproj`
project_name=${project_list%%.*}

# 打包出app
# 这和你点击 xcode -> Product -> Archive 是一样的效果的。
xcodebuild clean
xcodebuild archive \
  -project ./${project_name}.xcodeproj \
  -scheme ${project_name} \
  -configuration Release \
  -archivePath ./build/archive.xcarchive

Then we need to export the app to ipa format so that it can be uploaded to the App Store or test platform such as: Dandelion, fir.im

To transfer to the App Store, you need to export the official ipa package, and to transfer to Dandelion, you need to use the test ipa package (ad-hoc), so you need to execute it twice

cd ios

# 正式ipa包
xcodebuild -exportArchive \
    -archivePath ./build/archive.xcarchive \
    -exportPath ./build/ipa-app-store \
    -exportOptionsPlist ./exportOptions/app-store.plist \
    -allowProvisioningUpdates
    
# 测试ipa包
xcodebuild -exportArchive \
    -archivePath ./build/archive.xcarchive \
    -exportPath ./build/ipa-ad-hoc \
    -exportOptionsPlist ./exportOptions/ad-hoc.plist \
    -allowProvisioningUpdates

The above compilation will definitely fail because you are missing two files app-store.plist and ad-hoc.plist. You can actually find this yourself, that is, in the folder that is packaged and Exported in xcode, there will be an ExportOptions.plist file

How does react-native implement automatic packaging? React-native automatic packaging method
According to whether you choose App Store or Ad Hoc when exporting, copy them into the project exportOptions/app-store.plist andexportOptions/ad-hoc.plist

Upload Dandelion

The Dandelion used by the author, fir readers can find it themselves

PGY_API_KEY=你的api_key
PGY_HOST=https://www.pgyer.com/apiv2/app/upload

# ios
IPA=`ls ./ios/build/ipa-ad-hoc/*.ipa`
curl \ 
    --form "file=@$IPA" \
    --form "_api_key=$PGY_API_KEY" \
    $PGY_HOST
    
# android
curl \ 
    --form "file=@./android/app/build/outputs/apk/app-release.apk" \
    --form "_api_key=$PGY_API_KEY" \
    $PGY_HOST

Upload to AppStore

In fact, it is uploaded to appstoreconnect.apple.com first, which is the same as when you click Upload To App Store in xcode

Verify first whether it can be uploaded

APP_STORE_ACCOUNT=证书创建者账号
APP_STORE_PASSWORD=密码
IPA=`ls ./ios/build/ipa-app-store/*.ipa`

/Applications/Xcode.app/Contents/Applications/Application\ Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Versions/A/Support/altool \
    --validate-app \
    --file "$IPA" \
    --type ios \
    --username $APP_STORE_ACCOUNT \
    --password $APP_STORE_PASSWORD

You can only upload if the verification is successful, otherwise the upload will fail. No need to waste time

APP_STORE_ACCOUNT=证书创建者账号
APP_STORE_PASSWORD=密码
IPA=`ls ./ios/build/ipa-app-store/*.ipa`

# xcode临时生成的目录,不删除可能导致上传到appStore时失败
rm -rf ~/.itmstransporter/ ~/.old_itmstransporter/

# 开始上传
/Applications/Xcode.app/Contents/Applications/Application\ Loader.app/Contents/Frameworks/ITunesSoftwareService.framework/Versions/A/Support/altool \
    --upload-app \
    --file "$IPA" \
    --type ios \
    --username $APP_STORE_ACCOUNT \
    --password $APP_STORE_PASSWORD

Upload android

From the author's research, only Xiaomi application upload is provided Interface, other application platforms must be uploaded manually.

Notes:

1. A certificate needs to be generated on each node machine. You need to generate it manually, or use xcode to automatically generate it for you. If you don't do this step, you can't package ios
2. For the first few times of packaging, mac will prompt you to enter the password. You need to enter it in time, and be sure to click the button to always allow
3. If you use gitlab-runner, then in. Using alias altool=xx in gitlab-ci.yml will be invalid, that is, altool cannot be recognized. I don’t know why.
4. You must use macos system for ios packaging. Trying to use linux will not be worth the gain. You can use linux for android packaging, but it's also very troublesome, so why not do it with ios?
5. If macos is used as an automatically built sub-node, remember to make a startup script start.sh and add the script to the user-managed startup items. This sh file needs to be right-clicked to open the display introduction, and then set the opening method to terminal

How does react-native implement automatic packaging? React-native automatic packaging method

How does react-native implement automatic packaging? React-native automatic packaging method

## Recommended related articles:

Analysis of meta information meta tag attributes in HTML (with code)

About Gao Display of the basic controls of the German map WEB version

The above is the detailed content of How does react-native implement automatic packaging? React-native automatic packaging method. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
HTML as a Markup Language: Its Function and PurposeHTML as a Markup Language: Its Function and PurposeApr 22, 2025 am 12:02 AM

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

The Future of HTML, CSS, and JavaScript: Web Development TrendsThe Future of HTML, CSS, and JavaScript: Web Development TrendsApr 19, 2025 am 12:02 AM

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

HTML: The Structure, CSS: The Style, JavaScript: The BehaviorHTML: The Structure, CSS: The Style, JavaScript: The BehaviorApr 18, 2025 am 12:09 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The Future of HTML: Evolution and Trends in Web DesignThe Future of HTML: Evolution and Trends in Web DesignApr 17, 2025 am 12:12 AM

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

HTML vs. CSS vs. JavaScript: A Comparative OverviewHTML vs. CSS vs. JavaScript: A Comparative OverviewApr 16, 2025 am 12:04 AM

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTML: Is It a Programming Language or Something Else?HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AM

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.