# React Native 0.87 va SwiftPM nam 2026: Build iOS Hien Dai va Cau Hoi Phong Van > Huong dan day du ve React Native 0.87 voi ho tro Swift Package Manager cho build iOS. Tim hieu cach chuyen doi tu CocoaPods, Strict TypeScript API va cac cau hoi phong van ky thuat. - Published: 2026-09-03 - Updated: 2026-09-03 - Author: Anthony Fillion-Maillet - Reading time: 5 min --- React Native 0.87, phat hanh ngay 11 thang 8 nam 2026, mang den ho tro thu nghiem Swift Package Manager (SwiftPM) cho build iOS, danh dau buoc dau tien huong toi viec loai bo CocoaPods khoi cac du an React Native. Phien ban nay cung dat Strict TypeScript API lam mac dinh, tich hop Metro 0.87 voi toc do tao source map nhanh gap 2 lan, va nang yeu cau toolchain toi thieu len Node.js 22, Kotlin 2.0, va Android compileSdk 37. > **Thiet Lap SwiftPM Chi Voi Mot Lenh** > > Sau khi go bo CocoaPods, chay `npx react-native spm --deintegrate` mot lan. Du an sau do se tu dong lien ket cac dependency native trong moi lan build ma khong can `pod install`. ## Swift Package Manager Thay The CocoaPods Cho Cac Dependency iOS Ho tro SwiftPM trong React Native 0.87 la tuy chon va thu nghiem. CocoaPods van la trinh quan ly dependency mac dinh cho cac ung dung production. Duong dan SwiftPM su dung cung XCFramework da build san ma React Native da phat hanh, nen khong can tai them binary nao. Loi ich chinh: du an dua tren SwiftPM chi can Xcode. Ruby, Bundler va CocoaPods khong con can thiet tren may cua developer hoac pipeline CI. ```bash # ios-swiftpm-setup.sh # Step 1: Navigate to iOS directory cd ios # Step 2: Deintegrate CocoaPods and generate SwiftPM references npx react-native spm --deintegrate # Step 3: Open project in Xcode and build open MyApp.xcworkspace ``` Lenh `spm --deintegrate` chen cac tham chieu Swift package vao `.xcodeproj` hien co thay vi thay the file du an. Cac thiet lap code signing, build phases va capabilities van duoc giu nguyen. De hoan tac thay doi, chay `npx react-native spm deinit`. ## Cach Hoat Dong Cua SwiftPM Autolinking Ma Khong Can pod install Sau khi thiet lap ban dau, cac thay doi dependency se kich hoat viec lien ket lai tu dong. Cai dat hoac go bo native package bang npm hoac yarn, sau do build. Du an phat hien thay doi va chay lai autolinking trong giai doan build Xcode. ```bash # dependency-workflow.sh # Install a native dependency npm install react-native-reanimated # Build triggers automatic relinking npx react-native run-ios # No pod install required ``` Doi voi cac ban sao moi va moi truong CI, chay `npx react-native spm` mot lan truoc lan build dau tien. Dieu nay se tao file `Package.swift` va giai quyet cac dependency Swift package. ## Cac Han Che Cua SwiftPM va Muc Do San Sang Cho Production Ho tro SwiftPM trong phien ban 0.87 co nhung han che quan trong anh huong den quyet dinh ap dung: | Han Che | Tac Dong | |------------|--------| | Ho tro thu vien cong dong | Moi thu vien phai cung cap file `Package.swift` | | Do on dinh cua lenh | Cac flag va layout co the thay doi trong 0.88+ | | Cau hinh CI | Yeu cau buoc `npx react-native spm` truoc khi build | | Tai lieu | Nguon tai lieu xu ly su co con han che | Doi voi cac ung dung production, CocoaPods van la duong dan duoc khuyen nghi. Cac nhom danh gia SwiftPM nen tao prototype tren mot nhanh rieng va kiem tra toan bo cay dependency truoc khi cam ket chuyen doi. ## Thay Doi Lon: Import Header iOS Voi Namespace React Native 0.87 cung cap XCFramework moi: `ReactNativeHeaders.xcframework` va `ReactNativeDependenciesHeaders.xcframework`. Cac native module su dung angle include khong co namespace phai them tien to `React/`. ```objective-c // AppDelegate.m // Before 0.87 - bare include #import #import #import // After 0.87 - namespaced include #import #import #import ``` Thay doi nay ap dung cho ca build CocoaPods va SwiftPM. Cac du an co native module tuy chinh can cap nhat tat ca cac import header truoc khi nang cap. ## Strict TypeScript API: Interface JavaScript Mac Dinh Moi Strict TypeScript API, duoc gioi thieu trong phien ban 0.80, tro thanh mac dinh trong phien ban 0.87. Cac type bay gio duoc tao truc tiep tu source code React Native, loai bo su khong nhat quan giua cac dinh nghia TypeScript va hanh vi runtime thuc te. ```typescript // component-refs.tsx import { useRef } from 'react'; import { View, TextInput, ViewInstance, TextInputInstance } from 'react-native'; export function FormComponent() { // New dedicated ref types replace generic RefObject const containerRef = useRef(null); const inputRef = useRef(null); const focusInput = () => { // Type-safe method access inputRef.current?.focus(); }; return ( ); } ``` Ba thay doi type gay ra loi can duoc chu y trong qua trinh chuyen doi: 1. **Deep import bi chan**: Duong dan `react-native/Libraries/*` bay gio tao ra loi type. Tat ca export phai den tu package goc `react-native`. 2. **Cap nhat ref type**: `ViewInstance` va `TextInputInstance` thay the cac generic ref types. Cac type alias `*Properties` bi xoa va thay the bang `*Props`. 3. **Thay doi useColorScheme**: Tra ve `ColorSchemeName | null` thay vi gia tri chuoi `'unspecified'` truoc day. ## Tu Choi Strict TypeScript Trong Qua Trinh Chuyen Doi Cac nhom can them thoi gian de chuyen doi co the khoi phuc legacy deep import cho den React Native 0.88: ```json // tsconfig.json { "extends": "@react-native/typescript-config", "compilerOptions": { "customConditions": ["react-native", "react-native-legacy-deep-imports"] } } ``` Loi thoat nay se bi loai bo trong React Native 0.89. Cac du an nen uu tien chuyen doi truoc phien ban do. ## Metro 0.87: Source Map Nhanh Gap 2 Lan va Giam 50% Bo Nho Metro bundler phien ban 0.87 di kem voi nhung cai tien hieu suat dang ke anh huong den workflow phat trien va thoi gian khoi dong React Native DevTools. Viec tao source map nhanh hon 2 lan nho toi uu hoa xu ly chuoi. DevTools bay gio tai nhanh hon vi source map duoc tao hieu qua hon trong qua trinh build phat trien. Muc su dung bo nho giam 50% thong qua luu tru source map hieu qua hon. Dieu nay quan trong doi voi cac codebase lon noi Metro truoc day tieu thu RAM dang ke trong cac phien phat trien dai. Cac thay doi Metro bo sung: - Ho tro on dinh cho file cau hinh TypeScript (`metro.config.mts`) - Ho tro file cau hinh ESM cung voi CommonJS - Package self-resolve trong resolver - Loai bo ho tro cho phan mo rong file `.es6` va file cau hinh YAML ## Yeu Cau Toolchain Toi Thieu Cho React Native 0.87 Phien ban nay nang yeu cau phien ban toi thieu trong toan bo toolchain. Pipeline CI va moi truong developer can cap nhat truoc khi nang cap. | Yeu Cau | Phien Ban | |-------------|-------| | Node.js | >= 22.13.0 | | Kotlin | >= 2.0 (bundled: 2.2.0) | | Android minCompileSdk | 34 | | Android compileSdk | 37 | | Android Gradle Plugin | 9.x | Doi voi cac van de tuong thich AGP 9, them opt-out vao `android/gradle.properties`: ```properties # android/gradle.properties # Temporary opt-outs for AGP 9 migration android.builtInKotlin=false android.newDsl=false ``` ## API Bi Loai Bo Trong React Native 0.87 Mot so API deprecated bi loai bo trong phien ban nay. Cac du an su dung nhung API nay can tai cau truc truoc khi nang cap. | API Bi Loai Bo | Thay The | |-------------|----------| | `InteractionManager` | `requestIdleCallback` | | `Modal` animated prop | Su dung default transition behavior | | `NativeMethods` type | `HostInstance` | | `useTurboModules` flag | Luon kich hoat, flag bi loai bo | | `Touchable` root export | Extend `ViewProps` truc tiep | | `react-native/rn-get-polyfills` | `@react-native/js-polyfills` | Cac deprecation bo sung nham muc tieu loai bo trong tuong lai bao gom `ImageBackground` (su dung `View` voi `Image` dinh vi absolute), `DrawerLayoutAndroid` (su dung [react-native-drawer-layout](https://github.com/react-navigation/react-navigation/tree/main/packages/drawer)), va `react-native/Libraries/Core/InitializeCore` (su dung `react-native/setup-env`). ## Cau Hoi Phong Van React Native 0.87 Cho Developer Cap Cao Nhung cau hoi nay xuat hien trong cac cuoc phong van mobile developer cap cao sau cac phien ban lon cua React Native. Hieu cac quyet dinh kien truc dang sau ho tro SwiftPM va Strict TypeScript API the hien kien thuc cap framework. **Q: Tai sao React Native 0.87 gioi thieu SwiftPM la thu nghiem thay vi thay the CocoaPods ngay lap tuc?** Ho tro SwiftPM phu thuoc vao cac thu vien cong dong cung cap file `Package.swift`. Khong giong nhu CocoaPods noi co registry `Podspec` tap trung, SwiftPM yeu cau moi tac gia thu vien them cau hinh Swift package native. Giai doan thu nghiem cho phep he sinh thai ap dung SwiftPM dan dan trong khi CocoaPods van on dinh cho cac ung dung production. Ngoai ra, cac lenh CLI va layout du an duoc tao co the thay doi dua tren phan hoi cua developer truoc khi on dinh. **Q: Van de gi ma Strict TypeScript API giai quyet ma cac dinh nghia type duoc bao tri thu cong khong the?** Cac dinh nghia type duoc bao tri thu cong co the khac voi hanh vi runtime giua cac phien ban. Cac tai cau truc noi bo thay doi function signature hoac them tham so co the khong duoc phan anh trong type ngay lap tuc, gay ra crash runtime ma TypeScript le ra phai bat duoc. Strict API tao type truc tiep tu source code, lam cho type tro thanh quyen uy thay vi nguyen vong. No cung chan deep import truy cap API noi bo khong on dinh, ngan chan hong hoc khi cac noi bo do thay doi. **Q: SwiftPM autolinking khac voi CocoaPods autolinking trong React Native nhu the nao?** CocoaPods autolinking chay trong `pod install`, ma developer phai nho de thuc hien sau khi thay doi dependency. SwiftPM autolinking chay trong giai doan build Xcode tu dong. He thong build phat hien thay doi dependency va tai tao package manifest ma khong can can thiep thu cong. Dieu nay loai bo nguon gay ra van de "works on my machine" pho bien khi developer quen chay `pod install` sau khi pull thay doi. De chuan bi phong van React Native them, xem [native modules deep dive](/technologies/react-native/interview-questions/rn-native-modules) va ngan hang cau hoi [testing strategies](/technologies/react-native/interview-questions/rn-testing). ## Chien Luoc Nang Cap Cho Du An React Native 0.87 [React Native Upgrade Helper](https://react-native-community.github.io/upgrade-helper/) tao diff giua template du an hien tai va 0.87. Diff nay cho thay chinh xac file nao can thay doi. Uu tien cac buoc chuyen doi sau: 1. **Cap nhat Node.js len 22.13.0+** va xac minh moi truong CI khop 2. **Chay bien dich TypeScript** de xac dinh vi pham deep import 3. **Cap nhat ref types** tu generic sang dedicated instance types 4. **Cap nhat iOS header import** sang dinh dang co namespace 5. **Kiem tra toan bo cay native dependency** truoc khi kich hoat SwiftPM Doi voi cac du an Expo, React Native 0.87 co san trong cac phien ban `expo@canary`. Cac du an Expo production nen doi phien ban SDK on dinh. ## Y Nghia Cua Ho Tro SwiftPM 0.87 Doi Voi Thoi Gian Build iOS SwiftPM loai bo `pod install` khoi workflow phat trien, nhung thiet lap du an ban dau mat nhieu thoi gian hon. Lenh `npx react-native spm` giai quyet Swift package tu source, mat nhieu thoi gian hon so voi tai binary CocoaPods da build san. Cac lan build tiep theo duoc huong loi tu viec giai quyet package tang dan cua Xcode. Chi cac package thay doi moi duoc tai lai. Doi voi cac nhom co su thay doi dependency thuong xuyen, cach tiep can tang dan nay co the nhanh hon cac chu ky `pod install` lap di lap lai. Toi uu hoa CI khac nhau giua hai cach tiep can. CocoaPods cache thu muc `Pods/` hieu qua. SwiftPM cache thong qua derived data Xcode, yeu cau chien luoc cache key khac. Cac nhom chuyen doi pipeline CI nen danh gia ca hai cach tiep can voi tap hop dependency cu the cua ho. De biet cac ky thuat toi uu hoa build iOS lien quan, xem [huong dan React Native New Architecture](/blog/react-native/react-native-new-architecture-hermes-v1-bridgeless) bao gom dac tinh hieu suat Hermes V1 va bridgeless mode. --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/vi/blog/react-native/react-native-087-swiftpm-ios-build-interview-questions