Create prebuilt Detox framework (#1954)

* Swap to bash for convenience

* Switch to Swift 5 and no longer embed Swift standard libraries

This means we require Xcode 10.2, iOS 12.2 at minimum

* Fix Xcode version regex

* Do not pack iOS artifacts during prepublish or publish

Artifacts will be built during a separate step in CI.

* Add “package:ios” script to be run on CI

* Rather than build during postinstall, extract existing prebuilt framework

Dev mode will continue to build from source

* Make the script exit on build error

* Update ci.publish.js
This commit is contained in:
Leo Natan
2020-03-12 14:46:25 +02:00
committed by GitHub
parent cad5887d74
commit a296cc2515
14 changed files with 55 additions and 63 deletions
+1
View File
@@ -229,3 +229,4 @@ detox/test/artifacts
Detox-android/
Detox-ios-src.tbz
Detox-ios.tbz
+4 -3
View File
@@ -52,8 +52,9 @@ The most difficult part of automated testing on mobile is the tip of the testing
### Environment
* **OS**: MacOS 10.13 (High Sierra) or higher.
* **Xcode**: 10.1 or higher.
* **OS**: MacOS 10.13 (High Sierra) or higher
* **Xcode**: 10.2 or higher
* **iOS Simulator Runtime**: iOS 12.2 or higher
### React Native
@@ -63,7 +64,7 @@ The following React Native versions have been tested:
| iOS | Android |
| ------ | ------------------------------------------------------------ |
| <=0.60.4 | <=0.56 - Full support |
| <=0.61.* | <=0.56 - Full support |
| | >=0.57 <=0.61 - Visibility edge-case: see this [RN issue](https://github.com/facebook/react-native/issues/23870)* |
Future versions are most likely supported, but have not been tested yet. Please open issues if you find specific issues with newer React Native versions.
+5 -13
View File
@@ -797,7 +797,6 @@
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OBJC_BRIDGING_HEADER = "DetoxUserNotificationTests/Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
};
name = Debug;
};
@@ -815,7 +814,6 @@
PRODUCT_BUNDLE_IDENTIFIER = com.wix.DetoxUserNotificationTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "DetoxUserNotificationTests/Bridging-Header.h";
SWIFT_VERSION = 4.2;
};
name = Release;
};
@@ -872,11 +870,13 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.3;
IPHONEOS_DEPLOYMENT_TARGET = 12.2;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_TREAT_WARNINGS_AS_ERRORS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
@@ -930,12 +930,13 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.3;
IPHONEOS_DEPLOYMENT_TARGET = 12.2;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_TREAT_WARNINGS_AS_ERRORS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
@@ -947,7 +948,6 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 390D1C981E3A2893007F5F46 /* Detox.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CLANG_ENABLE_MODULES = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = NO;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = NO;
@@ -962,7 +962,6 @@
HEADER_SEARCH_PATHS = EarlGrey/fishhook;
INFOPLIST_FILE = Detox/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 11.3;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@@ -982,9 +981,6 @@
SKIP_INSTALL = YES;
STRIP_INSTALLED_PRODUCT = NO;
STRIP_SWIFT_SYMBOLS = NO;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_TREAT_WARNINGS_AS_ERRORS = NO;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
@@ -992,7 +988,6 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 390D1C981E3A2893007F5F46 /* Detox.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CLANG_ENABLE_MODULES = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = NO;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = NO;
@@ -1007,7 +1002,6 @@
HEADER_SEARCH_PATHS = EarlGrey/fishhook;
INFOPLIST_FILE = Detox/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 11.3;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@@ -1027,8 +1021,6 @@
SKIP_INSTALL = YES;
STRIP_INSTALLED_PRODUCT = NO;
STRIP_SWIFT_SYMBOLS = NO;
SWIFT_TREAT_WARNINGS_AS_ERRORS = NO;
SWIFT_VERSION = 4.2;
};
name = Release;
};
@@ -31,7 +31,7 @@ public class DetoxUserActivityDispatcher: NSObject {
Swift.fatalError("Unable to read user activity data file.")
}
guard let jsonObject = (try? JSONSerialization.jsonObject(with: data, options: .init(rawValue: 0)) as! [String: Any]) else {
guard let jsonObject = try? (JSONSerialization.jsonObject(with: data, options: .init(rawValue: 0)) as! [String: Any]) else {
Swift.fatalError("Unable to parse user activity data file.")
}
@@ -91,7 +91,7 @@ public class DetoxUserNotificationDispatcher: NSObject {
Swift.fatalError("Unable to read user notification data file.")
}
guard var jsonObject = (try? JSONSerialization.jsonObject(with: data, options: .init(rawValue: 0)) as! [String: Any]) else {
guard var jsonObject = try? (JSONSerialization.jsonObject(with: data, options: .init(rawValue: 0)) as! [String: Any]) else {
Swift.fatalError("Unable to parse user notification data file.")
}
+3
View File
@@ -92,7 +92,10 @@ id<GREYMatcher> detox_grey_parent(id<GREYMatcher> ancestorMatcher)
//Either take scroll views or web views that match the provided matcher, or take views whose parent is a RCTScrollView subclass and the parent matches the provided matcher.
return grey_anyOf(grey_allOf(
grey_anyOf(grey_kindOfClass([UIScrollView class]),
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
grey_kindOfClass([UIWebView class]),
#pragma clang diagnostic pop
nil),
matcher,
nil),
+1 -4
View File
@@ -1,10 +1,7 @@
const fs = require('fs-extra');
const {sh} = require('./utils');
if (process.platform === 'darwin') {
const {packageIosSources} = require('./pack_ios');
packageIosSources();
}
//No need to pack iOS artifacts here. The build_framework.ios.sh script will be called during the post-install phase.
if (process.argv[2] === "android" || process.argv[3] === "android") {
console.log("\nBuilding Detox aars");
+7 -11
View File
@@ -14,21 +14,17 @@ detoxFrameworkPath="${detoxFrameworkDirPath}/Detox.framework"
function prepareAndBuildFramework () {
if [ -d "$detoxRootPath"/ios ]; then
detoxSourcePath="${detoxRootPath}"/ios
echo "Dev mode, will build from ${detoxSourcePath}"
echo "Dev mode, building from ${detoxSourcePath}"
buildFramework "${detoxSourcePath}"
else
detoxSourcePath="${detoxRootPath}"/ios_src
extractSources "${detoxSourcePath}"
buildFramework "${detoxSourcePath}"
rm -fr "${detoxSourcePath}"
extractFramework
fi
}
function extractSources () {
detoxSourcePath="${1}"
echo "Extracting Detox sources..."
mkdir -p "${detoxSourcePath}"
tar -xjf "${detoxRootPath}"/Detox-ios-src.tbz -C "${detoxSourcePath}"
function extractFramework () {
echo "Extracting Detox framework..."
mkdir -p "${detoxFrameworkDirPath}"
tar -xjf "${detoxRootPath}"/Detox-ios.tbz -C "${detoxFrameworkDirPath}"
}
function buildFramework () {
@@ -55,7 +51,7 @@ function main () {
rm -rf "${detoxFrameworkDirPath}"
prepareAndBuildFramework
else
echo "Detox.framework was previously compiled, skipping..."
echo "Detox.framework exists, skipping..."
fi
else
prepareAndBuildFramework
+3 -1
View File
@@ -1,3 +1,5 @@
#!/bin/bash -e
PROJECT=$1
OUTPUT_DIR=$2
CONFIGURATION=Release
@@ -19,7 +21,7 @@ echo TEMP_DIR = "${TEMP_DIR}"
# Step 0. Xcode version
XCODEVERSION=$(xcodebuild -version | grep -oEi "([0-9]*\.[0-9]*)")
XCODEVERSION=$(xcodebuild -version | grep -oEi "([0-9]*(\.[0-9]*)+)")
echo "Xcode ${XCODEVERSION}"
USE_NEW_BUILD_SYSTEM="YES"
if [ "${XCODEVERSION}" != "`echo -e "${XCODEVERSION}\n11.0" | sort --version-sort -r | head -n1`" ]; then
-18
View File
@@ -1,18 +0,0 @@
const fs = require('fs-extra');
const {sh} = require('./utils');
function packageIosSources() {
console.log("\nPackaging Detox iOS sources");
fs.removeSync('Detox-ios-src.tbz');
// Prepare Earl Grey without building
sh("ios/EarlGrey/Scripts/setup-earlgrey.sh");
sh("find ./ios -name Build -type d -exec rm -rf {} ;");
sh("tar --exclude-from=.tbzignore -cjf ../Detox-ios-src.tbz .", { cwd: "ios" });
}
module.exports = {
packageIosSources,
};
+24
View File
@@ -0,0 +1,24 @@
#!/bin/bash -e
rm -rf Detox-ios-src.tbz
rm -rf Detox-ios.tbz
rm -rf build_temp
ios/EarlGrey/Scripts/setup-earlgrey.sh
find ./ios -name Build -type d -exec rm -rf {} \;
#Package sources
pushd . &> /dev/null
cd ios
tar --exclude-from=.tbzignore -cjf ../Detox-ios-src.tbz .
popd &> /dev/null
#Package prebuilt framework
mkdir build_temp
scripts/build_universal_framework.sh "ios/Detox.xcodeproj" "build_temp" &> build_temp/detox_ios.log
pushd . &> /dev/null
cd build_temp
tar --exclude-from=../ios/.tbzignore -cjf ../Detox-ios.tbz .
popd &> /dev/null
rm -fr build_temp
+1
View File
@@ -6,6 +6,7 @@
"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:ios": "scripts/ci.ios-release.sh",
"postinstall": "scripts/postinstall.sh"
},
"publishConfig": {
+4
View File
@@ -0,0 +1,4 @@
#!/bin/bash -e
cd detox
scripts/pack_ios.sh
-11
View File
@@ -6,7 +6,6 @@ const {log, logSection, getVersionSafe} = require('./ci.common');
function publishNewVersion(packageVersion) {
validatePrerequisites();
projectSetup();
prePublishToNpm();
publishToNpm();
const newVersion = getVersionSafe();
@@ -37,16 +36,6 @@ function projectSetup() {
exec.execSync(`git checkout master`);
}
function prePublishToNpm() {
logSection('Prepublish');
log('Gathering up iOS artifacts...');
process.chdir('detox');
const {packageIosSources} = require('../detox/scripts/pack_ios');
packageIosSources();
process.chdir('..');
}
function publishToNpm() {
logSection('Lerna publish');