Skip to content

Commit

Permalink
Upgrade project to RN61 with CocoaPods (wix#1713)
Browse files Browse the repository at this point in the history
* Upgrade project to RN61 with CocoaPods

Remove componentWillMount functions
Remove PushNotificationIOS
Add pod install step to lerna bootstrap

* Update install.ios.sh

* Build the workspace rather than the project

* Remove cocoapods installation from script

* RN61

* Run pod install only on iOS builds

* Is it just lerna cli parser? we really need to upgrade to new lerna

Co-authored-by: Rotem Mizrachi-Meidan <[email protected]>
  • Loading branch information
LeoNatan and rotemmiz authored Dec 24, 2019
1 parent 7102c5c commit 94bd06c
Show file tree
Hide file tree
Showing 15 changed files with 200 additions and 746 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ ios/xcuserdata/
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
ios/Pods/
*/*/ios/Pods/
*/*/ios/Podfile.lock

# Carthage
#
Expand Down
14 changes: 1 addition & 13 deletions detox/test/index.ios.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
import example from './src/app';

import {
AppRegistry,
PushNotificationIOS
AppRegistry
} from 'react-native';

class exampleIos extends example {

componentWillMount() {
super.componentWillMount();
PushNotificationIOS.addEventListener('notification', (notification) => this._onNotification(notification));
PushNotificationIOS.addEventListener('localNotification', (notification) => this._onNotification(notification));
}

async componentDidMount() {
super.componentDidMount();
const notification = await PushNotificationIOS.getInitialNotification();
if (notification) {
this.setState({notification: notification.getAlert().title});
}
}
}

Expand Down
47 changes: 47 additions & 0 deletions detox/test/ios/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

use_frameworks!

def rn_pods
pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/'
pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'

pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

use_native_modules!
end

target 'example' do
rn_pods
end

target 'example_ci' do
rn_pods
end
814 changes: 113 additions & 701 deletions detox/test/ios/example.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions detox/test/ios/example.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions detox/test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
},
"dependencies": {
"moment": "^2.24.0",
"react": "16.8.x",
"react-native": "0.60.x"
"react": "16.9.0",
"react-native": "0.61.4"
},
"devDependencies": {
"@babel/core": "^7.4.5",
Expand All @@ -49,15 +49,15 @@
"configurations": {
"ios.sim.debug": {
"binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/example.app",
"build": "set -o pipefail && xcodebuild -project ios/example.xcodeproj -UseNewBuildSystem=NO -scheme example_ci -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
"build": "set -o pipefail && xcodebuild -workspace ios/example.xcworkspace -UseNewBuildSystem=NO -scheme example_ci -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
"type": "ios.simulator",
"device": {
"type": "iPhone 11 Pro"
}
},
"ios.sim.release": {
"binaryPath": "ios/build/Build/Products/Release-iphonesimulator/example.app",
"build": "set -o pipefail && export CODE_SIGNING_REQUIRED=NO && export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -project ios/example.xcodeproj -UseNewBuildSystem=NO -scheme example_ci -configuration Release -sdk iphonesimulator -derivedDataPath ios/build",
"build": "set -o pipefail && export CODE_SIGNING_REQUIRED=NO && export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -workspace ios/example.xcworkspace -UseNewBuildSystem=NO -scheme example_ci -configuration Release -sdk iphonesimulator -derivedDataPath ios/build",
"type": "ios.simulator",
"device": {
"type": "iPhone 11 Pro"
Expand Down
2 changes: 1 addition & 1 deletion detox/test/src/Screens/LaunchArgsScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default class LaunchArgsScreen extends Component {
}
}

async componentWillMount() {
async componentDidMount() {
const launchArgs = await NativeModule.getLaunchArguments();
this.setState({
launchArgs,
Expand Down
11 changes: 4 additions & 7 deletions detox/test/src/Screens/ShakeScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export default class ShakeScreen extends Component {
greeting: "Shake it, baby"
};
this.subscription = undefined;
this.subscription = shakeEventEmitter.addListener('ShakeEvent', () => {
console.log("Shake!!!");
this.setState({ greeting: "Shaken, not stirred" });
});
}

render() {
Expand All @@ -33,13 +37,6 @@ export default class ShakeScreen extends Component {
);
}

componentWillMount() {
this.subscription = shakeEventEmitter.addListener('ShakeEvent', () => {
console.log("Shake!!!");
this.setState({ greeting: "Shaken, not stirred" });
});
}

componentWillUnmount() {
console.log("Unsubscribing");
this.subscription.remove();
Expand Down
6 changes: 1 addition & 5 deletions detox/test/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ class example extends Component {
notification: undefined
};

// TODO this is a hack for RN 0.60: Android warns of the deprecation (yellow-box), while iOS can't live
// without this method (native error).
if (!isAndroid) {
this.componentWillMount = () => {};
}
Linking.addEventListener('url', (params) => this._handleOpenURL(params));
}

renderButton(title, onPressCallback) {
Expand Down
3 changes: 2 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"examples/demo-react-native",
"examples/demo-react-native-detox-instruments",
"examples/demo-react-native-jest",
"generation"
"generation",
"."
],
"version": "14.9.1",
"npmClient": "npm",
Expand Down
9 changes: 2 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@
"test:e2e:ios": "pushd detox/test && npm run e2e:ios && popd",
"test:e2e:android": "pushd detox/test && npm run e2e:android && popd",
"release": "node scripts/ci.release.js",
"package:android": "node scripts/ci.android-release.js"
"package:android": "node scripts/ci.android-release.js",
"postinstall": "scripts/postinstall.sh"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/"
},
"devDependencies": {
"lodash": "4.17.x",
"semver": "5.x.x",
"shell-utils": "1.x.x",
"chalk": "^2.4.2"
}
}
4 changes: 2 additions & 2 deletions scripts/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ fi

run_f "lerna bootstrap"

run_f "lerna run --ignore detox-demo* build"
run_f "lerna run --ignore detox-demo* test"
run_f "lerna run build"
run_f "lerna run test"
6 changes: 4 additions & 2 deletions scripts/install.ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

$(dirname "$0")/install.sh

gem install xcpretty >/dev/null 2>&1

export CODE_SIGNING_REQUIRED=NO
brew tap wix/brew
brew install applesimutils --HEAD
HOMEBREW_NO_INSTALL_CLEANUP=1 HOMEBREW_NO_AUTO_UPDATE=1 brew tap wix/brew
HOMEBREW_NO_INSTALL_CLEANUP=1 HOMEBREW_NO_AUTO_UPDATE=1 brew install applesimutils
3 changes: 1 addition & 2 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@

npm install -g [email protected] >/dev/null 2>&1
npm install -g react-native-cli >/dev/null 2>&1
npm install -g detox-cli >/dev/null 2>&1
gem install xcpretty >/dev/null 2>&1
npm install -g detox-cli >/dev/null 2>&1
6 changes: 6 additions & 0 deletions scripts/postinstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash -e

if [ "$(uname)" == "Darwin" ]; then
cd detox/test/ios
pod install
fi

0 comments on commit 94bd06c

Please sign in to comment.