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

Sky/new arch #1

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 4 additions & 2 deletions detox/ios/Detox/Invocation/Element.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@ class Element : NSObject {
return view.scrollView
} else if ReactNativeSupport.isReactNativeApp && NSStringFromClass(type(of: view)) == "RCTScrollView" {
return (view.value(forKey: "scrollView") as! UIScrollView)
}

} else if ReactNativeSupport.isReactNativeApp && NSStringFromClass(type(of: view)) == "RCTScrollViewComponentView" {
return (view.value(forKey: "scrollView") as! UIScrollView)
}

dtx_fatalError("View “\(self.view.dtx_shortDescription)” is not an instance of “UIScrollView”", viewDescription: debugAttributes)
}

Expand Down
14 changes: 12 additions & 2 deletions detox/ios/Detox/Invocation/Predicate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import Foundation
import UIKit
import Detox.Private
import DetoxSync

class Predicate : CustomStringConvertible, CustomDebugStringConvertible {
struct Keys {
Expand Down Expand Up @@ -66,10 +67,15 @@ class Predicate : CustomStringConvertible, CustomDebugStringConvertible {
return ValuePredicate(kind: kind, modifiers: modifiers, value: label, requiresAccessibilityElement: true, isRegex: isRegex)
} else {
//Will crash if RN app and neither class exists
let RCTTextViewClass : AnyClass = NSClassFromString("RCTText") ?? NSClassFromString("RCTTextView")!
var RCTTextViewClass : AnyClass? = nil
if DTXReactNativeSupport.newArchEnabled() {
RCTTextViewClass = NSClassFromString("RCTParagraphComponentView")
} else {
RCTTextViewClass = NSClassFromString("RCTText") ?? NSClassFromString("RCTTextView")
}

let descendantPredicate = DescendantPredicate(predicate: AndCompoundPredicate(predicates: [
try KindOfPredicate(kind: Kind.type, modifiers: [], className: NSStringFromClass(RCTTextViewClass)),
try KindOfPredicate(kind: Kind.type, modifiers: [], className: NSStringFromClass(RCTTextViewClass!)),
ValuePredicate(kind: kind, modifiers: modifiers, value: label, requiresAccessibilityElement: true, isRegex: isRegex)
], modifiers: []), modifiers: [Modifier.not])
descendantPredicate.hidden = true
Expand All @@ -91,6 +97,10 @@ class Predicate : CustomStringConvertible, CustomDebugStringConvertible {
//Will crash if RN app and neither class exists
let RCTTextViewClass : AnyClass = NSClassFromString("RCTText") ?? NSClassFromString("RCTTextView")!
orPredicates.append(try KindOfPredicate(kind: Kind.type, modifiers: [], className: NSStringFromClass(RCTTextViewClass)))

if NSClassFromString("RCTParagraphComponentView") != nil {
orPredicates.append(try KindOfPredicate(kind: Kind.type, modifiers: [], className: "RCTParagraphComponentView"))
}
}

let orCompoundPredicate = OrCompoundPredicate(predicates: orPredicates, modifiers: [])
Expand Down
10 changes: 8 additions & 2 deletions detox/ios/Detox/Utilities/NSObject+DontCrash.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,23 @@ - (id)_dtx_text
{
return [(UITextView*)self text];
}

static Class RCTTextView;
static Class RCTParagraphComponentView;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
RCTTextView = NSClassFromString(@"RCTTextView");
RCTParagraphComponentView = NSClassFromString(@"RCTParagraphComponentView");
});
if(RCTTextView != nil && [self isKindOfClass:RCTTextView])
{
return [(NSTextStorage*)[self valueForKey:@"textStorage"] string];
}

if(RCTParagraphComponentView != nil && [self isKindOfClass:RCTParagraphComponentView])
{
return [(NSAttributedString*)[self valueForKey:@"attributedText"] string];
}

return nil;
}

Expand Down
28 changes: 21 additions & 7 deletions detox/ios/Detox/Utilities/ReactNativeSupport/ReactNativeSupport.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import "ReactNativeSupport.h"
#import "ReactNativeHeaders.h"
#import "UIKit/UIKit.h"

#include <dlfcn.h>
#include <stdatomic.h>
Expand Down Expand Up @@ -40,14 +41,27 @@ + (void)reloadApp
{
//Call RN public API to request reload.
[bridge requestReload];
return;
}
else
{
//Legacy call to reload RN.
[[NSNotificationCenter defaultCenter] postNotificationName:RCTReloadNotification
object:nil
userInfo:nil];
}

NSObject<UIApplicationDelegate> *delegate = UIApplication.sharedApplication.delegate;
NSObject *rootViewFactory = [delegate valueForKey: @"rootViewFactory"];
if (rootViewFactory) {
NSObject *host = [rootViewFactory valueForKey:@"reactHost"];
SEL didReceiveReloadCommand = NSSelectorFromString(@"didReceiveReloadCommand");
if (host && [host respondsToSelector:didReceiveReloadCommand]) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[host performSelector:didReceiveReloadCommand];
#pragma clang diagnostic pop
return;
}
}

