react-native-keep-awake icon indicating copy to clipboard operation
react-native-keep-awake copied to clipboard

Does not build in 76.0 in new arch for ios

Open Gautham495 opened this issue 1 year ago • 19 comments

Build logs

#if RCT_NEW_ARCH_ENABLED #import <ReactNativeKCKeepAwakeSpec/ReactNativeKCKeepAwakeSpec.h> #endif

@sayem314 - Please fix it when you have time.

Gautham495 avatar Nov 04 '24 09:11 Gautham495

Send screenshot of error. I haven't touched RN in a while.

sayem314 avatar Nov 04 '24 13:11 sayem314

This is the error which xcode gave out.

It works well in android.

Gautham495 avatar Nov 04 '24 18:11 Gautham495

@sayem314 as new arch is enabled, it just said this module is not found.

Gautham495 avatar Nov 04 '24 18:11 Gautham495

I've just run into the same issue on RN 0.75.4 with the new architecture enabled. It was previously working with the new architecture on RN 0.74.

'ReactNativeKCKeepAwakeSpec/ReactNativeKCKeepAwakeSpec.h' file not found

Screenshot 2024-11-05 at 17 38 05

chrisbianca avatar Nov 05 '24 17:11 chrisbianca

Hi there! Same issue here with React Native 0.76.1 and new Arch enabled.

Captura de pantalla 2024-11-08 a la(s) 12 56 52 a  m

smfunder avatar Nov 08 '24 03:11 smfunder

Same here. Issue with with RN 0.76.1 and Xcode

** BUILD FAILED **


The following build commands failed:
        CompileC /Users/amin/Library/Developer/Xcode/DerivedData/myapp-ehkjrileckhvxbafzuvenijgdutp/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/react-native-keep-awake.build/Objects-normal/arm64/ReactNativeKCKeepAwake.o /Users/amin/Projects/myapp/app/node_modules/@sayem314/react-native-keep-awake/ios/ReactNativeKCKeepAwake.mm normal arm64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'react-native-keep-awake' from project 'Pods')
        Building workspace myapp with scheme myapp and configuration Debug
(2 failures)

gigilibala avatar Nov 08 '24 04:11 gigilibala

@sayem314 - Any fixes?

Gautham495 avatar Nov 10 '24 13:11 Gautham495

Change the import path to #import <ReactCodegen/ReactNativeKCKeepAwakeSpec/ReactNativeKCKeepAwakeSpec.h> I also added PR for it #18

shlomo-neuberger avatar Nov 11 '24 08:11 shlomo-neuberger

@Gautham495 can you install directly from main github branch now and check if it’s working so i can push to npm.

sayem314 avatar Nov 11 '24 09:11 sayem314

@sayem314 I just tried installing from master branch on my app and seems to be working correctly!

I did it this way: "@sayem314/react-native-keep-awake": "https://github.com/sayem314/react-native-keep-awake.git", on package.json / dependencies

The built is now working! Thanks for the update!

smfunder avatar Nov 11 '24 16:11 smfunder

Published @sayem314/[email protected]

sayem314 avatar Nov 11 '24 16:11 sayem314

I’m trying to build using version 0.76.5. I’ve used the upgrade helper to modify the necessary files, but when I run the build command, it exits with exit code 65 in Xcode. Is there any other solution to fix this?

jwhan-dix avatar Jan 23 '25 06:01 jwhan-dix

@jwhan-dix see https://circleci.com/blog/xcodebuild-exit-code-65-what-it-is-and-how-to-solve-for-ios-and-macos-builds/

sayem314 avatar Jan 23 '25 06:01 sayem314

@sayem314 It wasn't directly helpful, but I managed to fix the error. Thank you!😂

jwhan-dix avatar Jan 23 '25 07:01 jwhan-dix

Same issue! What's the solution. I'm using 1.3.0

#import <ReactNativeKCKeepAwakeSpec/ReactNativeKCKeepAwakeSpec.h>

wilav-dev avatar Jan 25 '25 12:01 wilav-dev

I am building in RN 0.77, but did not mange to fix the issue so I removed the new arch all together.

Patch

