brodybits / create-react-native-module

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[...] iOS on React Native 0.60(+)

brodybits opened this issue · comments

If I would generate a new module with an example on RN 0.60, the generated example project does not work on iOS.

Tool version: 0.5.0

Command used:

create-react-native-module --generate-example ben-alan

Debug output with error message:

2019-07-10 22:19:39.624 [info][tid:main][RCTCxxBridge.mm:236] Initializing <RCTCxxBridge: 0x7fe7be5031a0> (parent: <RCTBridge: 0x600000a347e0>, executor: (null))
2019-07-10 22:19:39.629322-0400 example[21627:1170867] Initializing <RCTCxxBridge: 0x7fe7be5031a0> (parent: <RCTBridge: 0x600000a347e0>, executor: (null))
2019-07-10 22:19:39.836 [info][tid:main][RCTRootView.m:293] Running application example ({
    initialProps =     {
    };
    rootTag = 1;
})
2019-07-10 22:19:39.836033-0400 example[21627:1170867] Running application example ({
    initialProps =     {
    };
    rootTag = 1;
})
2019-07-10 22:20:59.403488-0400 example[21627:1171076] [] nw_socket_handle_socket_event [C3.1:1] Socket SO_ERROR [61: Connection refused]
2019-07-10 22:20:59.409348-0400 example[21627:1171076] [] nw_socket_handle_socket_event [C3.2:1] Socket SO_ERROR [61: Connection refused]
2019-07-10 22:20:59.412213-0400 example[21627:1171105] [] nw_connection_get_connected_socket [C3] Client called nw_connection_get_connected_socket on unconnected nw_connection
2019-07-10 22:20:59.659 [info][tid:com.facebook.react.JavaScript] Running application "example" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
2019-07-10 22:20:59.659131-0400 example[21627:1171099] Running application "example" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
2019-07-10 22:20:59.815 [error][tid:com.facebook.react.JavaScript] TypeError: null is not an object (evaluating '_reactNativeBenAlan.default.sampleMethod')

This error is located at:
    in App (at renderApplication.js:40)
    in RCTView (at View.js:35)
    in View (at AppContainer.js:98)
    in RCTView (at View.js:35)
    in View (at AppContainer.js:115)
    in AppContainer (at renderApplication.js:39)
2019-07-10 22:20:59.815621-0400 example[21627:1171099] TypeError: null is not an object (evaluating '_reactNativeBenAlan.default.sampleMethod')

This error is located at:
    in App (at renderApplication.js:40)
    in RCTView (at View.js:35)
    in View (at AppContainer.js:98)
    in RCTView (at View.js:35)
    in View (at AppContainer.js:115)
    in AppContainer (at renderApplication.js:39)
2019-07-10 22:20:59.844 [error][tid:com.facebook.react.JavaScript] TypeError: null is not an object (evaluating '_reactNativeBenAlan.default.sampleMethod')

This error is located at:
    in App (at renderApplication.js:40)
    in RCTView (at View.js:35)
    in View (at AppContainer.js:98)
    in RCTView (at View.js:35)
    in View (at AppContainer.js:115)
    in AppContainer (at renderApplication.js:39)
2019-07-10 22:20:59.843901-0400 example[21627:1171099] TypeError: null is not an object (evaluating '_reactNativeBenAlan.default.sampleMethod')

This error is located at:
    in App (at renderApplication.js:40)
    in RCTView (at View.js:35)
    in View (at AppContainer.js:98)
    in RCTView (at View.js:35)
    in View (at AppContainer.js:115)
    in AppContainer (at renderApplication.js:39)
2019-07-10 22:20:59.854 [fatal][tid:com.facebook.react.ExceptionsManagerQueue] Unhandled JS Exception: TypeError: null is not an object (evaluating '_reactNativeBenAlan.default.sampleMethod')

This error is located at:
    in App (at renderApplication.js:40)
    in RCTView (at View.js:35)
    in View (at AppContainer.js:98)
    in RCTView (at View.js:35)
    in View (at AppContainer.js:115)
    in AppContainer (at renderApplication.js:39)
2019-07-10 22:20:59.853868-0400 example[21627:1171105] Unhandled JS Exception: TypeError: null is not an object (evaluating '_reactNativeBenAlan.default.sampleMethod')

This error is located at:
    in App (at renderApplication.js:40)
    in RCTView (at View.js:35)
    in View (at AppContainer.js:98)
    in RCTView (at View.js:35)
    in View (at AppContainer.js:115)
    in AppContainer (at renderApplication.js:39)
