Skip to content

Commit

Permalink
Minor fixes for XCode 9.1 (#207)
Browse files Browse the repository at this point in the history
* Minor fixes for XCode 9.1

* Only check runtime major iOS version number in testRunUITest

* Bump Xcode version for circleci

* Bump runtime versions and Xcode version

* only compare major Xcode version for bluepill compile time and bluepill runtime

* Wire in the XcodePath to fix the code for replacing __PLATFORMS__

* Update README
  • Loading branch information
ob committed Nov 29, 2017
1 parent 6a936b0 commit c330f51
Show file tree
Hide file tree
Showing 25 changed files with 57 additions and 42 deletions.
4 changes: 2 additions & 2 deletions BPSampleApp/BPSampleApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = BPSampleApp/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = LI.BPSampleApp;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -843,7 +843,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = BPSampleApp/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = LI.BPSampleApp;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "0910"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Bluepill-cli/BPInstanceTests/BluepillTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ - (void)setUp {
XCTAssert(self.config.simDeviceType != nil);

for (SimRuntime *runtime in [sc supportedRuntimes]) {
if ([[runtime name] isEqualToString:self.config.runtime]) {
if ([[runtime name] containsString:self.config.runtime]) {
self.config.simRuntime = runtime;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion Bluepill-cli/Bluepill-cli.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@
7A79017A1D5CB679004D4325 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0900;
LastUpgradeCheck = 0910;
ORGANIZATIONNAME = LinkedIn;
TargetAttributes = {
7A7901811D5CB679004D4325 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "0910"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "0910"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "0910"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "0910"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion Bluepill-cli/Bluepill-cli/Bluepill/Helpers/BPHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
dispatch_once_t onceToken;
}

typedef void (^BasicHandlerBlock)();
typedef void (^BasicHandlerBlock)(void);
typedef void (^BasicErrorBlock)(NSError *error);

@property (nonatomic, strong) BPWaitTimer *timer;
Expand Down
2 changes: 1 addition & 1 deletion Bluepill-cli/Bluepill-cli/Bluepill/Helpers/BPWaitTimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@class BPWaitTimer;

typedef void (^BPWaitTimerBlock)(BPWaitTimer *timer);
typedef void (^BPWaitTimerTimeoutBlock)();
typedef void (^BPWaitTimerTimeoutBlock)(void);

/**
This class will call the specified timeout block if the
Expand Down
2 changes: 1 addition & 1 deletion Bluepill-cli/Bluepill-cli/Bluepill/Helpers/BPWaitTimer.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ - (void)start {
}];
}

- (void)startTimerFor:(NSTimeInterval)seconds withCompletion:(void (^)())block {
- (void)startTimerFor:(NSTimeInterval)seconds withCompletion:(void (^)(void))block {
self.timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0));
__weak typeof(self) __self = self;
dispatch_source_set_timer(self.timer, dispatch_time(DISPATCH_TIME_NOW, seconds * NSEC_PER_SEC), DISPATCH_TIME_FOREVER, 0.1 * NSEC_PER_SEC);
Expand Down
2 changes: 1 addition & 1 deletion Bluepill-cli/Bluepill-cli/Simulator/SimulatorHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ + (NSString *)testEnvironmentWithConfiguration:(BPConfiguration *)config {
xctConfig.treatMissingBaselinesAsFailures = NO;
xctConfig.targetApplicationPath = config.appBundlePath;
xctConfig.reportResultsToIDE = YES;
xctConfig.automationFrameworkPath = [NSString stringWithFormat:@"%@/Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks/XCTAutomationSupport.framework", config.xcodePath],
xctConfig.automationFrameworkPath = [NSString stringWithFormat:@"%@/Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks/XCTAutomationSupport.framework", config.xcodePath];
testHostPath = config.appBundlePath;

if (config.testRunnerAppPath) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "0910"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
7 changes: 5 additions & 2 deletions Bluepill-runner/Bluepill-runner/BPApp.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@ @implementation BPApp

+ (NSArray <BPXCTestFile *>*)testsFromXCTestRunDict:(NSDictionary *)xcTestRunDict
andXCTestRunPath:(NSString *)xcTestRunPath
andXcodePath:(NSString *)xcodePath
withError:(NSError *__autoreleasing *)error {

NSMutableArray<BPXCTestFile *> *allTests = [[NSMutableArray alloc] init];
NSUInteger errorCount = 0;
for (NSString *key in xcTestRunDict) {
BPXCTestFile *xcTestFile = [BPXCTestFile BPXCTestFileFromDictionary:[xcTestRunDict objectForKey:key]
withTestRoot:[xcTestRunPath stringByDeletingLastPathComponent]
andError:error];
andXcodePath:xcodePath
andError:error];
if (!xcTestFile) {
[BPUtils printInfo:ERROR withString:@"Failed to read data for %@", key];
errorCount++;
Expand All @@ -98,7 +100,8 @@ + (instancetype)appWithConfig:(BPConfiguration *)config
[BPUtils printInfo:INFO withString:@"Using xctestrun configuration"];
NSArray<BPXCTestFile *> *loadedTests = [BPApp testsFromXCTestRunDict:config.xcTestRunDict
andXCTestRunPath:config.xcTestRunPath
withError:error];
andXcodePath:config.xcodePath
withError:error];
if (loadedTests == nil) {
return nil;
}
Expand Down
14 changes: 8 additions & 6 deletions Bluepill-runner/Bluepill-runner/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,21 @@ int main(int argc, char * argv[]) {
exit(0);
}

//Check if xcode version running on the host match the intended Bluepill branch: Xcode 9 branch is not backward compatible
// Check if xcode version running on the host match the intended Bluepill branch: Xcode 9 branch is not backward compatible
NSString *xcodeVersion = [BPUtils runShell:@"xcodebuild -version"];
if ([xcodeVersion rangeOfString:@BP_DEFAULT_XCODE_VERSION].location == NSNotFound) {
fprintf(stderr, "ERROR: Invalid Xcode version:\n%s;\nOnly %s is supported\n", [xcodeVersion UTF8String], BP_DEFAULT_XCODE_VERSION);
exit(1);
}

//Check if Bluepill compile time Xcode version is matched with Bluepill runtime Xcode version
//Senario to prevent: Bluepill is compiled with Xcode 8, but runs with host installed with Xcode 9
if ([[BPUtils getXcodeRuntimeVersion] isEqualToString:@XCODE_VERSION]) {
printf("Bluepill runtime version and compile time version are matched: %s\n", XCODE_VERSION);
// Check if Bluepill compile time Xcode version is matched with Bluepill runtime Xcode version
// Senario to prevent: Bluepill is compiled with Xcode 8, but runs with host installed with Xcode 9
// Only compare major and minor version version Exg. 9.1 == 9.1
if ([[[BPUtils getXcodeRuntimeVersion] substringToIndex:3] isEqualToString:[@XCODE_VERSION substringToIndex:3]]) {
printf("Bluepill runtime version and compile time version are matched: %s\n", [[@XCODE_VERSION substringToIndex:3] UTF8String]);
} else {
fprintf(stderr, "ERROR: Bluepill runtime version %s and compile time version %s are mismatched\n", [[BPUtils getXcodeRuntimeVersion] UTF8String], XCODE_VERSION);
fprintf(stderr, "ERROR: Bluepill runtime version %s and compile time version %s are mismatched\n",
[[[BPUtils getXcodeRuntimeVersion] substringToIndex:3] UTF8String], [[@XCODE_VERSION substringToIndex:3] UTF8String]);
exit(1);
}
if (argv[1] && (!strcmp(argv[1], "--matrix"))) {
Expand Down
2 changes: 1 addition & 1 deletion Bluepill-runner/Bluepill.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
BAEF4B2C1DAC539400E68294 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0900;
LastUpgradeCheck = 0910;
ORGANIZATIONNAME = LinkedIn;
TargetAttributes = {
BA1809DF1DBA8FB100D7D130 = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "0910"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "0910"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "0910"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ A full list supported options are listed here.
| error-retries | -R | Number of times to recover from simulator/app crashing/hanging and continue running| N | 5 |
| failure-tolerance | -f | Number of times to retry on test failures | N | 0 |
| only-retry-failed | -F | When `failure-tolerance` > 0, only retry tests that failed | N | false |
| runtime | -r | What runtime to use. | N | iOS 10.3 |
| runtime | -r | What runtime to use. | N | iOS 11.1 |
| stuck-timeout | -S | Timeout in seconds for a test that seems stuck (no output). | N | 300s |
| test-timeout | -T | Timeout in seconds for a test that is producing output. | N | 300s |
| test-bundle-path | -t | The path to the test bundle to execute (single .xctest). | N | n/a |
Expand All @@ -98,8 +98,10 @@ A full list supported options are listed here.

## Requirements

Bluepill only works with **Xcode 9.0**. If you're looking for Xcode 8 support, please check out the
[xcode8](https://github.com/linkedin/bluepill/tree/xcode8) branch.
Bluepill only works with **Xcode 9.1**. If you're looking for old Xcode support, please check out the other branches:

* [Xcode-8](https://github.com/linkedin/bluepill/tree/xcode8)
* [Xcode-9.0](https://github.com/linkedin/bluepill/tree/xcode-9.0)

## Acknowledgement

Expand Down
4 changes: 2 additions & 2 deletions Source/Shared/BPConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

#import <Foundation/Foundation.h>

#define BP_DEFAULT_RUNTIME "iOS 11.0"
#define BP_DEFAULT_RUNTIME "iOS 11.1"
#define BP_DEFAULT_DEVICE_TYPE "iPhone 7"
#define BP_DEFAULT_XCODE_VERSION "Xcode 9"
#define BP_DEFAULT_XCODE_VERSION "Xcode 9.1"
#define BP_TM_PROTOCOL_VERSION 17
#define BP_DAEMON_PROTOCOL_VERSION 24

Expand Down
1 change: 1 addition & 0 deletions Source/Shared/BPXCTestFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

+ (instancetype)BPXCTestFileFromDictionary:(NSDictionary<NSString *, NSString *>*) dict
withTestRoot:(NSString *)testRoot
andXcodePath:(NSString *)xcodePath
andError:(NSError **)error;

- (NSUInteger)numTests;
Expand Down
25 changes: 16 additions & 9 deletions Source/Shared/BPXCTestFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,13 @@ + (instancetype)BPXCTestFileFromXCTestBundle:(NSString *)path

+ (instancetype)BPXCTestFileFromDictionary:(NSDictionary *)dict
withTestRoot:(NSString *)testRoot
andXcodePath:(NSString *)xcodePath
andError:(NSError *__autoreleasing *)error {
NSAssert(dict, @"A dictionary should be provided");
NSAssert(testRoot, @"A testRoot argument must be supplied");
NSString * const TESTROOT = @"__TESTROOT__";
NSString * const TESTHOST = @"__TESTHOST__";
NSString * const PLATFORMS = @"__PLATFORMS__";
NSString *testHostPath = [dict objectForKey:@"TestHostPath"];
NSString *testHostBundleIdentifier = [dict objectForKey:@"TestHostBundleIdentifier"];
if (!testHostPath) {
Expand All @@ -129,15 +131,20 @@ + (instancetype)BPXCTestFileFromDictionary:(NSDictionary *)dict
if ([testBundlePath rangeOfString:TESTHOST].location != NSNotFound) {
testBundlePath = [testBundlePath stringByReplacingOccurrencesOfString:TESTHOST withString:testHostPath];
} else if ([testBundlePath rangeOfString:TESTROOT].location != NSNotFound) {
testHostPath = [testHostPath stringByDeletingLastPathComponent]; //remove /bluepill
NSString *temp = [testHostPath stringByDeletingLastPathComponent]; //remove /iphonesimulator
//extract app name with .app extension
NSRange dotPosition = [testHostBundleIdentifier rangeOfString:@"." options:NSBackwardsSearch];
NSString *appName = [testHostBundleIdentifier substringFromIndex:dotPosition.location + 1];
NSString *appNameWithExtension = [appName stringByAppendingString:@".app"];
//append the app name to the direction
testHostPath = [testHostPath stringByAppendingString:appNameWithExtension];
testBundlePath = [testBundlePath stringByReplacingOccurrencesOfString:TESTROOT withString:temp];
if ([testHostPath rangeOfString:PLATFORMS].location != NSNotFound) {
NSString *platformsPath = [xcodePath stringByAppendingPathComponent:@"Platforms"];
testBundlePath = [testBundlePath stringByReplacingOccurrencesOfString:PLATFORMS withString:platformsPath];
} else {
testHostPath = [testHostPath stringByDeletingLastPathComponent]; //remove /bluepill
NSString *temp = [testHostPath stringByDeletingLastPathComponent]; //remove /iphonesimulator
//extract app name with .app extension
NSRange dotPosition = [testHostBundleIdentifier rangeOfString:@"." options:NSBackwardsSearch];
NSString *appName = [testHostBundleIdentifier substringFromIndex:dotPosition.location + 1];
NSString *appNameWithExtension = [appName stringByAppendingString:@".app"];
//append the app name to the direction
testHostPath = [testHostPath stringByAppendingString:appNameWithExtension];
testBundlePath = [testBundlePath stringByReplacingOccurrencesOfString:TESTROOT withString:temp];
}
} else {
[BPUtils printInfo:ERROR withString:@"testBundlePath is incorrect, please check xctestrun file"];
}
Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
machine:
xcode:
version: 9.0
version: 9.1

compile:
override:
Expand Down
2 changes: 1 addition & 1 deletion scripts/bluepill.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ bluepill_build_sample_app()
-workspace Bluepill.xcworkspace \
-scheme BPSampleApp \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 7,OS=11.0.1' \
-destination 'platform=iOS Simulator,name=iPhone 7,OS=11.1' \
-derivedDataPath "build/" 2>&1 | tee result.txt | $XCPRETTY

test $? == 0 || {
Expand Down

0 comments on commit c330f51

Please sign in to comment.