Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
1ed4402
Update podspec file for fabric
okwasniewski Jul 19, 2022
51ca37e
Define codegen spec & move import to separate file
okwasniewski Jul 19, 2022
b86cf6c
Add codegenConfig in package.json
okwasniewski Jul 19, 2022
4f8671d
Update podspec to detect .mm files
okwasniewski Jul 20, 2022
00d9a79
Change spec types to floats
okwasniewski Jul 20, 2022
1c40598
Implement fabric component with props updating
okwasniewski Jul 20, 2022
c7a4e23
Re-order functions, add accessibilityIncrements prop
okwasniewski Jul 20, 2022
8dfb795
Clean up imports, remove comment
okwasniewski Jul 21, 2022
8946e51
Sort out props updating, remove unused functions
okwasniewski Jul 21, 2022
5e6f348
Add event handling
okwasniewski Jul 21, 2022
c93b119
Add tapToSeek implementation
okwasniewski Jul 21, 2022
1ae3f1d
Fix tapToSeek
okwasniewski Jul 21, 2022
3ab0013
Handle images using bridge
okwasniewski Jul 21, 2022
8195867
Add missing typedef
okwasniewski Jul 22, 2022
e647c95
Verify the build for new arch with GH Actions
BartoszKlonowski Jul 25, 2022
bc90c77
Save new-arch Pods under new-arch cache key
BartoszKlonowski Jul 26, 2022
e8b2a6c
Use Podfile.lock with old arch and regenerate for new one
BartoszKlonowski Jul 26, 2022
c5c2b80
Correct path for new arch Podfile.lock creation
BartoszKlonowski Jul 26, 2022
d258a90
Disable flipper in Podfile
okwasniewski Jul 26, 2022
dc0988a
Install pods with new arch flag
okwasniewski Jul 26, 2022
8574ae6
Fix tapToSeek on iOS
okwasniewski Jul 26, 2022
62e5e46
Allow value property to be controlled
okwasniewski Jul 26, 2022
9a35cb8
Generate project.pbxproj for new arch
okwasniewski Jul 28, 2022
ad2f640
Separate npm & pods step in CI
okwasniewski Jul 28, 2022
e6531fc
Change step names, fix cache keys
okwasniewski Jul 28, 2022
190454a
Remove pods cache
okwasniewski Jul 28, 2022
22aa190
Run npm install if cache was not found
okwasniewski Jul 28, 2022
e2d87ec
Run build using xcodebuild
okwasniewski Jul 28, 2022
9bfb6eb
Fix: Pods-related error after using Pods from cache (#407)
BartoszKlonowski Jul 28, 2022
4193daf
Remove explicit folly version, default to old arch
okwasniewski Jul 29, 2022
9af9061
Add clean scripts in example for codegen cleanup
okwasniewski Jul 29, 2022
1ae1cda
Change CI step names
okwasniewski Jul 29, 2022
0c7b483
Configure build.gradle
okwasniewski Jul 22, 2022
c272d87
Update libraryName on android
okwasniewski Jul 25, 2022
fbdf661
Create ReactSlider shared implementation
okwasniewski Jul 25, 2022
87051b0
Split implementations into oldarch and newarch
okwasniewski Jul 25, 2022
e685a43
Dispatch events
okwasniewski Jul 25, 2022
0bd7e7b
Cleanup eventDispatcher
okwasniewski Jul 25, 2022
3ed2e9b
Make oldarch implementation use shared code
okwasniewski Jul 25, 2022
1f58ce8
Add defaults to js spec
okwasniewski Jul 27, 2022
06304c9
Clean up newarch ReactSliderManager
okwasniewski Jul 27, 2022
cf24a40
Reorder props to fix disabled state
okwasniewski Jul 27, 2022
7e12d78
Update example app
okwasniewski Jul 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 84 additions & 16 deletions .github/workflows/ReactNativeSlider-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:


verify:
name: Verify the Example app sources
name: Verify example app sources
runs-on: ubuntu-latest

steps:
Expand All @@ -75,7 +75,7 @@ jobs:


build-android-app:
name: Verify the package and example app builds for Android platform
name: Build example app Android
runs-on: ubuntu-latest
needs: [verify]

Expand All @@ -95,7 +95,7 @@ jobs:


build-iOS-app:
name: Verify the package and example app builds for iOS platform
name: Build example app iOS
runs-on: macos-latest
needs: [verify]
steps:
Expand All @@ -105,33 +105,101 @@ jobs:
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cached-ios-deps
cache-name: cached-ios-npm-deps
with:
path: |
example/node_modules
example/ios/Pods
key: ${{ hashFiles('./example/package-lock.json') }}-${{ hashFiles('./package/package-lock.json') }}-${{ hashFiles('./example/ios/Podfile.lock') }}
path: example/node_modules
key: ${{ hashFiles('./example/package-lock.json') }}-${{ hashFiles('./package/package-lock.json') }}

- name: Install required dependencies on cache miss
- name: Install required dependencies on cache miss (npm)
if: steps.cache-npm.outputs.cache-hit != 'true'
run: |
npm install
cd example/ios && pod install --verbose

- name: Cache Pods
id: cache-pods
uses: actions/cache@v3
env:
cache-name: cached-ios-pods-deps
with:
path: example/ios/Pods
key: ${{ hashFiles('./example/ios/Podfile.lock') }}

- name: Install required dependencies on cache miss (Pods)
if: steps.cache-pods.outputs.cache-hit != 'true'
run: |
cd example/ios && pod install

- name: Reinstall Pods only if using cached ones
if: steps.cache-pods.outputs.cache-hit == 'true'
run: cd example/ios && pod install

- name: Use the current package sources in build
run: cd example && npm run refresh-package

- name: Opening Simulator app
uses: futureware-tech/simulator-action@v1
- name: Build iOS
run: |
device_name='iPhone 13'
device=$(xcrun simctl list devices "${device_name}" available | grep "${device_name} (")
re='\(([-0-9A-Fa-f]+)\)'
[[ $device =~ $re ]] || exit 1
xcodebuild -workspace example.xcworkspace -scheme example -destination "platform=iOS Simulator,id=${BASH_REMATCH[1]}" CODE_SIGNING_ALLOWED=NO COMPILER_INDEX_STORE_ENABLE=NO build
working-directory: example/ios


build-iOS-new-arch-app:
name: Build example app iOS (Fabric)
runs-on: macos-latest
needs: [build-iOS-app]
steps:
- uses: actions/checkout@v3

- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cached-ios-npm-deps
with:
path: example/node_modules
key: new-arch-${{ hashFiles('./example/package-lock.json') }}-${{ hashFiles('./package/package-lock.json') }}

- name: Install required dependencies on cache miss (npm)
if: steps.cache-npm.outputs.cache-hit != 'true'
run: |
npm install

- name: Cache Pods
id: cache-pods
uses: actions/cache@v3
env:
cache-name: cached-ios-pods-deps
with:
model: 'iPhone 12 mini'
path: example/ios/Pods
key: new-arch-${{ hashFiles('./example/ios/Podfile.lock') }}

- name: Install required dependencies on cache miss (Pods)
if: steps.cache-pods.outputs.cache-hit != 'true'
run: |
cd example/ios && RCT_NEW_ARCH_ENABLED=1 pod install

- name: Reinstall Pods only if using cached ones
if: steps.cache-pods.outputs.cache-hit == 'true'
run: cd example/ios && RCT_NEW_ARCH_ENABLED=1 pod install

- name: Builds the iOS app
run: cd example && npx react-native run-ios
- name: Use the current package sources in build
run: cd example && npm run refresh-package

- name: Build iOS - Fabric
run: |
device_name='iPhone 13'
device=$(xcrun simctl list devices "${device_name}" available | grep "${device_name} (")
re='\(([-0-9A-Fa-f]+)\)'
[[ $device =~ $re ]] || exit 1
xcodebuild -workspace example.xcworkspace -scheme example -destination "platform=iOS Simulator,id=${BASH_REMATCH[1]}" CODE_SIGNING_ALLOWED=NO COMPILER_INDEX_STORE_ENABLE=NO build
working-directory: example/ios


build-Windows-app:
name: Verify the package and example app builds for Windows platform
name: Build example app Windows
runs-on: windows-latest
needs: [verify]
steps:
Expand Down
2 changes: 1 addition & 1 deletion example/.flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ untyped-import
untyped-type-import

[version]
^0.176.3
^0.182.0
7 changes: 6 additions & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apply plugin: "com.android.application"

import com.android.build.OutputFile
import org.apache.tools.ant.taskdefs.condition.Os

/**
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
Expand Down Expand Up @@ -78,7 +79,7 @@ import com.android.build.OutputFile
*/

project.ext.react = [
enableHermes: false, // clean and rebuild if changing
enableHermes: true, // clean and rebuild if changing
]

apply from: "../../node_modules/react-native/react.gradle"
Expand Down Expand Up @@ -158,6 +159,10 @@ android {
// Make sure this target name is the same you specify inside the
// src/main/jni/Android.mk file for the `LOCAL_MODULE` variable.
targets "example_appmodules"
// Fix for windows limit on number of character in file paths and in command lines
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
arguments "NDK_APP_SHORT_COMMANDS=true"
}
}
}
if (!enableSeparateBuildPerCPUArchitecture) {
Expand Down
27 changes: 16 additions & 11 deletions example/android/app/src/main/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,21 @@ include $(REACT_ANDROID_DIR)/Android-prebuilt.mk
# If you wish to add a custom TurboModule or Fabric component in your app you
# will have to include the following autogenerated makefile.
# include $(GENERATED_SRC_DIR)/codegen/jni/Android.mk

# Includes the MK file for autolinked libraries
include $(PROJECT_BUILD_DIR)/generated/rncli/src/main/jni/Android-rncli.mk

include $(CLEAR_VARS)

LOCAL_PATH := $(THIS_DIR)

# You can customize the name of your application .so file here.
LOCAL_MODULE := example_appmodules

LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp)
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)

