Eject the native projects
Ejecting writes the generated Xcode and Android Studio projects into your project, so you can change anything in them. It's a last resort:
- For Swift or Kotlin of your own, a native module or a native element, add a native plugin instead. The builder keeps generating the projects.
- Eject for a native change neither covers, such as adding a native library.
This writes the generated projects into ios/ and android/ at your project root. From then on you edit them in Xcode or Android Studio, and commit them. ng build --platform builds those folders as they are, with your latest bundle and signing.
What it costs
Ejecting is one-way, and it costs you:
- The identity options stop applying. Name, ID, version, icon, permissions and the rest now live in the native projects. The signing options still apply.
- Device features stay as they were. A project keeps the features that were on when you ejected it, with their permissions, until you take them out of the native projects. A project ejected without the
bluetoothpermission has no Bluetooth module, so adding Bluetooth later is a native change, with the module's reasons inios/App/PrivacyInfo.xcprivacy, the app's privacy manifest. See Ejected apps. - Upkeep becomes your job. New Lynx versions, new Xcode versions and Google Play's yearly requirements no longer arrive with AngularLynx updates.
- The native modules AngularLynx calls can change with an update. An ejected project keeps the ones it was ejected with. When the release notes say a module changed, copy the new one from
@blotch/angular-lynx-native'stemplatesfolder into the native project, with any changes you made to it. For example,LynxMotion's watches get nothing from an olderMotionModule, which hasstartandstoprather thanaddWatchandremoveWatch. - You need native knowledge to change the projects.
Things to know
- Android's release build runs R8, which removes and renames Java and Kotlin it can't see used. Code you add that's only reached by name, through reflection or from native code, needs keep rules in
android/app/proguard-rules.pro. A native module that extendsLynxModuleis kept already. - A project ejected before the build wrote the privacy manifest has none. Add
ios/App/PrivacyInfo.xcprivacyyourself, or App Store Connect can refuse the upload (ITMS-91053). To get one, moveios/aside, eject iOS alone again (ng generate @blotch/angular-lynx:eject --platform ios, which leavesandroid/as it is), and copy the newios/App/PrivacyInfo.xcprivacyinto yours. Then put yourios/back. The copy has the reasons for the modules your current angular.json keeps, which may not be the ones yourios/App/has. Make it match: add the reasons of each module yourios/App/has that the copy lacks, and take a reason out only when no module you keep needs it (35F9.1, for example, is Bluetooth's, the audio recorder's and motion's):LocalStorageModule.swiftandDevServer.swift:NSPrivacyAccessedAPICategoryUserDefaults,CA92.1BluetoothModule.swiftandAudioRecorderModule.swift:NSPrivacyAccessedAPICategorySystemBootTime,35F9.1MotionModule.swift:NSPrivacyAccessedAPICategorySystemBootTime,35F9.1and8FFB.1
ng serve --platformbuilds the ejected project too. On a real iPhone, addNSLocalNetworkUsageDescriptionto its Info.plist, so iOS can say why the app reaches your Mac. See On a real iPhone.
Go back
To go back to the generated project, delete the folder.
