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

RCTCxxModule incorrectly flagged as not exported module by RCTVerifyAllModulesExported #14806

Closed
mac-cain13 opened this issue Jul 3, 2017 · 28 comments
Labels
Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot.

Comments

@mac-cain13
Copy link

mac-cain13 commented Jul 3, 2017

Is this a bug report?

Yes

Have you read the Bugs section of the Contributing to React Native Guide?

Yes

Environment

  1. react-native -v: 0.45.1 / cli 2.0.1
  2. node -v: v7.9.0
  3. npm -v: 5.0.3
  4. yarn --version (if you use Yarn): 0.24.6

Then, specify:

  1. Target Platform: iOS
  2. Development Operating System: macOS Sierra
  3. Build tools: any supported Xcode version, any supported iOS version

Steps to Reproduce

  1. Execute react-native init testproject
  2. Open the Xcode project and hit run

Expected Behavior

No warnings should be logged to the Xcode console since we have the default setup.

Actual Behavior

In the Xcode log there is a warning about the RCTCxxModule not being exported:

2017-07-03 11:09:47.963 [warn][tid:main][RCTBridge.m:114] Class RCTCxxModule was not exported. Did you forget to use RCT_EXPORT_MODULE()?
2017-07-03 11:09:47.963285+0200 testproject[467:119661] Class RCTCxxModule was not exported. Did you forget to use RCT_EXPORT_MODULE()?

Reproducible Demo

Any newly created React-Native project using the CxxBridge has this issue.

Possible solution

The RCTVerifyAllModulesExported function uses the objc_copyClassList which also reports the RCTCxxModule. This triggers the warning that this module is not exported, but since the RCTCxxModule is merely a base class that can be used by real module implementation this is a false positive.

A possible solution would be to make an exception in RCTVerifyAllModulesExported for the RCTCxxModule so it will not be checked and the warning will not be produced.

Note: The warning will disappear when you create a module that subclasses RCTCxxModule since there is a check in place for that scenario. As long as there is no subclass yet this warning will pop up.

@mac-cain13 mac-cain13 changed the title RCTCxxModule flagged as not exported module by RCTVerifyAllModulesExported RCTCxxModule incorrectly flagged as not exported module by RCTVerifyAllModulesExported Jul 3, 2017
@TheRemjx01
Copy link

I stucked at this issue now. Any solution?

@mac-cain13
Copy link
Author

This issue described a warning logged to the Xcode console. It's annoying and a bit confusing, but you can just ignore it. It's not a compile error or other workflow blocking issue.

@TheRemjx01 maybe you can explain how you are "stuck" at this issue?

@TheRemjx01
Copy link