# If you wish to add a custom TurboModule or Fabric component in your app you
# will have to uncomment those lines to include the generated source
# files from the codegen (placed in $(GENERATED_SRC_DIR)/codegen/jni)
#
# LOCAL_C_INCLUDES += $(GENERATED_SRC_DIR)/codegen/jni
# LOCAL_SRC_FILES += $(wildcard $(GENERATED_SRC_DIR)/codegen/jni/*.cpp)
# LOCAL_EXPORT_C_INCLUDES += $(GENERATED_SRC_DIR)/codegen/jni
# The generated/rncli/src/main/jni folder contains Autolinking support files.
LOCAL_C_INCLUDES := $(LOCAL_PATH) $(PROJECT_BUILD_DIR)/generated/rncli/src/main/jni
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(PROJECT_BUILD_DIR)/generated/rncli/src/main/jni/*.cpp)
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(PROJECT_BUILD_DIR)/generated/rncli/src/main/jni

# Here you should add any native library you wish to depend on.
LOCAL_SHARED_LIBRARIES := \
Expand All @@ -43,6 +40,14 @@ LOCAL_SHARED_LIBRARIES := \
libturbomodulejsijni \
libyoga

# Autolinked libraries
LOCAL_SHARED_LIBRARIES += $(call import-codegen-modules)

# If you wish to add a custom TurboModule or Fabric component in your app you
# will have to link against it here:
# LOCAL_SHARED_LIBRARIES += \
# libreact_codegen_<your library name>

LOCAL_CFLAGS := -DLOG_TAG=\"ReactNative\" -fexceptions -frtti -std=c++17 -Wall

include $(BUILD_SHARED_LIBRARY)
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#include "MainApplicationModuleProvider.h"

#include <rncli.h>
#include <rncore.h>

namespace facebook {
namespace react {

std::shared_ptr<TurboModule> MainApplicationModuleProvider(
const std::string moduleName,
const std::string &moduleName,
const JavaTurboModule::InitParams &params) {
// Here you can provide your own module provider for TurboModules coming from
// either your application or from external libraries. The approach to follow
Expand All @@ -17,6 +18,13 @@ std::shared_ptr<TurboModule> MainApplicationModuleProvider(
// return module;
// }
// return rncore_ModuleProvider(moduleName, params);

// Module providers autolinked by RN CLI
auto rncli_module = rncli_ModuleProvider(moduleName, params);
if (rncli_module != nullptr) {
return rncli_module;
}

return rncore_ModuleProvider(moduleName, params);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace facebook {
namespace react {

std::shared_ptr<TurboModule> MainApplicationModuleProvider(
const std::string moduleName,
const std::string &moduleName,
const JavaTurboModule::InitParams &params);

} // namespace react
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ void MainApplicationTurboModuleManagerDelegate::registerNatives() {

std::shared_ptr<TurboModule>
MainApplicationTurboModuleManagerDelegate::getTurboModule(
const std::string name,
const std::shared_ptr<CallInvoker> jsInvoker) {
const std::string &name,
const std::shared_ptr<CallInvoker> &jsInvoker) {
// Not implemented yet: provide pure-C++ NativeModules here.
return nullptr;
}

std::shared_ptr<TurboModule>
MainApplicationTurboModuleManagerDelegate::getTurboModule(
const std::string name,
const std::string &name,
const JavaTurboModule::InitParams &params) {
return MainApplicationModuleProvider(name, params);
}

bool MainApplicationTurboModuleManagerDelegate::canCreateTurboModule(
std::string name) {
const std::string &name) {
return getTurboModule(name, nullptr) != nullptr ||
getTurboModule(name, {.moduleName = name}) != nullptr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ class MainApplicationTurboModuleManagerDelegate
static void registerNatives();

std::shared_ptr<TurboModule> getTurboModule(
const std::string name,
const std::shared_ptr<CallInvoker> jsInvoker) override;
const std::string &name,
const std::shared_ptr<CallInvoker> &jsInvoker) override;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why passing shared pointer as a reference? This removes the idea of a pointer being actually shared.
Making a copy allows this smart pointer to do it's job of sharing the pointer.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the idea of how shared pointer works is that each time new copy is created, the internal counter of copies of this shared pointer is increased, so the smart pointer can manage the allocated space for example: when to free the memory. If we pass the shared pointer as a reference, we are not increasing it and work on a direct object of a copy that was passed to that method. So why having it a shared pointer in the first place then?
Consider the above a hint, please, but I'm eager to "check" if the example app will work with a new architecture with having it still passed by a copy, though.
I see it's a part of official migration guidence, Don't get me wrong, my point is: if there's any reason behind that line in original guide other than "you should use const reference wherever possible" then I'm happy to know and learn.

std::shared_ptr<TurboModule> getTurboModule(
const std::string name,
const std::string &name,
const JavaTurboModule::InitParams &params) override;

/**
* Test-only method. Allows user to verify whether a TurboModule can be
* created by instances of this class.
*/
bool canCreateTurboModule(std::string name);
bool canCreateTurboModule(const std::string &name);
};

} // namespace react
Expand Down
4 changes: 4 additions & 0 deletions example/android/app/src/main/jni/MainComponentsRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <fbjni/fbjni.h>
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
#include <react/renderer/components/rncore/ComponentDescriptors.h>
#include <rncli.h>