diff --git a/node_modules/@sayem314/react-native-keep-awake/ios/ReactNativeKCKeepAwake.h b/node_modules/@sayem314/react-native-keep-awake/ios/ReactNativeKCKeepAwake.h
index 43749db..b9dccd1 100644
--- a/node_modules/@sayem314/react-native-keep-awake/ios/ReactNativeKCKeepAwake.h
+++ b/node_modules/@sayem314/react-native-keep-awake/ios/ReactNativeKCKeepAwake.h
@@ -6,14 +6,5 @@
 #import "React/RCTBridgeModule.h"
 #endif
 
-#if RCT_NEW_ARCH_ENABLED
-#import <ReactCodegen/ReactNativeKCKeepAwakeSpec/ReactNativeKCKeepAwakeSpec.h>
-#endif
-
 @interface ReactNativeKCKeepAwake : NSObject <RCTBridgeModule>
 @end
-
-#if RCT_NEW_ARCH_ENABLED
-@interface ReactNativeKCKeepAwake () <NativeKCKeepAwakeSpec>
-@end
-#endif
diff --git a/node_modules/@sayem314/react-native-keep-awake/ios/ReactNativeKCKeepAwake.mm b/node_modules/@sayem314/react-native-keep-awake/ios/ReactNativeKCKeepAwake.mm
index bdd992c..c806172 100644
--- a/node_modules/@sayem314/react-native-keep-awake/ios/ReactNativeKCKeepAwake.mm
+++ b/node_modules/@sayem314/react-native-keep-awake/ios/ReactNativeKCKeepAwake.mm
@@ -2,11 +2,6 @@
 #import "UIKit/UIKit.h"
 
 
-#if RCT_NEW_ARCH_ENABLED
-#import <ReactCodegen/ReactNativeKCKeepAwakeSpec/ReactNativeKCKeepAwakeSpec.h>
-#endif
-
-
 @implementation ReactNativeKCKeepAwake
 
 RCT_EXPORT_MODULE();
@@ -25,14 +20,5 @@ @implementation ReactNativeKCKeepAwake
     });
 }
 
-# pragma mark - New Architecture
-#if RCT_NEW_ARCH_ENABLED
-- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
-    (const facebook::react::ObjCTurboModule::InitParams &)params
-{
-    return std::make_shared<facebook::react::NativeKCKeepAwakeSpecJSI>(params);
-}
-#endif
-
 @end

timmylindh avatar Feb 03 '25 09:02 timmylindh

This issue appear again in 0.77 My workaround https://github.com/sayem314/react-native-keep-awake/issues/20#issuecomment-2653042261

huanguolin avatar Feb 12 '25 09:02 huanguolin

Yes it looks like this issue reappeared in react-native 0.77 and @sayem314/react-native-keep-awake 1.3.0, but this time with ReactCodegen in import path.

error 'ReactCodegen/ReactNativeKCKeepAwakeSpec/ReactNativeKCKeepAwakeSpec.h' file not found
Image

stachu2k avatar Feb 19 '25 09:02 stachu2k

Would love for this issue to be properly solved as it seems to just be a simple problem of importing a library. As a temporary fix (tested with React Native 0.77.1), if you want to keep the new React Native architecture:

  1. Open both node_modules/@sayem314/react-native-keep-awake/ios/ReactNativeKCKeepAwake.h and node_modules/@sayem314/react-native-keep-awake/ios/ReactNativeKCKeepAwake.mm
  2. Change the following import statement:
    • From: #import <ReactCodegen/ReactNativeKCKeepAwakeSpec/ReactNativeKCKeepAwakeSpec.h>
    • To: #import <absolute_or_relative_path_to_project/ios/build/generated/ios/ReactNativeKCKeepAwakeSpec/ReactNativeKCKeepAwakeSpec.h>
      • For example, in my project, the relative import path would be: #import <../../../../ios/build/generated/ios/ReactNativeKCKeepAwakeSpec/ReactNativeKCKeepAwakeSpec.h>

The annoying part is that whenever you delete node_modules folder, you are going to have to redo the above steps.

oserrabassa-jcm avatar Mar 20 '25 11:03 oserrabassa-jcm

thx @oserrabassa-jcm I applied your suggestion and I manage to build the project with React Native 0.78.1

chramos avatar Mar 24 '25 18:03 chramos

Import issue should be fixed in v1.3.1

sayem314 avatar Apr 07 '25 13:04 sayem314