//Legacy call to reload RN.
[[NSNotificationCenter defaultCenter] postNotificationName:RCTReloadNotification
object:nil
userInfo:nil];
}

+ (void)waitForReactNativeLoadWithCompletionHandler:(void (^)(void))handler
Expand Down
2 changes: 1 addition & 1 deletion detox/ios/DetoxSync
5 changes: 5 additions & 0 deletions detox/test/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@ DerivedData
*.ipa
*.xcuserstate
example.xcworkspace
**/.xcode.env.local

# Android/IJ
#
.idea
.gradle
local.properties

# Ruby / CocoaPods
**/Pods/
/vendor/bundle/

# node.js
#
node_modules/
Expand Down
89 changes: 55 additions & 34 deletions detox/test/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
if ENV["REACT_NATIVE_VERSION"] && ENV["REACT_NATIVE_VERSION"].match(/0.(70|71).*/)
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
require_relative '../node_modules/react-native-permissions/scripts/setup'
else
# Resolve react_native_pods.rb with node to allow for hoisting
def node_require(script)
# Resolve script with node to allow for hoisting
require Pod::Executable.execute_command('node', ['-p',
"require.resolve(
'#{script}',
{paths: [process.argv[1]]},
)", __dir__]).strip
end
# if ENV["REACT_NATIVE_VERSION"] && ENV["REACT_NATIVE_VERSION"].match(/0.(70|71).*/)
# require_relative '../node_modules/react-native/scripts/react_native_pods'
# require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
# require_relative '../node_modules/react-native-permissions/scripts/setup'
# else
# # Resolve react_native_pods.rb with node to allow for hoisting
# def node_require(script)
# # Resolve script with node to allow for hoisting
# require Pod::Executable.execute_command('node', ['-p',
# "require.resolve(
# '#{script}',
# {paths: [process.argv[1]]},
# )", __dir__]).strip
# end

# node_require('react-native/scripts/react_native_pods.rb')
# node_require('react-native-permissions/scripts/setup.rb')
# end

node_require('react-native/scripts/react_native_pods.rb')
node_require('react-native-permissions/scripts/setup.rb')
# Resolve react_native_pods.rb with node to allow for hoisting
def node_require(script)
# Resolve script with node to allow for hoisting
require Pod::Executable.execute_command('node', ['-p',
"require.resolve(
'#{script}',
{paths: [process.argv[1]]},
)", __dir__]).strip
end

node_require('react-native/scripts/react_native_pods.rb')
node_require('react-native-permissions/scripts/setup.rb')

platform :ios, min_ios_version_supported
prepare_react_native_project!

install! 'cocoapods', :deterministic_uuids => false

Expand Down Expand Up @@ -46,24 +61,30 @@ setup_permissions([
def shared_pods
config = use_native_modules!

if ENV["REACT_NATIVE_VERSION"] && ENV["REACT_NATIVE_VERSION"].match(/0.(70).*/)
# Flags change depending on the env values.
flags = get_default_flags()

use_react_native!(
:path => config[:reactNativePath],
:hermes_enabled => flags[:hermes_enabled],
:fabric_enabled => flags[:fabric_enabled],
# :flipper_configuration => FlipperConfiguration.enabled,
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
else
use_react_native!(
# To enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => false,
)
end
# if ENV["REACT_NATIVE_VERSION"] && ENV["REACT_NATIVE_VERSION"].match(/0.(70).*/)
# # Flags change depending on the env values.
# flags = get_default_flags()

# use_react_native!(
# :path => config[:reactNativePath],
# :hermes_enabled => flags[:hermes_enabled],
# :fabric_enabled => flags[:fabric_enabled],
# # :flipper_configuration => FlipperConfiguration.enabled,
# # An absolute path to your application root.
# :app_path => "#{Pod::Config.instance.installation_root}/.."
# )
# else
# use_react_native!(
# # To enable hermes on iOS, change `false` to `true` and then install pods
# :hermes_enabled => false,
# )
# end

use_react_native!(
:path => config[:reactNativePath],
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
end

target 'example' do
Expand Down
59 changes: 47 additions & 12 deletions detox/test/ios/example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; };
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
26369388132CB1E5F8B325A9 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 09B091E74024FE7A722D5D4D /* PrivacyInfo.xcprivacy */; };
3953CC0D229AA78F005DD98C /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 39ED920022916437005EDB56 /* JavaScriptCore.framework */; };
399B4DEC1ED587120098D2AC /* NativeModule.m in Sources */ = {isa = PBXBuildFile; fileRef = CC17D3311D60A24300267B0C /* NativeModule.m */; };
399B4DED1ED587120098D2AC /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };
Expand All @@ -22,6 +23,7 @@
39B044651DAED76E00431EC5 /* Detox.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 39B044621DAED76400431EC5 /* Detox.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
39B71FCC24643AEA00CC9A88 /* exampleUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 39B71FCB24643AEA00CC9A88 /* exampleUITests.m */; };
39ED92302291643E005EDB56 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 39ED920022916437005EDB56 /* JavaScriptCore.framework */; };
4AD906C52CC7E17826163C24 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 09B091E74024FE7A722D5D4D /* PrivacyInfo.xcprivacy */; };
4FB97BDF2636490900B7B57C /* CustomKeyboardViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4FB97BDE2636490800B7B57C /* CustomKeyboardViewController.m */; };
4FB97BE02636490900B7B57C /* CustomKeyboardViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4FB97BDE2636490800B7B57C /* CustomKeyboardViewController.m */; };
A6246A8AF2D035D89BA61CA6 /* libPods-example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 86172A40F266BB07F101EB18 /* libPods-example.a */; };
Expand Down Expand Up @@ -85,6 +87,7 @@