namespace facebook {
namespace react {
Expand All @@ -14,6 +15,9 @@ std::shared_ptr<ComponentDescriptorProviderRegistry const>
MainComponentsRegistry::sharedProviderRegistry() {
auto providerRegistry = CoreComponentsRegistry::sharedProviderRegistry();

// Autolinked providers registered by RN CLI
rncli_registerProviders(providerRegistry);

// Custom Fabric Components go here. You can register custom
// components coming from your App or from 3rd party libraries here.
//
Expand Down
4 changes: 1 addition & 3 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import org.apache.tools.ant.taskdefs.condition.Os

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
Expand All @@ -22,7 +20,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.1.1")
classpath("com.android.tools.build:gradle:7.2.1")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("de.undercouch:gradle-download-task:5.0.1")
// NOTE: Do not place your application dependencies here; they belong
Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
# your application. You should enable this flag either if you want
# to write custom TurboModules/Fabric components OR use libraries that
# are providing them.
newArchEnabled=false
newArchEnabled=true
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
19 changes: 15 additions & 4 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@ target 'example' do

use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => flags[:hermes_enabled],
# Hermes is now enabled by default. Disable by setting this flag to false.
# Upcoming versions of React Native may rely on get_default_flags(), but
# we make it explicit here to aid in the React Native upgrade process.
:hermes_enabled => true,
:fabric_enabled => flags[:fabric_enabled],
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
:flipper_configuration => FlipperConfiguration.enabled,
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
Expand All @@ -28,10 +35,14 @@ target 'example' do
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
use_flipper!()
# use_flipper!()

post_install do |installer|
react_native_post_install(installer)
react_native_post_install(installer,
# Set `mac_catalyst_enabled` to `true` in order to apply patches
# necessary for Mac Catalyst builds
:mac_catalyst_enabled => false
)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
end
Loading