thekevinbrown/react-native-schemes-manager

It would be nice to be able to pass parameters to react-native-xcode.sh

synackal opened this issue · 7 comments

Steps to reproduce the behavior

react-native-xcode.sh in the react package allows for the passing of parameters, e.g., path to index.js for ENTRY_FILE.

Expected behavior

Developer should be able to specify parameters.

Actual behavior

No option available.

I'm not particularly familiar with how this works, as I haven't used it before. In the vanilla version, do you edit the script step in XCode to accomplish this, or? Could you provide me with an example of what you're trying to accomplish?

Yep, I edit the script step. If you check out the react-native-xcode.sh or your variant it will allow for the entry file parameter:

if [[ -s "index.ios.js" ]]; then ENTRY_FILE=${1:-index.ios.js} else ENTRY_FILE=${1:-index.js} fi

So the build phase step could look like this:
export DEVELOPMENT_BUILD_CONFIGURATIONS="+(Debug)" export NODE_BINARY=node ../node_modules/react-native-schemes-manager/lib/react-native-xcode.sh ./src/index.js

@synackal, correct me if I'm wrong, but isn't that use case already catered for in the settings part of the config in package.json?

And you mean to pass 'nodeCommand' with a path to your existing script with the extra parameter in that settings object? Or is there an easier way? Heh, part of this request is exploratory because I wasn't sure if it was already covered by your current functionality and whether that would be the best way to handle it, i.e., isn't fragile across versions.

I'm talking about the stuff under the env key:

// Additional environment variables your code might need
// They will be set using an `export` right before the scheme manager script runs.

Does that do what you need?

If not, can you give me an example of what you're trying to achieve in terms of your project (not the steps to get there)?

I do not think either of our suggestions will work:

(1) Modify/Add the node command within the settings option
(2) Modify/Add the ENV values within the settings option

The reason why (1) doesn't work is because that modification doesn't replace the existing invocation of your react-native-xcode.sh call it just pre-pends whatever you pass into it; fix-script.js:32. I need to pass a parameter into react-native-xcode.sh.

The reason why (2) doesn't work is that because in react-native-xcode.sh:66-70 if I set the ENTRY_FILE environment variable it will be overwritten.

What I need to have happen (and what I am currently using as a work-around) is in my Xcode build phases I replace your Bundle React Native code and images step with:

export NODE_BINARY=node
../node_modules/react-native-schemes-manager/lib/react-native-xcode.sh ./src/index.js # <= notice this parameter passing

but by doing this I can't take advantage of having the fix-script being invoked and possibly missing potential additional behavior you may add in the future.

To answer you stated question, my goal is to bundle my JS code and assets from a different path and name than the default in the main script.

Apologies for taking a little while in getting back to you and also if I've missed anything outstandingly obvious.

Ah, I got what you're tying to do now.

The best way to do it would be to have a configuration option in package.json, perhaps packageRoot or bundlingRoot or something similar, then have the fix script action apply this for you if it's there, and output what it currently does if it's not. That should be a pretty easy PR to create I reckon.