-
Notifications
You must be signed in to change notification settings - Fork 263
Add watchOS, tvOS, iOS platforms support #176
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
Conversation
@@ -11,7 +11,7 @@ | |||
// Measures the performance of a block of code and reports the results. | |||
// | |||
|
|||
#if os(Linux) || os(FreeBSD) | |||
#if os(Linux) || os(FreeBSD) || os(iOS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we discussed on Twitter, I think the way forward here isn't to hard-code Linux, FreeBSD, and now iOS to import Foundation
. Instead, we should provide a configuration option of some kind, to compile swift-corelibs-xctest to use Foundation or SwiftFoundation, as the user desires.
To put it another way, I'm envisioning something like this:
#if defined(USE_SWIFT_FOUNDATION_XCODEPROJ)
import SwiftFoundation
#else
import Foundation
#endif
USE_SWIFT_FOUNDATION_XCODEPROJ
would be specified by the user when they compile swift-corelibs-xctest, or as part of the SwiftXCTest-iOS scheme.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better assume that SwiftFoundation is default. So I suggest introducing flag with name like USE_OBJC_FOUNDATION.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me! @briancroom, any thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@modocache @briancroom PR was updated.
@@ -45,8 +45,7 @@ public extension XCTestCase { | |||
.default | |||
.addObserver(forName: Notification.Name(rawValue: notificationName), | |||
object: objectToObserve, | |||
queue: nil, | |||
usingBlock: { | |||
queue: nil) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a good change, thanks! But please submit these syntax cleanup changes as a separate pull request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this change in a separate PR, see #177. I rebased this PR on PR with the syntax cleanup. In other case iOS build fails. I'll rebase on master as soon as the syntax cleanup approved.
@modocache thank you for the review. I'll do changes on Monday. |
cc39485
to
98aae59
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kicked off the tests for #177 -- thanks!
@@ -11,7 +11,7 @@ | |||
// Measures the performance of a block of code and reports the results. | |||
// | |||
|
|||
#if os(Linux) || os(FreeBSD) | |||
#if USE_OBJC_FOUNDATION || os(Linux) || os(FreeBSD) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, this is very close to what I had in mind. My only suggestion would be to remove the || os(Linux) || os(FreeBSD)
here. Instead, have the build script, build_script.py
, define USE_OBJC_FOUNDATION=1
when compiling for a non-Darwin target.
Of course, it's strange that USE_OBJC_FOUNDATION
should be defined when building for Linux, so I'd change the name here. Maybe USE_IMPORT_FOUNDATION
or USE_IMPORT_SWIFTFOUNDATION
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought ObjC Foundation
exist for Linux. So just curious to introduce better name what kind of foundation we use for Linux / FreeBSD.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
BTW I forgot to add USE_IMPORT_FOUNDATION
for tests, so now it's fixed.
PS. I still not sure that USE_IMPORT_FOUNDATION
is a good name, but I don't have any better ideas.
98aae59
to
b7f2080
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent, thanks @larryonoff!
I like these changes, but I'll let @briancroom chime in as well before merging.
@swift-ci please test |
If you want to do this for XCTest, that's fine - but I do want to point out that we have no plans to make swift-corelibs-foundation a shippable product on Darwin platforms. Our plan all along there has been to continue to use the system provided one. |
b7f2080
to
6393dea
Compare
CI just pointed out that I forgot update build script for Unix. Just did it, could anyone please check that I did it properly. |
@swift-ci Please test |
6393dea
to
03e2074
Compare
Could anyone please trigger CI? I made changes that should fix CI tests. |
@swift-ci Please test |
03e2074
to
344b1bb
Compare
Since I don't have Linux env I only had to check if the changes for Linux are valid with CI help. Sorry, but I need to trigger ci build again :) |
No problem! :) |
@swift-ci please test |
344b1bb
to
14cee72
Compare
build failed on macOS since llvm clone failed. could you please trigger CI again :) |
@swift-ci Please test |
This is going to keep failing until swiftlang/swift#5890 gets merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @larryonoff, I'm so sorry for not getting to this sooner. Thanks for taking the time to look into this! I've left a couple of comments with suggestions that should simplify the required changes a bit.
I'd also like to mention, though, that while I happy to pull in these few changes in support of allowing the framework to build on iOS, I would by no means consider iOS to be a properly supported platform for Corelibs XCTest. See #34 for some previous discussion of this point.
Xcode's XCTest.framework has much more in the way of platform integration and should provide a better experience when working on any Apple platform. If this isn't the case, please file Radars indicating what you are trying to accomplish and how the framework isn't pulling its weight.
@@ -11,7 +11,7 @@ | |||
// Measures the performance of a block of code and reports the results. | |||
// | |||
|
|||
#if os(Linux) || os(FreeBSD) | |||
#if USE_IMPORT_FOUNDATION |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding this conditional compilation flag, how about we simplify the expression to something like:
#if os(macOS)
import SwiftFoundation
#else
import Foundation
#endif
See also previous discussion of this: #96
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of removing USE_IMPORT_FOUNDATION define (I generally don't like the flag). But in the case we excluding the case when we want to run both tests for SwiftFoundation and Foundation of SwiftXCTests on macOS.
@modocache @briancroom any thoughts about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corelibs XCTest is really intended to build on top of Corelibs Foundation. If it works with Darwin Foundation, that's great, but it's not a core configuration for the project. I don't think we should go out of our way to add support for that as a part of this PR, at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got your point. I'll do change soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These look great 👍
@@ -255,6 +299,24 @@ | |||
/* End PBXLegacyTarget section */ | |||
|
|||
/* Begin PBXNativeTarget section */ | |||
19D66F931DE6F57E00C112C0 /* SwiftXCTest-iOS */ = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than adding a whole new target, it should be pretty straightforward to accomplish the same goal by adding iphoneos
and iphonesimulator
to the SUPPORTED_PLATFORMS
build setting of the existing target. You'll probably need to also bring over a couple of additional settings like the iOS deployment target, but I would it expect it to mostly just work for a simple target like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will this work for with SPM?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand what you're asking here. Could you elaborate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant if we leave one unified target (for macOS, iOS) will Swift Package Manage be able compiling it for macOS and iOS platforms separately? e.g. I think that Carthage won't be able doing it (but I'm not sure).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, SwiftPM doesn't build from Xcode projects, so there's be no effect there. (It would be interesting to see sometime though if we could do away with this Xcode project altogether and just let SwiftPM generate it for us!)
I'm not sure about Carthage, though I would consider it to be their bug if it doesn't work, since xcodebuild deals with that setup just fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about Carthage, though I would consider it to be their bug if it doesn't work, since xcodebuild deals with that setup just fine.
Carthage is supporting such unified schemes since September 2015.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ikesyo thanks for pointing it out!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've migrated into unified scheme. Generally I checked https://github.com/mxcl/PromiseKit settings to do this.
The main thing that can be wrong is that I had to remove SwiftFoundation.framework
from "Linked Frameworks and Libraries" since it doesn't compile for iOS platform. I checked that there's a setting "Link Frameworks Automatically", but I'm not sure that it works properly.
Could anyone please provide any suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I missed this before. I think what we're going to need here is to add -framework SwiftFoundation
into the Other Linker Flags
build setting, but conditionalized such that it only applies to Any macOS SDK
. Similar to what is described here.
@CodaFi thank you for mentioning. It looks that issue introduced recently. Since I was able passing macOS build some time before. |
14cee72
to
8d1e857
Compare
@larryonoff A good next step would be to look at the CI log, and run the exact same invocation locally. Swift CI usually builds a larger portion of all the Swift projects, and sometimes with unique settings. |
@swift-ci please test |
It seems that by swiftlang/swift-corelibs-foundation#709, Swift Foundation does not work well on macOS 10.11 now. What is the version of the CI environment? |
I can see that swift-corelibs-foundation only runs tests on Linux, and its build log prints out the version Ubuntu 16.04. Unfortunately the macOS build doesn't seem to print out the current macOS version. I can see that it's using the MacOSX10.12.sdk, but that doesn't mean much. @shahmishal, so you know which version of macOS the CI is running? Would you merge a pull request to print out the macOS version in build-script? |
I've submitted a pull request: swiftlang/swift-corelibs-foundation#784 |
@modocache PR swiftlang/swift-corelibs-foundation#784 merged. Could you please trigger CI? |
@swift-ci please test |
|
Another Foundation pull request related to the failure: swiftlang/swift-corelibs-foundation#785. |
Sorry guys, I was on holiday for a bit and my notification settings were messed up so I missed the activity and lost track here. I'm going to take a moment to catch up now. |
@@ -409,13 +407,22 @@ | |||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; | |||
GCC_WARN_UNUSED_FUNCTION = YES; | |||
GCC_WARN_UNUSED_VARIABLE = YES; | |||
MACOSX_DEPLOYMENT_TARGET = 10.9; | |||
INFOPLIST_FILE = Info.plist; | |||
IPHONEOS_DEPLOYMENT_TARGET = 10.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't any specific concerns with these deployment targets, but I'm curious how you picked them? Is there a reason why it couldn't deploy further back?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There're two reasons, see them below:
swift-corelibs-xctest
uses Timer.scheduledTimer(withTimeInterval:repeats:block:) that requires iOS 10.0+, macOS 10.12+, tvOS 10.0+, watchOS 3.0+. The link to the documentation.SwiftFoundation
macOS deployment target is 10.11.
PS. I think that at the moment we don't need deployment targets lower that specified. We can decrease deployment target as soon as people need it, but in this case we need to make some changes in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense! Thanks for the explanation.
MTL_ENABLE_DEBUG_INFO = YES; | ||
ONLY_ACTIVE_ARCH = YES; | ||
SDKROOT = macosx; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These SDKROOT
changes are surprising to me. Can you explain what's going on here? This corresponds to the Base SDK
setting in the Xcode UI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good question!
Please note that most of the changes I made are based on PromiseKit and the article.
We also should note that we're making the multi-platform single-scheme framework now, so each platform needs it's own SDKROOT
.
I tried the same setup for SDKROOT
as for PromiseKit
(just by removing SDKROOT
on project level) and it works for swift-corelibs-xctest
. But I had to add to specify SDKROOT
for SwiftXCTestFunctionalTests
target, because without SDKROOT
it failed to build.
PS. I agree that it would be better having SDKROOT
on project level for each platform, but Xcode only allows configuring it for architecture (I tried doing it via Xcode UI), not for platform.
It would be awesome if you provide any better solution. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my testing, Xcode will automatically adjust the SDKROOT
used for a build such that it matches the platform of the run destination. For example, if the selected SDK is "Latest macOS" and the build has an iOS device destination selected, it will implicitly use the "Latest iOS" SDK instead. Therefore I would prefer keeping the Base SDK setting at the project level with no target overrides.
One other minor point: I think it would be better to specify the new SUPPORTED_PLATFORMS
value at the level of the SwiftXCTest
target, rather than at the project level, for now anyway. This is because the SwiftXCTestFunctionalTests
target only works on macOS, and I don't foresee that changing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comments. I did the following updates:
- move SUPPORTED_PLATFORMS from project level to 'XCTest' target.
- move deployment targets from project level to 'XCTest' target. Because there're relevant only for 'XCTest' target.
- revert SDKROOT to macosx for project level.
I left a couple of minor questions, but this looks good to me, @larryonoff! Thanks for your work here. I would like to wait to merge until we can get CI green on OS X, though. Thanks @ikesyo for helping to deal with the Foundation build failures we're seeing here. I'm hopeful we can get through this soon! |
'SwiftXCTest' is multi-platform single-scheme target now. Note that 'SwiftXCTestFunctionalTests' still only works on macOS and isn't planned to support other platforms.
- move SUPPORTED_PLATFORMS from project level to 'XCTest' target - move deployment targets from project level to 'XCTest' target - revert SDKROOT to macosx for project level
2518bfe
to
cb30809
Compare
Could anyone please trigger CI again. It should still fail since swiftlang/swift-corelibs-foundation#785 not merged. But I would like to see that nothing is broken since my current changes. |
@swift-ci please test |
Unfortunately the CI build won't even reach XCTest if Foundation is failing to build, so there's not any additional feedback to be gained from running the build again, AFAICT. I'm not sure why CI seeks to have ignored your request though, @modocache! |
Please trigger CI, since PR swiftlang/swift-corelibs-foundation#785 merged. |
@swift-ci Please test |
All CI checks finally passed! Thanks all. |
🎉 🎉 🎉 Thanks for all the persistence, everyone! :) |
Excellent! |
Motivation
CoreLibs XCTest only supports desktop platforms. What limits us using CoreLibs XCTest on other platforms like iOS / Android. Xcode provides functionality to use XCTest framework on iOS, but this's Objective-C framework that is tightly coupled to Xcode. I see two main goals of this PR:
PS. I guess this PR strongly relates to #61 because currently tests only run for macOS platform.
TODO