@rock-js/plugin-brownfield-ios
Advanced tools
| {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"} |
| {"version":3,"file":"copyHermesXcframework.d.ts","sourceRoot":"","sources":["../../../src/lib/copyHermesXcframework.ts"],"names":[],"mappings":"AAIA,wBAAgB,qBAAqB,CAAC,EACpC,SAAS,EACT,cAAc,EACd,kBAAkB,GACnB,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;CAC5B,QAyBA"} |
| {"version":3,"file":"pluginBrownfieldIos.d.ts","sourceRoot":"","sources":["../../../src/lib/pluginBrownfieldIos.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAEL,KAAK,UAAU,EAMhB,MAAM,iCAAiC,CAAC;AAazC,eAAO,MAAM,gBAAgB,GAC3B,MAAM,UAAU,EAChB,iGAOG;IACD,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,EACD,eAAe,gBAAgB,kBAgGhC,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC7B,eAAe,gBAAgB,MAC/B,KAAK,SAAS,KAAG,YAsBjB,CAAC;AAEJ,eAAe,mBAAmB,CAAC"} |
| export * from './lib/pluginBrownfieldIos.js'; | ||
| //# sourceMappingURL=index.d.ts.map |
@@ -6,1 +6,2 @@ export declare function copyHermesXcframework({ sourceDir, destinationDir, reactNativeVersion, }: { | ||
| }): void; | ||
| //# sourceMappingURL=copyHermesXcframework.d.ts.map |
| import type { IOSProjectConfig } from '@react-native-community/cli-types'; | ||
| import type { PluginApi, PluginOutput } from '@rock-js/config'; | ||
| import { type BuildFlags } from '@rock-js/platform-apple-helpers'; | ||
| export declare const packageIosAction: (args: BuildFlags, { projectRoot, reactNativePath, reactNativeVersion, usePrebuiltRNCore, skipCache, packageDir, }: { | ||
| projectRoot: string; | ||
| reactNativePath: string; | ||
| reactNativeVersion: string; | ||
| usePrebuiltRNCore: number | undefined; | ||
| skipCache?: boolean; | ||
| packageDir?: string; | ||
| }, pluginConfig?: IOSProjectConfig) => Promise<void>; | ||
| export declare const pluginBrownfieldIos: (pluginConfig?: IOSProjectConfig) => (api: PluginApi) => PluginOutput; | ||
| export default pluginBrownfieldIos; | ||
| //# sourceMappingURL=pluginBrownfieldIos.d.ts.map |
| import path from 'node:path'; | ||
| import { createBuild, genericDestinations, getBuildOptions, getBuildPaths, getValidProjectConfig, mergeFrameworks, } from '@rock-js/platform-apple-helpers'; | ||
| import { colorLink, intro, logger, outro, relativeToCwd } from '@rock-js/tools'; | ||
| import { buildApp, genericDestinations, getBuildOptions, getBuildPaths, getValidProjectConfig, mergeFrameworks, } from '@rock-js/platform-apple-helpers'; | ||
| import { colorLink, intro, logger, outro, relativeToCwd, RockError, } from '@rock-js/tools'; | ||
| import { copyHermesXcframework } from './copyHermesXcframework.js'; | ||
| const buildOptions = getBuildOptions({ platformName: 'ios' }); | ||
| export const packageIosAction = async (args, { projectRoot, reactNativePath, reactNativeVersion, usePrebuiltRNCore, skipCache, packageDir, }, pluginConfig) => { | ||
| intro('Packaging iOS project'); | ||
| // 1) Build the project | ||
| const iosConfig = getValidProjectConfig('ios', projectRoot, pluginConfig); | ||
| const destination = args.destination ?? [ | ||
| genericDestinations.ios.device, | ||
| genericDestinations.ios.simulator, | ||
| ]; | ||
| const buildFolder = args.buildFolder ?? getBuildPaths('ios').derivedDataDir; | ||
| const configuration = args.configuration ?? 'Debug'; | ||
| let scheme; | ||
| try { | ||
| const { appPath, ...buildAppResult } = await buildApp({ | ||
| projectRoot, | ||
| projectConfig: iosConfig, | ||
| platformName: 'ios', | ||
| args: { ...args, destination, buildFolder }, | ||
| reactNativePath, | ||
| brownfield: true, | ||
| usePrebuiltRNCore, | ||
| pluginConfig, | ||
| skipCache, | ||
| }); | ||
| logger.log(`Build available at: ${colorLink(relativeToCwd(appPath))}`); | ||
| scheme = buildAppResult.scheme; | ||
| } | ||
| catch (error) { | ||
| const message = `Failed to create ${args.archive ? 'archive' : 'build'}`; | ||
| throw new RockError(message, { cause: error }); | ||
| } | ||
| // 2) Merge the .framework outputs of the framework target | ||
| const productsPath = path.join(buildFolder, 'Build', 'Products'); | ||
| const frameworkTargetOutputDir = packageDir ?? getBuildPaths('ios').packageDir; | ||
| const { sourceDir } = iosConfig; | ||
| await mergeFrameworks({ | ||
| sourceDir, | ||
| frameworkPaths: [ | ||
| path.join(productsPath, `${configuration}-iphoneos`, `${scheme}.framework`), | ||
| path.join(productsPath, `${configuration}-iphonesimulator`, `${scheme}.framework`), | ||
| ], | ||
| outputPath: path.join(frameworkTargetOutputDir, `${scheme}.xcframework`), | ||
| }); | ||
| // 3) Merge React Native Brownfield paths | ||
| await mergeFrameworks({ | ||
| sourceDir, | ||
| frameworkPaths: [ | ||
| path.join(productsPath, `${configuration}-iphoneos`, 'ReactBrownfield', 'ReactBrownfield.framework'), | ||
| path.join(productsPath, `${configuration}-iphonesimulator`, 'ReactBrownfield', 'ReactBrownfield.framework'), | ||
| ], | ||
| outputPath: path.join(frameworkTargetOutputDir, 'ReactBrownfield.xcframework'), | ||
| }); | ||
| // 4) Copy hermes xcframework to the output path | ||
| copyHermesXcframework({ | ||
| sourceDir, | ||
| destinationDir: frameworkTargetOutputDir, | ||
| reactNativeVersion, | ||
| }); | ||
| // 5) Inform the user | ||
| logger.log(`XCFrameworks are available at: ${colorLink(relativeToCwd(frameworkTargetOutputDir))}`); | ||
| outro('Success 🎉.'); | ||
| }; | ||
| export const pluginBrownfieldIos = (pluginConfig) => (api) => { | ||
@@ -10,56 +71,8 @@ api.registerCommand({ | ||
| description: 'Emit a .xcframework file from React Native code.', | ||
| action: async (args) => { | ||
| intro('Packaging iOS project'); | ||
| // 1) Build the project | ||
| const projectRoot = api.getProjectRoot(); | ||
| const iosConfig = getValidProjectConfig('ios', projectRoot, pluginConfig); | ||
| const { derivedDataDir } = getBuildPaths('ios'); | ||
| const destination = args.destination ?? [ | ||
| genericDestinations.ios.device, | ||
| genericDestinations.ios.simulator, | ||
| ]; | ||
| const buildFolder = args.buildFolder ?? derivedDataDir; | ||
| const configuration = args.configuration ?? 'Debug'; | ||
| const { sourceDir } = iosConfig; | ||
| const { scheme } = await createBuild({ | ||
| platformName: 'ios', | ||
| projectConfig: iosConfig, | ||
| args: { ...args, destination, buildFolder }, | ||
| projectRoot, | ||
| reactNativePath: api.getReactNativePath(), | ||
| fingerprintOptions: api.getFingerprintOptions(), | ||
| brownfield: true, | ||
| remoteCacheProvider: await api.getRemoteCacheProvider(), | ||
| usePrebuiltRNCore: api.getUsePrebuiltRNCore(), | ||
| }); | ||
| // 2) Merge the .framework outputs of the framework target | ||
| const productsPath = path.join(buildFolder, 'Build', 'Products'); | ||
| const { packageDir: frameworkTargetOutputDir } = getBuildPaths('ios'); | ||
| await mergeFrameworks({ | ||
| sourceDir, | ||
| frameworkPaths: [ | ||
| path.join(productsPath, `${configuration}-iphoneos`, `${scheme}.framework`), | ||
| path.join(productsPath, `${configuration}-iphonesimulator`, `${scheme}.framework`), | ||
| ], | ||
| outputPath: path.join(frameworkTargetOutputDir, `${scheme}.xcframework`), | ||
| }); | ||
| // 3) Merge React Native Brownfield paths | ||
| await mergeFrameworks({ | ||
| sourceDir, | ||
| frameworkPaths: [ | ||
| path.join(productsPath, `${configuration}-iphoneos`, 'ReactBrownfield', 'ReactBrownfield.framework'), | ||
| path.join(productsPath, `${configuration}-iphonesimulator`, 'ReactBrownfield', 'ReactBrownfield.framework'), | ||
| ], | ||
| outputPath: path.join(frameworkTargetOutputDir, 'ReactBrownfield.xcframework'), | ||
| }); | ||
| // 4) Copy hermes xcframework to the output path | ||
| copyHermesXcframework({ | ||
| sourceDir, | ||
| destinationDir: frameworkTargetOutputDir, | ||
| reactNativeVersion: api.getReactNativeVersion(), | ||
| }); | ||
| // 5) Inform the user | ||
| logger.log(`XCFrameworks are available at: ${colorLink(relativeToCwd(frameworkTargetOutputDir))}`); | ||
| outro('Success 🎉.'); | ||
| }, | ||
| action: async (args) => packageIosAction(args, { | ||
| projectRoot: api.getProjectRoot(), | ||
| reactNativePath: api.getReactNativePath(), | ||
| reactNativeVersion: api.getReactNativeVersion(), | ||
| usePrebuiltRNCore: api.getUsePrebuiltRNCore(), | ||
| }, pluginConfig), | ||
| options: buildOptions, | ||
@@ -66,0 +79,0 @@ }); |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"pluginBrownfieldIos.js","sourceRoot":"","sources":["../../../src/lib/pluginBrownfieldIos.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAEL,WAAW,EACX,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,qBAAqB,EACrB,eAAe,GAChB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,MAAM,YAAY,GAAG,eAAe,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;AAE9D,MAAM,CAAC,MAAM,mBAAmB,GAC9B,CAAC,YAA+B,EAAE,EAAE,CACpC,CAAC,GAAc,EAAgB,EAAE;IAC/B,GAAG,CAAC,eAAe,CAAC;QAClB,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,kDAAkD;QAC/D,MAAM,EAAE,KAAK,EAAE,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S;gBACT,cAAc,EAAE;oBACd,IAAI,CAAC,IAAI,CACP,YAAY,EACZ,GAAG,aAAa,WAAW,EAC3B,GAAG,MAAM,YAAY,CACtB;oBACD,IAAI,CAAC,IAAI,CACP,YAAY,EACZ,GAAG,aAAa,kBAAkB,EAClC,GAAG,MAAM,YAAY,CACtB;iBACF;gBACD,UAAU,EAAE,IAAI,CAAC,IAAI,CACnB,wBAAwB,EACxB,GAAG,MAAM,cAAc,CACxB;aACF,CAAC,CAAC;YAEH,yCAAyC;YACzC,MAAM,eAAe,CAAC;gBACpB,SAAS;gBACT,cAAc,EAAE;oBACd,IAAI,CAAC,IAAI,CACP,YAAY,EACZ,GAAG,aAAa,WAAW,EAC3B,iBAAiB,EACjB,2BAA2B,CAC5B;oBACD,IAAI,CAAC,IAAI,CACP,YAAY,EACZ,GAAG,aAAa,kBAAkB,EAClC,iBAAiB,EACjB,2BAA2B,CAC5B;iBACF;gBACD,UAAU,EAAE,IAAI,CAAC,IAAI,CACnB,wBAAwB,EACxB,6BAA6B,CAC9B;aACF,CAAC,CAAC;YAEH,gDAAgD;YAChD,qBAAqB,CAAC;gBACpB,SAAS;gBACT,cAAc,EAAE,wBAAwB;gBACxC,kBAAkB,EAAE,GAAG,CAAC,qBAAqB,EAAE;aAChD,CAAC,CAAC;YAEH,qBAAqB;YACrB,MAAM,CAAC,GAAG,CACR,kCAAkC,SAAS,CACzC,aAAa,CAAC,wBAAwB,CAAC,CACxC,EAAE,CACJ,CAAC;YAEF,KAAK,CAAC,aAAa,CAAC,CAAC;QACvB,CAAC;QACD,OAAO,EAAE,YAAY;KACtB,CAAC,CAAC;IAEH,OAAO;QACL,IAAI,EAAE,uBAAuB;QAC7B,WAAW,EAAE,iCAAiC;KAC/C,CAAC;AACJ,CAAC,CAAC;AAEJ,eAAe,mBAAmB,CAAC"} | ||
| {"version":3,"file":"pluginBrownfieldIos.js","sourceRoot":"","sources":["../../../src/lib/pluginBrownfieldIos.ts"],"names":[],"mappings":"AAAA,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AAG,aAAa,kBAAkB,EAClC,iBAAiB,EACjB,2BAA2B,CAC5B;SACF;QACD,UAAU,EAAE,IAAI,CAAC,IAAI,CACnB,wBAAwB,EACxB,6BAA6B,CAC9B;KACF,CAAC,CAAC;IAEH,gDAAgD;IAChD,qBAAqB,CAAC;QACpB,SAAS;QACT,cAAc,EAAE,wBAAwB;QACxC,kBAAkB;KACnB,CAAC,CAAC;IAEH,qBAAqB;IACrB,MAAM,CAAC,GAAG,CACR,kCAAkC,SAAS,CACzC,aAAa,CAAC,wBAAwB,CAAC,CACxC,EAAE,CACJ,CAAC;IAEF,KAAK,CAAC,aAAa,CAAC,CAAC;AACvB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAC9B,CAAC,YAA+B,EAAE,EAAE,CACpC,CAAC,GAAc,EAAgB,EAAE;IAC/B,GAAG,CAAC,eAAe,CAAC;QAClB,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,kDAAkD;QAC/D,MAAM,EAAE,KAAK,EAAE,IAAgB,EAAE,EAAE,CACjC,gBAAgB,CACd,IAAI,EACJ;YACE,WAAW,EAAE,GAAG,CAAC,cAAc,EAAE;YACjC,eAAe,EAAE,GAAG,CAAC,kBAAkB,EAAE;YACzC,kBAAkB,EAAE,GAAG,CAAC,qBAAqB,EAAE;YAC/C,iBAAiB,EAAE,GAAG,CAAC,oBAAoB,EAAE;SAC9C,EACD,YAAY,CACb;QACH,OAAO,EAAE,YAAY;KACtB,CAAC,CAAC;IAEH,OAAO;QACL,IAAI,EAAE,uBAAuB;QAC7B,WAAW,EAAE,iCAAiC;KAC/C,CAAC;AACJ,CAAC,CAAC;AAEJ,eAAe,mBAAmB,CAAC"} |
+4
-4
| { | ||
| "name": "@rock-js/plugin-brownfield-ios", | ||
| "version": "0.12.4", | ||
| "version": "0.12.5", | ||
| "description": "Plugin for integrating Rock projects with existing iOS apps", | ||
@@ -25,8 +25,8 @@ "type": "module", | ||
| "@react-native-community/cli-types": "^20.0.0", | ||
| "@rock-js/tools": "^0.12.4", | ||
| "@rock-js/platform-apple-helpers": "^0.12.4", | ||
| "@rock-js/tools": "^0.12.5", | ||
| "@rock-js/platform-apple-helpers": "^0.12.5", | ||
| "tslib": "^2.3.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@rock-js/config": "^0.12.4" | ||
| "@rock-js/config": "^0.12.5" | ||
| }, | ||
@@ -33,0 +33,0 @@ "publishConfig": { |
@@ -5,4 +5,4 @@ import path from 'node:path'; | ||
| import { | ||
| buildApp, | ||
| type BuildFlags, | ||
| createBuild, | ||
| genericDestinations, | ||
@@ -14,3 +14,10 @@ getBuildOptions, | ||
| } from '@rock-js/platform-apple-helpers'; | ||
| import { colorLink, intro, logger, outro, relativeToCwd } from '@rock-js/tools'; | ||
| import { | ||
| colorLink, | ||
| intro, | ||
| logger, | ||
| outro, | ||
| relativeToCwd, | ||
| RockError, | ||
| } from '@rock-js/tools'; | ||
| import { copyHermesXcframework } from './copyHermesXcframework.js'; | ||
@@ -20,105 +27,134 @@ | ||
| export const pluginBrownfieldIos = | ||
| (pluginConfig?: IOSProjectConfig) => | ||
| (api: PluginApi): PluginOutput => { | ||
| api.registerCommand({ | ||
| name: 'package:ios', | ||
| description: 'Emit a .xcframework file from React Native code.', | ||
| action: async (args: BuildFlags) => { | ||
| intro('Packaging iOS project'); | ||
| export const packageIosAction = async ( | ||
| args: BuildFlags, | ||
| { | ||
| projectRoot, | ||
| reactNativePath, | ||
| reactNativeVersion, | ||
| usePrebuiltRNCore, | ||
| skipCache, | ||
| packageDir, | ||
| }: { | ||
| projectRoot: string; | ||
| reactNativePath: string; | ||
| reactNativeVersion: string; | ||
| usePrebuiltRNCore: number | undefined; | ||
| skipCache?: boolean; | ||
| packageDir?: string; | ||
| }, | ||
| pluginConfig?: IOSProjectConfig, | ||
| ) => { | ||
| intro('Packaging iOS project'); | ||
| // 1) Build the project | ||
| const projectRoot = api.getProjectRoot(); | ||
| const iosConfig = getValidProjectConfig( | ||
| 'ios', | ||
| projectRoot, | ||
| pluginConfig, | ||
| ); | ||
| const { derivedDataDir } = getBuildPaths('ios'); | ||
| // 1) Build the project | ||
| const iosConfig = getValidProjectConfig('ios', projectRoot, pluginConfig); | ||
| const destination = args.destination ?? [ | ||
| genericDestinations.ios.device, | ||
| genericDestinations.ios.simulator, | ||
| ]; | ||
| const destination = args.destination ?? [ | ||
| genericDestinations.ios.device, | ||
| genericDestinations.ios.simulator, | ||
| ]; | ||
| const buildFolder = args.buildFolder ?? getBuildPaths('ios').derivedDataDir; | ||
| const configuration = args.configuration ?? 'Debug'; | ||
| let scheme; | ||
| const buildFolder = args.buildFolder ?? derivedDataDir; | ||
| const configuration = args.configuration ?? 'Debug'; | ||
| try { | ||
| const { appPath, ...buildAppResult } = await buildApp({ | ||
| projectRoot, | ||
| projectConfig: iosConfig, | ||
| platformName: 'ios', | ||
| args: { ...args, destination, buildFolder }, | ||
| reactNativePath, | ||
| brownfield: true, | ||
| usePrebuiltRNCore, | ||
| pluginConfig, | ||
| skipCache, | ||
| }); | ||
| logger.log(`Build available at: ${colorLink(relativeToCwd(appPath))}`); | ||
| const { sourceDir } = iosConfig; | ||
| scheme = buildAppResult.scheme; | ||
| } catch (error) { | ||
| const message = `Failed to create ${args.archive ? 'archive' : 'build'}`; | ||
| throw new RockError(message, { cause: error }); | ||
| } | ||
| const { scheme } = await createBuild({ | ||
| platformName: 'ios', | ||
| projectConfig: iosConfig, | ||
| args: { ...args, destination, buildFolder }, | ||
| projectRoot, | ||
| reactNativePath: api.getReactNativePath(), | ||
| fingerprintOptions: api.getFingerprintOptions(), | ||
| brownfield: true, | ||
| remoteCacheProvider: await api.getRemoteCacheProvider(), | ||
| usePrebuiltRNCore: api.getUsePrebuiltRNCore(), | ||
| }); | ||
| // 2) Merge the .framework outputs of the framework target | ||
| const productsPath = path.join(buildFolder, 'Build', 'Products'); | ||
| const frameworkTargetOutputDir = | ||
| packageDir ?? getBuildPaths('ios').packageDir; | ||
| const { sourceDir } = iosConfig; | ||
| // 2) Merge the .framework outputs of the framework target | ||
| const productsPath = path.join(buildFolder, 'Build', 'Products'); | ||
| const { packageDir: frameworkTargetOutputDir } = getBuildPaths('ios'); | ||
| await mergeFrameworks({ | ||
| sourceDir, | ||
| frameworkPaths: [ | ||
| path.join( | ||
| productsPath, | ||
| `${configuration}-iphoneos`, | ||
| `${scheme}.framework`, | ||
| ), | ||
| path.join( | ||
| productsPath, | ||
| `${configuration}-iphonesimulator`, | ||
| `${scheme}.framework`, | ||
| ), | ||
| ], | ||
| outputPath: path.join(frameworkTargetOutputDir, `${scheme}.xcframework`), | ||
| }); | ||
| await mergeFrameworks({ | ||
| sourceDir, | ||
| frameworkPaths: [ | ||
| path.join( | ||
| productsPath, | ||
| `${configuration}-iphoneos`, | ||
| `${scheme}.framework`, | ||
| ), | ||
| path.join( | ||
| productsPath, | ||
| `${configuration}-iphonesimulator`, | ||
| `${scheme}.framework`, | ||
| ), | ||
| ], | ||
| outputPath: path.join( | ||
| frameworkTargetOutputDir, | ||
| `${scheme}.xcframework`, | ||
| ), | ||
| }); | ||
| // 3) Merge React Native Brownfield paths | ||
| await mergeFrameworks({ | ||
| sourceDir, | ||
| frameworkPaths: [ | ||
| path.join( | ||
| productsPath, | ||
| `${configuration}-iphoneos`, | ||
| 'ReactBrownfield', | ||
| 'ReactBrownfield.framework', | ||
| ), | ||
| path.join( | ||
| productsPath, | ||
| `${configuration}-iphonesimulator`, | ||
| 'ReactBrownfield', | ||
| 'ReactBrownfield.framework', | ||
| ), | ||
| ], | ||
| outputPath: path.join( | ||
| frameworkTargetOutputDir, | ||
| 'ReactBrownfield.xcframework', | ||
| ), | ||
| }); | ||
| // 3) Merge React Native Brownfield paths | ||
| await mergeFrameworks({ | ||
| sourceDir, | ||
| frameworkPaths: [ | ||
| path.join( | ||
| productsPath, | ||
| `${configuration}-iphoneos`, | ||
| 'ReactBrownfield', | ||
| 'ReactBrownfield.framework', | ||
| ), | ||
| path.join( | ||
| productsPath, | ||
| `${configuration}-iphonesimulator`, | ||
| 'ReactBrownfield', | ||
| 'ReactBrownfield.framework', | ||
| ), | ||
| ], | ||
| outputPath: path.join( | ||
| frameworkTargetOutputDir, | ||
| 'ReactBrownfield.xcframework', | ||
| ), | ||
| }); | ||
| // 4) Copy hermes xcframework to the output path | ||
| copyHermesXcframework({ | ||
| sourceDir, | ||
| destinationDir: frameworkTargetOutputDir, | ||
| reactNativeVersion, | ||
| }); | ||
| // 4) Copy hermes xcframework to the output path | ||
| copyHermesXcframework({ | ||
| sourceDir, | ||
| destinationDir: frameworkTargetOutputDir, | ||
| reactNativeVersion: api.getReactNativeVersion(), | ||
| }); | ||
| // 5) Inform the user | ||
| logger.log( | ||
| `XCFrameworks are available at: ${colorLink( | ||
| relativeToCwd(frameworkTargetOutputDir), | ||
| )}`, | ||
| ); | ||
| // 5) Inform the user | ||
| logger.log( | ||
| `XCFrameworks are available at: ${colorLink( | ||
| relativeToCwd(frameworkTargetOutputDir), | ||
| )}`, | ||
| ); | ||
| outro('Success 🎉.'); | ||
| }; | ||
| outro('Success 🎉.'); | ||
| }, | ||
| export const pluginBrownfieldIos = | ||
| (pluginConfig?: IOSProjectConfig) => | ||
| (api: PluginApi): PluginOutput => { | ||
| api.registerCommand({ | ||
| name: 'package:ios', | ||
| description: 'Emit a .xcframework file from React Native code.', | ||
| action: async (args: BuildFlags) => | ||
| packageIosAction( | ||
| args, | ||
| { | ||
| projectRoot: api.getProjectRoot(), | ||
| reactNativePath: api.getReactNativePath(), | ||
| reactNativeVersion: api.getReactNativeVersion(), | ||
| usePrebuiltRNCore: api.getUsePrebuiltRNCore(), | ||
| }, | ||
| pluginConfig, | ||
| ), | ||
| options: buildOptions, | ||
@@ -125,0 +161,0 @@ }); |
@@ -10,4 +10,4 @@ { | ||
| "devDependencies": { | ||
| "@rock-js/plugin-brownfield-ios": "^0.12.4" | ||
| "@rock-js/plugin-brownfield-ios": "^0.12.5" | ||
| } | ||
| } |
52042
5.36%23
15%322
21.97%