2019-07-10 22:20:59.946 [info][tid:com.facebook.react.JavaScript] 'BugReporting extraData:', { 'AppRegistry.runApplication1': 'Running application "example" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF' }
2019-07-10 22:20:59.946207-0400 example[21627:1171099] 'BugReporting extraData:', { 'AppRegistry.runApplication1': 'Running application "example" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF' }
2019-07-10 22:20:59.981970-0400 example[21627:1170867] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/brodybits/Library/Developer/CoreSimulator/Devices/D3554BC6-55FA-4421-82BA-9510E66B738D/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2019-07-10 22:20:59.982485-0400 example[21627:1170867] [MC] Reading from private effective user settings.
2019-07-10 22:21:00.206 [info][tid:com.facebook.react.JavaScript] 'BugReporting extraData:', { 'AppRegistry.runApplication1': 'Running application "example" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF' }
2019-07-10 22:21:00.208203-0400 example[21627:1171099] 'BugReporting extraData:', { 'AppRegistry.runApplication1': 'Running application "example" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF' }
2019-07-10 22:21:00.228 [info][tid:com.facebook.react.JavaScript] 'BugReporting extraData:', { 'AppRegistry.runApplication1': 'Running application "example" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF' }
2019-07-10 22:21:00.228134-0400 example[21627:1171099] 'BugReporting extraData:', { 'AppRegistry.runApplication1': 'Running application "example" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF' }
2019-07-10 22:21:03.280 [info][tid:com.facebook.react.JavaScript] 'BugReporting extraData:', { 'AppRegistry.runApplication1': 'Running application "example" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF' }
2019-07-10 22:21:03.280881-0400 example[21627:1171099] 'BugReporting extraData:', { 'AppRegistry.runApplication1': 'Running application "example" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF' }
2019-07-10 22:21:05.823 [info][tid:com.facebook.react.JavaScript] 'BugReporting extraData:', { 'AppRegistry.runApplication1': 'Running application "example" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF' }
2019-07-10 22:21:05.823821-0400 example[21627:1171099] 'BugReporting extraData:', { 'AppRegistry.runApplication1': 'Running application "example" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF' }

See also:

  • #25 (updates for RN 0.60)

I think we need to add react-native.config.js to the generated project, like someone proposed for react-native-google-signin in react-native-google-signin/google-signin#692.

The warning message in react-native-google-signin/google-signin#692 points to the following documentation resource:

Hey, i came across this library after trying and failing to get react-native-create-library to work however I'm having similar issues to those you describe above. I'm able to build and run the example
project using the command described in the readme:
create-react-native-module --prefix CB --package-identifier io.mylibrary --generate-example AliceHelper
It works fine on android but in iOS i get TypeError: Cannot read property 'sampleMethod' of undefined. I've tried lowering the react-native version in templates/generate.js to 0.59.10 and re-generating but am still getting the same error. Is there a way you know of to get a working example project, i'm happy to use an old version of RN etc but cant see how i can achieve this. ... Side note, if you have any primarily JS work that needs looking at, i'd be happy to chip in if it helps :)

[…] I'm having similar issues to those you describe above. […]

I will try to fix this before making the 0.6.0 release later today. I will likely use the following PRs for examples:

I've tried lowering the react-native version in templates/generate.js to 0.59.10 and re-generating but am still getting the same error.

I think that should not make any difference.

[…] i'm happy to use an old version of RN […]

Try something like this:

react-native init my-native-module --version react-native@0.59

Side note, if you have any primarily JS work that needs looking at, i'd be happy to chip in if it helps :)

Thanks for the offer. There are a few issues that I think should be “pure JS”, for example: #15

I suspect that the iOS Podfile is needed to work with React Native 0.60. I tried using the new --use-cocoapods option but then run into an issue with duplicated modules on Haste. So I will release version 0.6.0 now and try to solve this issue sometime later. Any help from others would be highly appreciated.

Thank you for the quick response, I installed the dev branch and it's working 👌. I'll fork now and have a look at #15

Thanks @dsyne. In #15, I would like to work on the package JSON update, wouldn’t mind if you get a chance to look at any of the other items. A few other ideas if you get a chance:

  • #37 - drop support for Node.js pre-8.0
  • #40 - automatic testing, likely using Jest to check output snapshots

Here is how I was able to resolve this issue for the generated example on iOS:

  • do react-native link <module name> in the generated example (not needed)
  • do pod install in the ios subdirectory of the generated example manually

My first attempt to update lib/lib.js to automatically do pod install in the ios subdirectory of the generated example did not seem to work for me. I hope to get this working someday. I think the right solution for now is to simply document this.

Is the issue that pod install won’t work until you run yarn install in the generated example?

Is the issue that pod install won’t work until you run yarn install in the generated example?

I really don't remember. Further response should be coming soon.

discussion is now continued in #99