Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
synackal opened this issue Feb 4, 2019 · 7 comments
Open

Comments

@synackal
Copy link

synackal commented Feb 4, 2019

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.

@thekevinbrown
Copy link
Owner

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?

@synackal
Copy link
Author

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

@thekevinbrown
Copy link
Owner

@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?

@synackal
Copy link
Author

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.

@thekevinbrown
Copy link
Owner

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)?

@synackal
Copy link
Author

synackal commented Mar 8, 2019

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.

@thekevinbrown
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants