@@ -82,6 +82,14 @@ export async function copy(
8282 usesCapacitorPortals = true ;
8383 }
8484
85+ let usesLiveUpdates = false ;
86+ if (
87+ allPlugins . filter ( plugin => plugin . id === '@capacitor/live-updates' )
88+ . length > 0
89+ ) {
90+ usesLiveUpdates = true ;
91+ }
92+
8593 if ( platformName === config . ios . name ) {
8694 if ( usesCapacitorPortals ) {
8795 await copyFederatedWebDirs ( config , await config . ios . webDirAbs ) ;
@@ -92,6 +100,9 @@ export async function copy(
92100 config . app . webDirAbs ,
93101 ) ;
94102 }
103+ if ( usesLiveUpdates ) {
104+ await copySecureLiveUpdatesKey ( config , config . ios . nativeTargetDirAbs ) ;
105+ }
95106 await copyCapacitorConfig ( config , config . ios . nativeTargetDirAbs ) ;
96107 const cordovaPlugins = await getCordovaPlugins ( config , platformName ) ;
97108 await handleCordovaPluginsJS ( cordovaPlugins , config , platformName ) ;
@@ -105,6 +116,9 @@ export async function copy(
105116 config . app . webDirAbs ,
106117 ) ;
107118 }
119+ if ( usesLiveUpdates ) {
120+ await copySecureLiveUpdatesKey ( config , config . android . assetsDirAbs ) ;
121+ }
108122 await copyCapacitorConfig ( config , config . android . assetsDirAbs ) ;
109123 const cordovaPlugins = await getCordovaPlugins ( config , platformName ) ;
110124 await handleCordovaPluginsJS ( cordovaPlugins , config , platformName ) ;
@@ -207,3 +221,34 @@ function isPortal(config: any): config is Portal {
207221 ( config as Portal ) . name !== undefined
208222 ) ;
209223}
224+
225+ async function copySecureLiveUpdatesKey ( config : Config , nativeAbsDir : string ) {
226+ if ( ! config . app . extConfig ?. plugins ?. LiveUpdates ?. key ) {
227+ return ;
228+ }
229+
230+ const secureLiveUpdatesKeyFile = config . app . extConfig . plugins . LiveUpdates . key ;
231+ const keyAbsFromPath = join ( config . app . rootDir , secureLiveUpdatesKeyFile ) ;
232+ const keyAbsToPath = join ( nativeAbsDir , basename ( keyAbsFromPath ) ) ;
233+ const keyRelToDir = relative ( config . app . rootDir , nativeAbsDir ) ;
234+
235+ if ( ! ( await pathExists ( keyAbsFromPath ) ) ) {
236+ logger . warn (
237+ `Cannot copy Secure Live Updates signature file from ${ c . strong (
238+ keyAbsFromPath ,
239+ ) } to ${ keyRelToDir } \n` +
240+ `Signature file does not exist at specified key path.` ,
241+ ) ;
242+
243+ return ;
244+ }
245+
246+ await runTask (
247+ `Copying Secure Live Updates key from ${ c . strong (
248+ secureLiveUpdatesKeyFile ,
249+ ) } to ${ keyRelToDir } `,
250+ async ( ) => {
251+ return fsCopy ( keyAbsFromPath , keyAbsToPath ) ;
252+ } ,
253+ ) ;
254+ }
0 commit comments