Skip to content

Commit 1f105df

Browse files
author
Chris Brody
authored
support React Native 0.61; drop React Native 0.59 (#244)
* generate example with React Native 0.61 by default * remove `react-native link` step (not needed since React Native 0.60) * prep: test with generate example for Android only (needed to help ensure `pod install` is not run on example, in case the module is for Android only) * do `pod install` in generated example for iOS * remove `pod install` step from manual post-create instructions * update generated Android view for React Native 0.60(+) * update template `devDependencies` for React Native 0.61 * minimum React Native 0.60 in template `peerDependencies` * documentation updates * update documentation for out-of-tree platforms (not supported by the generated example)
1 parent 77f14cd commit 1f105df

File tree

44 files changed

+875
-182
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+875
-182
lines changed

README.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,15 @@ This tool based on [`react-native-create-library`](https://www.npmjs.com/package
2828
### General status
2929

3030
- **React Native versions supported:**
31-
- recommended: `0.61`, `0.60` (see known quirks and issues below)
32-
- outdated: `0.59`
33-
- Known quirks & issues on React Native 0.60(+):
34-
- [issue #99](https://github.com/brodybits/create-react-native-module/issues/99) - additional `pod install` step needed for RN 0.60 on iOS
35-
- [issue #29](https://github.com/brodybits/create-react-native-module/issues/29) - View does not work with RN 0.60 on Android (quick patch needed)
36-
- React Native 0.60(+) currently not supported by Expo or react-native-windows
31+
- recommended: `0.61`
32+
- minimum (outdated): `0.60`
3733
- Platform fork support
3834
- tvOS platform fork
3935
- requires use of `--tvos-enabled` option as documented below
4036
- requires the [`react-native-tvos`](https://www.npmjs.com/package/react-native-tvos) fork, with minimum version of 0.60 ref: [react-native-community/react-native-tvos#11](https://github.com/react-native-community/react-native-tvos/issues/11)), [issue #95](https://github.com/brodybits/create-react-native-module/issues/95)
4137
- unstable with very limited testing, with limited if any active support from the primary maintainer [@brodybits](https://github.com/brodybits) (see [issue #127](https://github.com/brodybits/create-react-native-module/issues/127))
42-
- Out-of-tree platform support
38+
- Out-of-tree platforms
39+
- not supported by generated example
4340
- Windows - unstable (not tested, see [issue #23](https://github.com/brodybits/create-react-native-module/issues/23)); now deprecated and may be removed in the near future (see [issue #43](https://github.com/brodybits/create-react-native-module/issues/43))
4441
- for future consideration: macOS (see [issue #94](https://github.com/brodybits/create-react-native-module/issues/94))
4542
- Node.js pre-10 support is deprecated and will be removed in the near future (see [issue #38](https://github.com/brodybits/create-react-native-module/issues/38))
@@ -109,7 +106,7 @@ Options:
109106
--use-apple-networking [iOS] Use `AFNetworking` dependency as a sample in the podspec & use it from the iOS code
110107
--generate-example Generate an example project and links the library module to it, requires both react-native-cli and yarn to be installed globally
111108
--example-name <exampleName> Name for the example project (default: `example`)
112-
--example-react-native-version <version> React Native version for the generated example project (default: `react-native@0.59`)
109+
--example-react-native-version <version> React Native version for the generated example project (default: `react-native@0.61`)
113110
--write-example-podfile [iOS] EXPERIMENTAL FEATURE NOT SUPPORTED: write (or overwrite) example ios/Podfile
114111
-h, --help output usage information
115112
```

lib/cli-command.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const normalizedOptions = require('./normalized-options');
44

55
const createLibraryModule = require('./lib');
66

7-
const postCreateInstructions = ({ moduleName, exampleName, writeExamplePodfile }) => {
7+
const postCreateInstructions = ({ moduleName, exampleName }) => {
88
return `
99
====================================================
1010
YOU'RE ALL SET!
@@ -13,9 +13,6 @@ To build and run iOS example project, do:
1313
----
1414
cd ${moduleName}/${exampleName}
1515
yarn
16-
cd ios
17-
pod install # ${writeExamplePodfile ? `required` : `required starting with React Native 0.60`}
18-
cd ..
1916
react-native run-ios
2017
----
2118
`;
@@ -109,7 +106,7 @@ ${postCreateInstructions(createOptions)}`);
109106
}, {
110107
command: '--example-react-native-version [exampleReactNativeVersion]',
111108
description: 'React Native version for the generated example project',
112-
default: 'react-native@0.59',
109+
default: 'react-native@0.61',
113110
}, {
114111
command: '--write-example-podfile',
115112
description: '[iOS] EXPERIMENTAL FEATURE NOT SUPPORTED: write (or overwrite) example ios/Podfile',

lib/lib.js

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const DEFAULT_AUTHOR_EMAIL = '[email protected]';
2929
const DEFAULT_LICENSE = 'MIT';
3030
const DEFAULT_GENERATE_EXAMPLE = false;
3131
const DEFAULT_EXAMPLE_NAME = 'example';
32-
const DEFAULT_EXAMPLE_REACT_NATIVE_VERSION = 'react-native@0.59';
32+
const DEFAULT_EXAMPLE_REACT_NATIVE_VERSION = 'react-native@0.61';
3333

3434
const renderTemplateIfValid = (fs, root, template, templateArgs) => {
3535
// avoid throwing an exception in case there is no valid template.name member
@@ -142,6 +142,9 @@ const generateWithNormalizedOptions = ({
142142
throw new Error(
143143
`${yarnVersionCommand} failed; ${errorRemedyMessage}`);
144144
}
145+
146+
// NOTE: While the pod tool is also required for example on iOS,
147+
// react-native CLI will help the user install this tool if needed.
145148
}
146149

147150
console.info('CREATE: Generating the React Native library module');
@@ -235,8 +238,39 @@ const generateWithNormalizedOptions = ({
235238
console.error('Yarn failure for example, aborting');
236239
throw (e);
237240
}
238-
commandSync('react-native link', addLinkLibraryOptions);
239241

242+
// Since React Native 0.60, pod install must be done (again)
243+
// after adding the native library to the generated example.
244+
if (platforms.indexOf('ios') !== -1) {
245+
const iosExampleAppProjectPath =
246+
`${pathExampleApp}/ios`;
247+
248+
const podCommandOptions = {
249+
cwd: iosExampleAppProjectPath,
250+
stdio: 'inherit'
251+
};
252+
253+
// pod tool is needed at this point for iOS
254+
try {
255+
console.log(
256+
`check for valid pod version in ${iosExampleAppProjectPath}`);
257+
258+
commandSync('pod --version', podCommandOptions);
259+
} catch (e) {
260+
console.error('pod --version failure, aborting with broken example app');
261+
throw (e);
262+
}
263+
264+
console.log(
265+
`running pod install in ${iosExampleAppProjectPath}`);
266+
267+
try {
268+
commandSync('pod install', podCommandOptions);
269+
} catch (e) {
270+
console.error('pod install failure, aborting with broken example app');
271+
throw (e);
272+
}
273+
}
240274
return resolve();
241275
});
242276
});

templates/android.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,7 @@ public class ${name}Module extends ReactContextBaseJavaModule {
203203
204204
import android.view.View;
205205
206-
// AppCompatCheckBox import for React Native pre-0.60:
207-
import android.support.v7.widget.AppCompatCheckBox;
208-
// AppCompatCheckBox import for React Native 0.60(+):
209-
// import androidx.appcompat.widget.AppCompatCheckBox;
206+
import androidx.appcompat.widget.AppCompatCheckBox;
210207
211208
import com.facebook.react.uimanager.SimpleViewManager;
212209
import com.facebook.react.uimanager.ThemedReactContext;

templates/general.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@ ${name};
2727
const peerDependencies =
2828
`{
2929
"react": "^16.8.1",
30-
"react-native": ">=0.59.0-rc.0 <1.0.x"` +
30+
"react-native": ">=0.60.0-rc.0 <1.0.x"` +
3131
(withWindows
3232
? `,
33-
"react-native-windows": ">=0.59.0-rc.0 <1.0.x"`
33+
"react-native-windows": ">=0.60.0-0 <1.0.x"`
3434
: ``) + `
3535
}`;
3636

3737
const devDependencies =
3838
`{
39-
"react": "^16.8.3",
40-
"react-native": "^0.59.10"` +
39+
"react": "^16.9.0",
40+
"react-native": "^0.61.5"` +
4141
(withWindows
4242
? `,
43-
"react-native-windows": "^0.59.0-rc.1"`
43+
"react-native-windows": "^0.61.0-beta.5"`
4444
: ``) + `
4545
}`;
4646

tests/integration/cli/create/view/__snapshots__/cli-create-with-view.test.js.snap

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,7 @@ afterEvaluate { project ->
263263
264264
import android.view.View;
265265
266-
// AppCompatCheckBox import for React Native pre-0.60:
267-
import android.support.v7.widget.AppCompatCheckBox;
268-
// AppCompatCheckBox import for React Native 0.60(+):
269-
// import androidx.appcompat.widget.AppCompatCheckBox;
266+
import androidx.appcompat.widget.AppCompatCheckBox;
270267
271268
import com.facebook.react.uimanager.SimpleViewManager;
272269
import com.facebook.react.uimanager.ThemedReactContext;
@@ -672,11 +669,11 @@ RCT_EXPORT_MODULE()
672669
\\"readmeFilename\\": \\"README.md\\",
673670
\\"peerDependencies\\": {
674671
\\"react\\": \\"^16.8.1\\",
675-
\\"react-native\\": \\">=0.59.0-rc.0 <1.0.x\\"
672+
\\"react-native\\": \\">=0.60.0-rc.0 <1.0.x\\"
676673
},
677674
\\"devDependencies\\": {
678-
\\"react\\": \\"^16.8.3\\",
679-
\\"react-native\\": \\"^0.59.10\\"
675+
\\"react\\": \\"^16.9.0\\",
676+
\\"react-native\\": \\"^0.61.5\\"
680677
}
681678
}
682679
",

tests/integration/cli/create/with-defaults/__snapshots__/cli-create-with-defaults.test.js.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -665,11 +665,11 @@ RCT_EXPORT_METHOD(sampleMethod:(NSString *)stringArgument numberParameter:(nonnu
665665
\\"readmeFilename\\": \\"README.md\\",
666666
\\"peerDependencies\\": {
667667
\\"react\\": \\"^16.8.1\\",
668-
\\"react-native\\": \\">=0.59.0-rc.0 <1.0.x\\"
668+
\\"react-native\\": \\">=0.60.0-rc.0 <1.0.x\\"
669669
},
670670
\\"devDependencies\\": {
671-
\\"react\\": \\"^16.8.3\\",
672-
\\"react-native\\": \\"^0.59.10\\"
671+
\\"react\\": \\"^16.9.0\\",
672+
\\"react-native\\": \\"^0.61.5\\"
673673
}
674674
}
675675
",

tests/integration/cli/help/__snapshots__/cli-help.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Options:
2121
--use-apple-networking [iOS] Use \`AFNetworking\` dependency as a sample in the podspec & use it from the iOS code
2222
--generate-example Generate an example project and links the library module to it, requires both react-native-cli and yarn to be installed globally
2323
--example-name [exampleName] Name for the example project (default: \\"example\\")
24-
--example-react-native-version [exampleReactNativeVersion] React Native version for the generated example project (default: \\"react-native@0.59\\")
24+
--example-react-native-version [exampleReactNativeVersion] React Native version for the generated example project (default: \\"react-native@0.61\\")
2525
--write-example-podfile [iOS] EXPERIMENTAL FEATURE NOT SUPPORTED: write (or overwrite) example ios/Podfile
2626
-h, --help output usage information"
2727
`;

tests/integration/cli/noargs/__snapshots__/cli-noargs.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Options:
2121
--use-apple-networking [iOS] Use \`AFNetworking\` dependency as a sample in the podspec & use it from the iOS code
2222
--generate-example Generate an example project and links the library module to it, requires both react-native-cli and yarn to be installed globally
2323
--example-name [exampleName] Name for the example project (default: \\"example\\")
24-
--example-react-native-version [exampleReactNativeVersion] React Native version for the generated example project (default: \\"react-native@0.59\\")
24+
--example-react-native-version [exampleReactNativeVersion] React Native version for the generated example project (default: \\"react-native@0.61\\")
2525
--write-example-podfile [iOS] EXPERIMENTAL FEATURE NOT SUPPORTED: write (or overwrite) example ios/Podfile
2626
-h, --help output usage information"
2727
`;

tests/with-injection/cli/command/object/__snapshots__/lib-cli-command-object-text.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Object {
7373
},
7474
Object {
7575
"command": "--example-react-native-version [exampleReactNativeVersion]",
76-
"default": "react-native@0.59",
76+
"default": "react-native@0.61",
7777
"description": "React Native version for the generated example project",
7878
},
7979
Object {

0 commit comments

Comments
 (0)