Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mattijsf committed Nov 1, 2017
0 parents commit fd5aed8
Show file tree
Hide file tree
Showing 15 changed files with 1,417 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"presets": ["react-native"],
"sourceMaps": true,
"env": {
"development": {
"plugins": [
"transform-inline-environment-variables"
]
}
}
}
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
10 changes: 10 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
'extends': [
'keystone-react',
],
'rules': {
'react/jsx-indent': 0,
'react/jsx-no-bind': 'off',
'react/jsx-boolean-value': 'off',
}
};
16 changes: 16 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!--
It's still early days for this package. It's entirely
likely that whatever you're trying to do is meant to be
supported, it's just that we haven't encountered your
type of environment before.
As such, please provide as much detail about your project
setup, folder structure, version of Node, etc as you can
to help get to the bottom of things as quickly as possible.
-->

### Steps to reproduce the behavior

### Expected behavior

### Actual behavior
12 changes: 12 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!--
Please make sure the following is filled in before submitting your Pull Request - thanks!
-->

## Description of changes



## Related issues (if any)

37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: node_js
node_js:
- "6"
script:
- yarn run lint
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 mattijsf

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
115 changes: 115 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# React Native Inhibit Warnings

Modified React Native modulus and silences warnings.

## Isn't this a really bad idea?

Yes.

## Why?

When using React Native with it's core / third party frameworks Xcode generated allot of warnings. Most of the warnings
aren't causing any harm and can be ignored for the time being. At the same time, these warnings obscure warnings from the
projects you're managing. Having a project with 100+ warnings, of which 1 or 2 are caused by your own code
is frustrating.

Don't get me wrong, these warnings should be properly fixed! But not in our day-to-day workspace :)

## What does it do?

It scans for `./node_modules/**/*.xcodeproj/project.pbxproj` files and applied the following changes to all build configurations:

- `GCC_WARN_INHIBIT_ALL_WARNINGS` = `YES`
- `RUN_CLANG_STATIC_ANALYZER` = `NO`
- `LastUpgradeCheck` = `9999`

## TODO

- Make flags configurable, especially the value of `LastUpgradeCheck` is ideal to specify explicitly.
- Allow adding / overwriting of any build settings
- Whitelist / Blacklist specific projects
- More? Let me know.

## Installation

```
yarn add --dev react-native-inhibit-warnings
```
or
```
npm install --save-dev react-native-inhibit-warnings
```

Once the package is installed in your project, you just need to configure it by adding a `postinstall` script which will re-run the script whenever you add or remove packages to/from your project:

```json
{
"name": "your-awesome-app",
"version": "1.0.0",
"scripts": {
"postinstall": "react-native-inhibit-warnings"
},
}
```

## What Then?
As long as `react-native-inhibit-warnings` has run whenever you add react native modules, you should be good to go.

## It's not working!

A good starting point for troubleshooting is:
- Completely quit Xcode.
- `rm -rf node_modules`
- `yarn` or `npm i`
- Re open Xcode
- Product -> Clean
- Run

If you're still having trouble, post an issue so we can look into it.

## Tested with the following RN versions

Folks using this module have confirmed the library works with the following React Native versions. If your version is not on the list and you have confirmed it works as expected please create a PR (you can even do it on github.com)

- 0.42.0
- 0.43.0
- 0.44.0
- 0.45.1

## Running Manually

You can run this package manually with `react-native-inhibit-warnings`.

The best way to give yourself a manual trigger for this is add to your `package.json` scripts section like so:

```json
{
"name": "your-awesome-app",
"version": "1.0.0",
"scripts": {
"inhibit-warnings": "react-native-inhibit-warnings",
"postinstall": "react-native-inhibit-warnings"
}
}
```

You can then `yarn run inhibit-warnings` or `npm run inhibit-warnings` which will run the cleanup scripts on demand.

## Uninstalling

If you decide this isn't working out for you, we'd love to know why and to try to fix it. Please [open an issue](https://github.com/mattijsf/react-native-inhibit-warnings/issues/new).

But if you still want to get rid of this and revert the changes to your project, you can follow these steps:

1. Quitting Xcode.
1. `rm -rf node_modules`
1. `yarn` or `npm i`
1. Re-open Xcode.

You're back to where you started!

## License

Licensed under the MIT License, Copyright © 2017 mattijsf.

See [LICENSE](./LICENSE) for more information.
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

require('./src/inhibit-warnings')();
44 changes: 44 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "react-native-inhibit-warnings",
"version": "1.0.1",
"description": "Silences various Xcode warnings from React Native modules",
"main": "index.js",
"bin": {
"react-native-inhibit-warnings": "index.js"
},
"scripts": {
"lint": "eslint .",
"lint-fix": "eslint . --fix"
},
"repository": {
"type": "git",
"url": "git+https://github.com/mattijsf/react-native-inhibit-warnings.git"
},
"keywords": [
"react",
"native",
"xcode",
"build",
"configuration",
"warnings"
],
"author": "mattijsf",
"license": "MIT",
"bugs": {
"url": "https://github.com/mattijsf/react-native-inhibit-warnings/issues"
},
"homepage": "https://github.com/mattijsf/react-native-inhibit-warnings#readme",
"dependencies": {
"chalk": "^1.1.3",
"glob": "^7.1.1",
"path": "^0.12.7",
"plist": "^2.0.1",
"xcode": "^0.9.1"
},
"devDependencies": {
"eslint": "^3.11.0",
"eslint-config-keystone": "^3.0.0",
"eslint-config-keystone-react": "^1.0.0",
"eslint-plugin-react": "^6.9.0"
}
}
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
inhibitWarnings: require('./inhibit-warnings'),
};
29 changes: 29 additions & 0 deletions src/inhibit-warnings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const chalk = require('chalk');
const path = require('path');

const utilities = require('./utilities');

function updateProject (project) {
console.log(chalk.gray(`${chalk.green('✔')} [inhibit-warnings]: in ${path.dirname(path.relative(process.cwd(), project.filepath))}`));

project.addBuildProperty('GCC_WARN_INHIBIT_ALL_WARNINGS', 'YES');
project.addBuildProperty('RUN_CLANG_STATIC_ANALYZER', 'NO');

const attributes = project.getFirstProject().firstProject.attributes;
attributes.LastUpgradeCheck = 9999;

return true;
}

module.exports = function findAndFix () {
// Find all of the pbxproj files we care about.
const pattern = './node_modules/**/*.xcodeproj/project.pbxproj';

utilities.updateProjectsMatchingGlob(pattern, (err, project) => {
if (err) {
return console.error(chalk.red('⃠ [inhibit-warnings]: Error!', err));
}

return updateProject(project);
});
};
Loading

0 comments on commit fd5aed8

Please sign in to comment.