My App Freeze then
2017-09-04 14:30:55.610 [info][tid:main][RCTCxxBridge.mm:188] Initializing <RCTCxxBridge: 0x6000001b88e0> (parent: <RCTBridge: 0x6000000ab160>, executor: (null))
2017-09-04 14:30:55.644 [warn][tid:main][RCTBridge.m:114] Class RCTCxxModule was not exported. Did you forget to use RCT_EXPORT_MODULE()?
2017-09-04 14:30:55.669 [info][tid:main][RCTRootView.m:301] Running application ExampleProject ({
initialProps = {
};
rootTag = 1;
})
2017-09-04 14:30:57.471 ExampleProject[10735:97004] -[NSTaggedPointerString unsignedIntValue]: unrecognized selector sent to instance 0xa303938303930327
2017-09-04 14:30:57.474 ExampleProject[10735:97004] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSTaggedPointerString unsignedIntValue]: unrecognized selector sent to instance 0xa303938303930327'
*** First throw call stack:
(
0 CoreFoundation 0x000000010a193d4b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010901721e objc_exception_throw + 48
2 CoreFoundation 0x000000010a203f04 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x000000010a119005 forwarding + 1013
4 CoreFoundation 0x000000010a118b88 _CF_forwarding_prep_0 + 120
5 ExampleProject 0x000000010841bd54 -[RCTMultipartStreamReader emitProgress:contentLength:final:callback:] + 244
6 ExampleProject 0x000000010841c54a -[RCTMultipartStreamReader readAllPartsWithCompletionCallback:progressCallback:] + 1610
7 ExampleProject 0x000000010846b8bc -[RCTMultipartDataTask URLSession:streamTask:didBecomeInputStream:outputStream:] + 444
8 CFNetwork 0x0000000109bd4352 __88-[NSURLSession delegate_streamTask:didBecomeInputStream:outputStream:completionHandler:]_block_invoke + 51
9 Foundation 0x0000000108b199ad NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK + 7
10 Foundation 0x0000000108b1968f -[NSBlockOperation main] + 101
11 Foundation 0x0000000108b17d8c -[__NSOperationInternal _start:] + 672
12 Foundation 0x0000000108b13ccf __NSOQSchedule_f + 201
13 libdispatch.dylib 0x000000010de0a0cd _dispatch_client_callout + 8
14 libdispatch.dylib 0x000000010dde7e17 _dispatch_queue_serial_drain + 236
15 libdispatch.dylib 0x000000010dde8b4b _dispatch_queue_invoke + 1073
16 libdispatch.dylib 0x000000010ddeb385 _dispatch_root_queue_drain + 720
17 libdispatch.dylib 0x000000010ddeb059 _dispatch_worker_thread3 + 123
18 libsystem_pthread.dylib 0x000000010e1b9712 _pthread_wqthread + 1299
19 libsystem_pthread.dylib 0x000000010e1b91ed start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException

@mac-cain13
Copy link
Author

Looks like an unrelated issue with NSTaggedPointerString to me. The warning you get above it is harmless, you probably have another issue.

@Mazyod
Copy link

Mazyod commented Sep 4, 2017

@TheRemjx01 You probably have something like:

NSNumber *aString = dictionary[@"key"];
[aString unsignedIntValue];

Basically, you are assigning a value with type id as an NSNumber, and using NSNumber APIs, when in fact, it's an NSString object, which doesn't support NSNumber selectors.

@TheRemjx01
Copy link

@Mazyod Thanks for your reply.
Actually, I haven't do anything, just create app with react-native-cli then run on xCode and got those errors.
However, I have changed from react-native-cli to CRNA. Everything work fine

@janreyho
Copy link

janreyho commented Sep 28, 2017

+1 same issue

@afshin-hoseini
Copy link

Same issue

@srameshr
Copy link

srameshr commented Oct 8, 2017

+1 Same issue.

Oct  8 20:45:27  Frills[11429] <Error>: CGContextSaveGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
Oct  8 20:45:27  Frills[11429] <Error>: CGContextTranslateCTM: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
Oct  8 20:45:27  Frills[11429] <Error>: CGContextRestoreGState: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.
2017-10-08 15:15:27.943 [info][tid:main][RCTCxxBridge.mm:187] Initializing <RCTCxxBridge: 0x7fb99d4c65e0> (parent: <RCTBridge: 0x7fb99d75f610>, executor: (null))
2017-10-08 15:15:27.954 [warn][tid:main][RCTBridge.m:114] Class RCTCxxModule was not exported. Did you forget to use RCT_EXPORT_MODULE()?
2017-10-08 20:45:28.050 Frills[11429] <Warning> [Firebase/Analytics][I-ACS005000] The AdSupport Framework is not currently linked. Some features will not function properly. Learn more at http://goo.gl/9vSsPb
2017-10-08 20:45:28.064 Frills[11429] <Notice> [Firebase/Analytics][I-ACS023007] Firebase Analytics v.4000000 started
2017-10-08 20:45:28.067 Frills[11429] <Notice> [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
2017-10-08 20:45:28.121 Frills[11429] <Notice> [Firebase/Analytics][I-ACS003007] Successfully created Firebase Analytics App Delegate Proxy automatically. To disable the proxy, set the flag FirebaseAppDelegateProxyEnabled to NO in the Info.plist
2017-10-08 20:45:29.278 Frills[11429] <Notice> [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. Add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO
2017-10-08 15:15:31.255 [warn][tid:main][RCTEventEmitter.m:54] Sending `FCMTokenRefreshed` with no listeners registered.
2017-10-08 20:45:34.081 Frills[11429] <Warning> [Firebase/Analytics][I-ACS032003] iAd framework is not linked. Search Ad Attribution Reporter is disabled.
2017-10-08 20:45:34.084 Frills[11429] <Notice> [Firebase/Analytics][I-ACS023012] Firebase Analytics enabled

@jeggy

This comment has been minimized.

@wootwoot1234
Copy link

Anyone find a solution to this?

@melihberberolu
Copy link

Any solutions ?

@jeggy
Copy link

jeggy commented Nov 28, 2017

Now it's already a month ago, so not really sure how I fixed it. But I think it was by adding React to the Target Dependencies.

In xcode > Build Phases > Target Dependencies > + > React > React

@rmlzy
Copy link

rmlzy commented Dec 8, 2017

same to me

@xardit
Copy link

xardit commented Dec 25, 2017

That npm v5.x.x sometimes removes packages while installing another one (very annoying bug, probably because we use npm i --save module, and npm v5 doesn't need --save flag).
Also the error "Native module cannot be null." happened to me the moment i changed the Bundle Identifier, i tried to clean build, clean DeriveData dir, npm start -- --reset-cache. I checked all modules where linked correctly.

In xcode console logs it has this particular row:
Class RCTCxxModule was not exported. Did you forget to use RCT_EXPORT_MODULE()?

Right now it looks to me more like a warning :/

@warrenronsiek
Copy link

I solved this by making sure that NSAppTrasnportSecurity key in my info.plist had the correct values:

<key>NSAppTransportSecurity</key>
<dict>
	<key>NSAllowsArbitraryLoads</key>
	<true/>
	<key>NSAllowsArbitraryLoadsInWebContent</key>
	<true/>
	<key>NSAllowsLocalNetworking</key>
	<true/>
	<key>NSExceptionDomains</key>
	<dict/>
</dict>

@realtebo
Copy link

realtebo commented Mar 7, 2018

@warrenronsiek thanks,
can you add a screenshot of info.plist opened in the info plist editor? I'm new on Max and I'm not able to understand where to insert these lines

Can it be ok like this?

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
    <key>NSAllowsArbitraryLoadsInWebContent</key>
    <true/>
    <key>NSAllowsLocalNetworking</key>
    <true/>
    <key>NSExceptionDomains</key>
		<dict>
			<key>localhost</key>
			<dict>
				<key>NSExceptionAllowsInsecureHTTPLoads</key>
				<true/>
			</dict>
		</dict>
</dict>

Anyway, adding these lines didn't stop warning about RCTCxxModule not exported

@warrenronsiek
Copy link

@realaboo, your info.plist should work. Seems like something else is going wrong.

@react-native-bot react-native-bot added the Platform: iOS iOS applications. label Mar 9, 2018
@watadarkstar
Copy link

+1 same issue

@hobo214
Copy link

hobo214 commented Apr 22, 2018

this issue puzzle me a lot.
My project ran smoothly days before, however this issue happens today, and this issue appears in every project inited by react-native-cli without any modification .

@chadlwilson
Copy link

Looks related to #18201.

@lafayea
Copy link

lafayea commented May 4, 2018

The same like @hobo214

@davidfant
Copy link

Adding -ObjC under Build Settings > Other Linker Flags solved this for me.
My issue was that the app crashed on start with error message:
Class RCTCxxModule was not exported. Did you forget to use RCT_EXPORT_MODULE()?

@jacob-sheldon
Copy link

@davidfant This -Objc Setting is default. So my waring still there.

macdoum1 pushed a commit to macdoum1/react-native that referenced this issue Jun 28, 2018
Summary:
<!--
  Required: Write your motivation here.
  If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged.
-->

On a relatively stock / default setup of RN on iOS you'll see the warning "Class RCTCxxModule was not exported. Did you forget to use RCT_EXPORT_MODULE()?" pop up on every launch. This change resolves that issue.

Fixes facebook#14806 .

This supersedes PR facebook#19794 .

Try a fresh project by following the RN iOS tutorial, and observe that there are no more warnings after making this change.

[IOS] [MINOR] [CxxBridge] - Fix "Class RCTCxxModule was not exported"
Closes facebook#19880

Differential Revision: D8653809

Pulled By: hramos

fbshipit-source-id: c48529c2d74ddd40a90bc0e06e405078e25b72e3
hramos pushed a commit that referenced this issue Jul 4, 2018
Summary:
<!--
  Required: Write your motivation here.
  If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged.
-->

On a relatively stock / default setup of RN on iOS you'll see the warning "Class RCTCxxModule was not exported. Did you forget to use RCT_EXPORT_MODULE()?" pop up on every launch. This change resolves that issue.

Fixes #14806 .

This supersedes PR #19794 .

Try a fresh project by following the RN iOS tutorial, and observe that there are no more warnings after making this change.

[IOS] [MINOR] [CxxBridge] - Fix "Class RCTCxxModule was not exported"
Closes #19880

Differential Revision: D8653809

Pulled By: hramos

fbshipit-source-id: c48529c2d74ddd40a90bc0e06e405078e25b72e3
@yeomann
Copy link

yeomann commented Jul 11, 2018

issue is still there, this just suddenly pops up after so many days development. Sadly the issue is closed on both of Github link where they are saying its duplicate.

@hramos
Copy link
Contributor

hramos commented Jul 16, 2018

@yeomann this was fixed in 569061d, can you confirm this is still an issue in master?

@yeomann
Copy link

yeomann commented Jul 16, 2018

@hramos Hi, yup it came suddenly. particularly appeared after installing react-native-keychain although I'm refactoring a lot of logic in auth and on init of application, so sometimes it comes, sometimes it doesn't show. so, I have no idea how and what is causing this to appear. maybe bcz I am exporting async functions in action creator? ... I have no idea!

UPDATE: I just linked a library after installing a package from npm and pod install after this I see the warning again. Hope this will help.

screen shot 2018-07-16 at 23 11 02

@hramos
Copy link
Contributor

hramos commented Jul 16, 2018

In that case, please open a new issue. As far as we are aware, this is fixed in master, so it would be useful to get a brand new report with your specifics.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Platform: iOS iOS applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet