-
Notifications
You must be signed in to change notification settings - Fork 92
fix(ios): add support for react-native-reanimated
#1197
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 1 addition & 5 deletions
6
ios/ReactTestApp/React+TurboModule.h → ios/ReactTestApp/BridgeDelegate.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,9 @@ | ||
#if USE_TURBOMODULE | ||
|
||
#import <React/RCTBridgeDelegate.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface RTATurboModuleManagerDelegate : NSObject <RCTBridgeDelegate> | ||
@interface RTABridgeDelegate : NSObject <RCTBridgeDelegate> | ||
- (instancetype)initWithBridgeDelegate:(id<RCTBridgeDelegate>)bridgeDelegate; | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END | ||
|
||
#endif // USE_TURBOMODULE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const { withMod } = require("@expo/config-plugins"); | ||
|
||
function withBridgeDelegate(config, action) { | ||
return withMod(config, { | ||
platform: "ios", | ||
mod: "bridgeDelegate", | ||
action, | ||
}); | ||
} | ||
|
||
function withSceneDelegate(config, action) { | ||
return withMod(config, { | ||
platform: "ios", | ||
mod: "sceneDelegate", | ||
action, | ||
}); | ||
} | ||
|
||
exports.withBridgeDelegate = withBridgeDelegate; | ||
exports.withSceneDelegate = withSceneDelegate; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
const { createRunOncePlugin } = require("@expo/config-plugins"); | ||
const { | ||
mergeContents, | ||
} = require("@expo/config-plugins/build/utils/generateCode"); | ||
const { withBridgeDelegate } = require("./index"); | ||
|
||
const NAME = "react-native-reanimated"; | ||
|
||
function addContents(tag, src, newSrc, anchor) { | ||
return mergeContents({ | ||
tag: `${NAME}-${tag}`, | ||
src, | ||
newSrc, | ||
anchor, | ||
offset: 1, | ||
comment: "//", | ||
}).contents; | ||
} | ||
|
||
function withReanimatedExecutor(config) { | ||
return withBridgeDelegate(config, (config) => { | ||
if (config.modResults.language !== "objcpp") { | ||
throw new Error( | ||
"`BridgeDelegate` is not in Objective-C++ (did that change recently?)" | ||
); | ||
} | ||
|
||
// Add Reanimated headers | ||
config.modResults.contents = addContents( | ||
"header", | ||
config.modResults.contents, | ||
[ | ||
"#pragma clang diagnostic push", | ||
'#pragma clang diagnostic ignored "-Wnullability-completeness"', | ||
"", | ||
"#import <RNReanimated/REAInitializer.h>", | ||
"", | ||
"#if __has_include(<reacthermes/HermesExecutorFactory.h>)", | ||
"#import <reacthermes/HermesExecutorFactory.h>", | ||
"using ExecutorFactory = HermesExecutorFactory;", | ||
"#elif __has_include(<React/HermesExecutorFactory.h>)", | ||
"#import <React/HermesExecutorFactory.h>", | ||
"using ExecutorFactory = HermesExecutorFactory;", | ||
"#else", | ||
"#import <React/JSCExecutorFactory.h>", | ||
"using ExecutorFactory = JSCExecutorFactory;", | ||
"#endif", | ||
"", | ||
"#pragma clang diagnostic pop", | ||
].join("\n"), | ||
/#import "BridgeDelegate\.h"/ | ||
); | ||
|
||
// Install Reanimated's JSI executor runtime | ||
const indent = " "; | ||
config.modResults.contents = addContents( | ||
"executor", | ||
config.modResults.contents, | ||
[ | ||
`${indent}const auto installer = reanimated::REAJSIExecutorRuntimeInstaller(bridge, nullptr);`, | ||
`${indent}return std::make_unique<ExecutorFactory>(RCTJSIExecutorRuntimeInstaller(installer));`, | ||
].join("\n"), | ||
/\/\/ jsExecutorFactoryForBridge: \(USE_TURBOMODULE=0\)/ | ||
); | ||
return config; | ||
}); | ||
} | ||
|
||
module.exports = createRunOncePlugin( | ||
withReanimatedExecutor, | ||
NAME, | ||
"UNVERSIONED" | ||
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.