/* Begin PBXFileReference section */
008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = main.jsbundle; sourceTree = "<group>"; };
09B091E74024FE7A722D5D4D /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xml; name = PrivacyInfo.xcprivacy; path = example/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
13B07F961A680F5B00A75B9A /* example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = example.app; sourceTree = BUILT_PRODUCTS_DIR; };
13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = example/AppDelegate.h; sourceTree = "<group>"; tabWidth = 4; };
13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = example/AppDelegate.m; sourceTree = "<group>"; tabWidth = 4; usesTabs = 1; };
Expand Down Expand Up @@ -157,6 +160,7 @@
13B07FB71A68108700A75B9A /* main.m */,
ADB9A7A225C82082005236EE /* ReactModules */,
ADB9A79F25C81FF7005236EE /* UI */,
09B091E74024FE7A722D5D4D /* PrivacyInfo.xcprivacy */,
);
name = example;
sourceTree = "<group>";
Expand Down Expand Up @@ -275,6 +279,7 @@
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
CC0F353E1D461097008BB94F /* Embed Frameworks */,
7E5379D0D68561A29BC0458B /* [CP] Copy Pods Resources */,
7AF754C7F2A4B722437CBA34 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand All @@ -297,6 +302,7 @@
399B4E001ED587120098D2AC /* Bundle React Native code and images */,
399B4E011ED587120098D2AC /* Embed Frameworks */,
9C024938B44AFDD355A0B654 /* [CP] Copy Pods Resources */,
752B107DCF4F35ADC021436F /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -390,6 +396,7 @@
files = (
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */,
4AD906C52CC7E17826163C24 /* PrivacyInfo.xcprivacy in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -399,6 +406,7 @@
files = (
399B4DFE1ED587120098D2AC /* Images.xcassets in Resources */,
399B4DFF1ED587120098D2AC /* LaunchScreen.xib in Resources */,
26369388132CB1E5F8B325A9 /* PrivacyInfo.xcprivacy in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -462,6 +470,40 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
752B107DCF4F35ADC021436F /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-example_ci/Pods-example_ci-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-example_ci/Pods-example_ci-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-example_ci/Pods-example_ci-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
7AF754C7F2A4B722437CBA34 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-example/Pods-example-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-example/Pods-example-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-example/Pods-example-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
7E5379D0D68561A29BC0458B /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -802,14 +844,11 @@
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "$(inherited)";
OTHER_CPLUSPLUSFLAGS = "$(inherited)";
OTHER_LDFLAGS = (
"$(inherited)",
"-Wl",
"-ld_classic",
);
OTHER_LDFLAGS = "$(inherited) ";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
USE_HERMES = false;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG";
USE_HERMES = true;
};
name = Debug;
};
Expand Down Expand Up @@ -864,14 +903,10 @@
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_CFLAGS = "$(inherited)";
OTHER_CPLUSPLUSFLAGS = "$(inherited)";
OTHER_LDFLAGS = (
"$(inherited)",
"-Wl",
"-ld_classic",
);
OTHER_LDFLAGS = "$(inherited) ";
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos;
USE_HERMES = false;
USE_HERMES = true;
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand Down
3 changes: 2 additions & 1 deletion detox/test/ios/example/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#import <UIKit/UIKit.h>
#import <RCTAppDelegate.h>

@interface SomeMiddleman : UIWindow @end

Expand All @@ -10,7 +11,7 @@

@interface DetoxApp : UIApplication @end

@interface AppDelegate : UIResponder <UIApplicationDelegate>
@interface AppDelegate : RCTAppDelegate <UIApplicationDelegate>

@property (nonatomic, strong) AnnoyingWindow *window;

Expand Down
Loading