This repository has been archived on 2022-03-12. You can view files and clone it, but cannot push or open issues or pull requests.

1 line
3.6 KiB
Plaintext
Raw Permalink Normal View History

2021-04-02 02:24:13 +03:00
{"version":3,"file":"XcodeProjectFile.js","sourceRoot":"","sources":["../../src/ios/XcodeProjectFile.ts"],"names":[],"mappings":";;;;;AAAA,wDAA0B;AAC1B,gDAAwB;AAGxB,wDAA0D;AAC1D,iDAA8E;AAE9E;;;;;;;;GAQG;AACU,QAAA,mBAAmB,GAI3B,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE;IACjD,OAAO,8BAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;QACvC,MAAM,WAAW,GAAG,0BAAc,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QAElE,MAAM,CAAC,UAAU,GAAG,qBAAqB,CAAC;YACxC,OAAO,EAAE,MAAM,CAAC,UAAU;YAC1B,iBAAiB,EAAE,MAAM,CAAC,UAAU,CAAC,mBAAmB;YACxD,YAAY,EAAE,QAAQ;YACtB,QAAQ,EAAE,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC;YAC1C,SAAS;SACV,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CAAC,EACpC,OAAO,EACP,iBAAiB,EACjB,QAAQ,EACR,YAAY,EACZ,SAAS,GAOV;IACC,MAAM,gBAAgB,GAAG,cAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;IAChE,IAAI,SAAS,IAAI,CAAC,kBAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;QACjD,kBAAkB;QAClB,kBAAE,CAAC,aAAa,CAAC,gBAAgB,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;KAC1D;IAED,UAAU;IACV,MAAM,SAAS,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEzC,sDAAsD;IACtD,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC9B,OAAO,GAAG,qCAAyB,CAAC;YAClC,QAAQ,EAAE,QAAQ;YAClB,SAAS;YACT,OAAO;SACR,CAAC,CAAC;KACJ;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AA/BD,sDA+BC","sourcesContent":["import fs from 'fs-extra';\nimport path from 'path';\n\nimport { ConfigPlugin, XcodeProject } from '../Plugin.types';\nimport { withXcodeProject } from '../plugins/ios-plugins';\nimport { addBuildSourceFileToGroup, getProjectName } from './utils/Xcodeproj';\n\n/**\n * Create a build source file and link it to Xcode.\n *\n * @param config\n * @param props.filePath relative to the build source folder. ex: `ViewController.swift` would be created in `ios/myapp/ViewController.swift`.\n * @param props.contents file contents to write.\n * @param props.overwrite should the contents overwrite any existing file in the same location on disk.\n * @returns\n */\nexport const withBuildSourceFile: ConfigPlugin<{\n filePath: string;\n contents: string;\n overwrite?: boolean;\n}> = (config, { filePath, contents, overwrite }) => {\n return withXcodeProject(config, config => {\n const projectName = getProjectName(config.modRequest.projectRoot);\n\n config.modResults = createBuildSourceFile({\n project: config.modResults,\n nativeProjectRoot: config.modRequest.platformProjectRoot,\n fileContents: contents,\n filePath: path.join(projectName, filePath),\n overwrite,\n });\n return config;\n });\n};\n\n/**\n * Add a source file to the Xcode project and write it to the file system.\n *\n * @param nativeProjectRoot absolute path to the native app root `user/app/ios`\n * @param filePath path relative to the `nativeProjectRoot` for the file to create `user/app/ios/myapp/foobar.swift`\n * @param fileContents string file contents to write to the `filePath`\n * @param overwrite should write file even if one already exists\n */\nexport function createBuildSourceFile({\n project,\n nativeProjectRoot,\n filePath,\n fileContents,\n overwrite,\n}: {\n project: XcodeProject;\n nativeProjectRoot: string;\n filePath: string;\n fileContents: string;\n overwrite?: boolean;\n}): XcodeProject {\n const absoluteFilePath = path.join(nativeProjectRoot, filePath);\n if (overwrite || !fs.existsSync(absoluteFilePath)) {\n // Create the file\n fs.writeFileSync(absoluteFilePath, fileContents, 'utf8');\n }\n\n // `myapp`\n const groupName = path.dirname(filePath);\n\n // Ensure the file is linked with Xcode resource files\n if (!project.hasFile(filePath)) {\n project = addBuildSourceFileToGroup({\n filepath: filePath,\n groupName,\n project,\n });\n }\n return project;\n}\n"]}