EvanBacon / expo-apple-targets

Config Plugin to setup Apple targets
308 stars 30 forks source link

Fullstory build failure #38

Open eladgel opened 3 months ago

eladgel commented 3 months ago

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @bacons/apple-targets@0.0.5 for the project I'm working on.

When using this library at the same time as the Fullstory expo, your app will fail when building.

Why? This function is asynchronous:

const withXcodeChanges = (config, props) => {
    return (0, withXcparse_1.withXcodeProjectBeta)(config, (config) => {
        // @ts-ignore
        applyXcodeChanges(config, config.modResults, props);
        return config;
    });
};

The problem is the Info.plist doesn't get copied in time for the FS plugin to run, resulting in a build failure.

This results in the Build phase of this project being added after the FS one.

image

You also need to comment out that part in the FS RN plugin

image

After change image

I created this repo for easy reproducible scenario https://github.com/eladgel/fullstory-collision

Here is the diff that solved my problem:

diff --git a/node_modules/@bacons/apple-targets/build/index.js b/node_modules/@bacons/apple-targets/build/index.js
index 79eead5..e136ebd 100644
--- a/node_modules/@bacons/apple-targets/build/index.js
+++ b/node_modules/@bacons/apple-targets/build/index.js
@@ -15,6 +15,7 @@ const withTargetsDir = (config, { appleTeamId, root = "./targets", match = "*" }
         cwd: projectRoot,
         absolute: true,
     });
+
     targets.forEach((configPath) => {
         config = (0, withWidget_1.default)(config, {
             appleTeamId,
diff --git a/node_modules/@bacons/apple-targets/build/withXcodeChanges.js b/node_modules/@bacons/apple-targets/build/withXcodeChanges.js
index ef64d1b..c0786c8 100644
--- a/node_modules/@bacons/apple-targets/build/withXcodeChanges.js
+++ b/node_modules/@bacons/apple-targets/build/withXcodeChanges.js
@@ -879,6 +879,7 @@ async function applyXcodeChanges(config, project, props) {
             });
         }
         else {
+            console.log("Embedding extension in main app");
             mainAppTarget.createBuildPhase(xcode_1.PBXCopyFilesBuildPhase, {
                 dstSubfolderSpec: 13,
                 buildActionMask: 2147483647,
@@ -886,6 +887,12 @@ async function applyXcodeChanges(config, project, props) {
                 name: WELL_KNOWN_COPY_EXTENSIONS_NAME,
                 runOnlyForDeploymentPostprocessing: 0,
             });
+            mainAppTarget.createBuildPhase(xcode_1.PBXShellScriptBuildPhase,{
+                name: "Run FullStory Asset Uploader Patched",
+                shellPath: "/bin/sh",
+                shellScript: "${PODS_ROOT}/FullStory/tools/FullStoryCommandLine ${CONFIGURATION_BUILD_DIR}/${WRAPPER_NAME}",
+                
+            });
         }
     }
     const mainSourcesBuildPhase = mainAppTarget.getBuildPhase(xcode_1.PBXSourcesBuildPhase);

This issue body was partially generated by patch-package.