Skip to content

Commit

Permalink
Linux and Windows Support (Alamofire#3446)
Browse files Browse the repository at this point in the history
* Initial Linux build.

* Add CI support.

* Fix YML.

* Use correct image.

* Initial Windows Support (Alamofire#3462)

* Correct example (Alamofire#3453)

* Exclude NetworkReachabilityManager from Windows

Fixes Alamofire#3459. Windows does not have SystemConfiguration, so we have to exclude it

* Initial windows support

* Fix lock issues

* Add Windows tests

* Fix Windows mutex error

* Remove enable test discovery

* Combine Windows and Linux mutex lock with one common NSLock based class

* Remove locked variable check

* Simplify locking extension

* Attempt to fix Windows build.

* Reenable all platform tests.

* Formatting.

* Update README for new platforms.

* Fix shields.

* Another color.

* Fix table.

* Update issues.

* Remove fixed issue.

* Add SPM badge.

* Spell it out.

* Update to 5.4.1 on Linux, add Nightly.

* Naming update.

* Use concurrency group to cancel previous runs.

* Use correct nightly image.

* Use Firebreak for most builds.

* Build with correct archs.

* Fix Catalyst, tvOS builds.

* Run Catalyst on GitHub.

* 12.4 for Catalyst.

* Try hardened runtime on Firebreak.

* Get tests building on Linux.

* Update Linux CI to build tests as well.

* Add unsupported status for Linux and Windows.

* Fix actions.

* Run Catalyst on GitHub.

* Build tests on Windows too.

* Remove hardened runtime.

* Run jobs when workflows change too.

* Add timeouts to all jobs.

* Enable CI on changes inside workflows.

* Check changes in Package too.

Co-authored-by: Alex Taffe <alex.taffe@gmail.com>
  • Loading branch information
jshier and alex-taffe authored Jun 7, 2021
1 parent 6aa21ec commit a41c07a
Show file tree
Hide file tree
Showing 23 changed files with 427 additions and 328 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.build/
.git/
122 changes: 91 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,28 @@ on:
branches:
- master
- hotfix
paths:
- 'Source/**'
- 'Tests/**'
- '.github/workflows/**'
- 'Package.swift'
pull_request:
branches:
- '*'
paths:
- 'Source/**'
- 'Tests/**'
- '.github/workflows/**'
- 'Package.swift'

concurrency:
group: ci
cancel-in-progress: true
jobs:
macOS_5_1:
name: Build macOS (5.1)
runs-on: macOS-10.15
env:
DEVELOPER_DIR: /Applications/Xcode_11.3.1.app/Contents/Developer
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- name: macOS (5.1)
Expand All @@ -24,6 +36,7 @@ jobs:
runs-on: macOS-10.15
env:
DEVELOPER_DIR: /Applications/Xcode_11.7.app/Contents/Developer
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- name: Install Firewalk
Expand All @@ -35,6 +48,7 @@ jobs:
runs-on: macOS-10.15
env:
DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- name: Install Firewalk
Expand All @@ -46,17 +60,19 @@ jobs:
runs-on: firebreak
env:
DEVELOPER_DIR: /Applications/Xcode_12.5.app/Contents/Developer
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- name: Install Firewalk
run: arch -arch arm64e brew install alamofire/alamofire/firewalk && arch -arch x86_64 firewalk &
run: arch -arch arm64e brew install alamofire/alamofire/firewalk || arch -arch arm64e brew upgrade alamofire/alamofire/firewalk && arch -arch x86_64 firewalk &
- name: macOS (5.4)
run: set -o pipefail && arch -arch arm64e env NSUnbufferedIO=YES xcodebuild -project "Alamofire.xcodeproj" -scheme "Alamofire macOS" -destination "platform=macOS" clean test | xcpretty
Catalyst:
name: Test Catalyst
runs-on: macOS-10.15
env:
DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- name: Install Firewalk
Expand All @@ -65,66 +81,110 @@ jobs:
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -project "Alamofire.xcodeproj" -scheme "Alamofire iOS" -destination "platform=macOS" clean test | xcpretty
iOS:
name: Test iOS
runs-on: macOS-10.15
runs-on: firebreak
env:
DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_12.5.app/Contents/Developer
timeout-minutes: 10
strategy:
matrix:
destination: ["OS=14.4,name=iPhone 12 Pro"]
destination: ["OS=14.5,name=iPhone 12 Pro"]
steps:
- uses: actions/checkout@v2
- name: Install Firewalk
run: brew install alamofire/alamofire/firewalk && firewalk &
run: arch -arch arm64e brew install alamofire/alamofire/firewalk || arch -arch arm64e brew upgrade alamofire/alamofire/firewalk && arch -arch x86_64 firewalk &
- name: iOS - ${{ matrix.destination }}
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -project "Alamofire.xcodeproj" -scheme "Alamofire iOS" -destination "${{ matrix.destination }}" clean test | xcpretty
run: set -o pipefail && arch -arch arm64e env NSUnbufferedIO=YES xcodebuild -project "Alamofire.xcodeproj" -scheme "Alamofire iOS" -destination "${{ matrix.destination }}" clean test | xcpretty
tvOS:
name: Test tvOS
runs-on: macOS-10.15
runs-on: firebreak
env:
DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_12.5.app/Contents/Developer
timeout-minutes: 10
strategy:
matrix:
destination: ["OS=14.3,name=Apple TV 4K"]
destination: ["OS=14.5,name=Apple TV"]
steps:
- uses: actions/checkout@v2
- name: Install Firewalk
run: brew install alamofire/alamofire/firewalk && firewalk &
run: arch -arch arm64e brew install alamofire/alamofire/firewalk || arch -arch arm64e brew upgrade alamofire/alamofire/firewalk && arch -arch x86_64 firewalk &
- name: tvOS - ${{ matrix.destination }}
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -project "Alamofire.xcodeproj" -scheme "Alamofire tvOS" -destination "${{ matrix.destination }}" clean test | xcpretty
run: set -o pipefail && arch -arch arm64e env NSUnbufferedIO=YES xcodebuild -project "Alamofire.xcodeproj" -scheme "Alamofire tvOS" -destination "${{ matrix.destination }}" clean test | xcpretty
watchOS:
name: Build watchOS
runs-on: macOS-10.15
env:
DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer
strategy:
matrix:
destination: ["OS=7.2,name=Apple Watch Series 6 - 44mm"]
steps:
- uses: actions/checkout@v2
- name: watchOS - ${{ matrix.destination }}
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -project "Alamofire.xcodeproj" -scheme "Alamofire watchOS" -destination "${{ matrix.destination }}" clean build | xcpretty
watchOS_Test:
name: Test watchOS
runs-on: firebreak
env:
DEVELOPER_DIR: /Applications/Xcode_12.5.app/Contents/Developer
timeout-minutes: 10
strategy:
matrix:
destination: ["OS=7.4,name=Apple Watch Series 6 - 44mm"]
steps:
- uses: actions/checkout@v2
- name: Install Firewalk
run: arch -arch arm64e brew install alamofire/alamofire/firewalk && arch -arch x86_64 firewalk &
run: arch -arch arm64e brew install alamofire/alamofire/firewalk || arch -arch arm64e brew upgrade alamofire/alamofire/firewalk && arch -arch x86_64 firewalk &
- name: watchOS - ${{ matrix.destination }}
run: set -o pipefail && arch -arch arm64e env NSUnbufferedIO=YES xcodebuild -project "Alamofire.xcodeproj" -scheme "Alamofire watchOS" -destination "${{ matrix.destination }}" clean test | xcpretty
spm:
SPM:
name: Test with SPM
runs-on: macOS-10.15
runs-on: firebreak
env:
DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer
DEVELOPER_DIR: /Applications/Xcode_12.5.app/Contents/Developer
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- name: Install Firewalk
run: brew install alamofire/alamofire/firewalk && firewalk &
run: arch -arch arm64e brew install alamofire/alamofire/firewalk || arch -arch arm64e brew upgrade alamofire/alamofire/firewalk && arch -arch x86_64 firewalk &
- name: SPM Test
run: swift test -c debug
run: arch -arch arm64e swift test -c debug
Linux:
name: Linux
runs-on: ubuntu-20.04
container:
image: swift:5.4.1-focal
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- name: SPM Linux build
run: swift build --build-tests -c debug
Linux_Nightly:
name: Linux Nightly
runs-on: ubuntu-20.04
container:
image: swiftlang/swift:nightly-focal
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- name: SPM Linux build
run: swift build --build-tests -c debug
Windows:
name: Windows
runs-on: windows-2019
timeout-minutes: 10
steps:
- name: "Clone Project"
uses: actions/checkout@v2
- uses: seanmiddleditch/gha-setup-vsdevenv@master
- name: Install Swift
run: |
Install-Binary -Url "https://swift.org/builds/swift-5.4.1-release/windows10/swift-5.4.1-RELEASE/swift-5.4.1-RELEASE-windows10.exe" -Name "installer.exe" -ArgumentList ("-q")
- name: Set Environment Variables
run: |
echo "SDKROOT=C:\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "DEVELOPER_DIR=C:\Library\Developer" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Adjust Paths
run: |
echo "C:\Library\Swift-development\bin;C:\Library\icu-67\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Install Supporting Files
run: |
Copy-Item "$env:SDKROOT\usr\share\ucrt.modulemap" -destination "$env:UniversalCRTSdkDir\Include\$env:UCRTVersion\ucrt\module.modulemap"
Copy-Item "$env:SDKROOT\usr\share\visualc.modulemap" -destination "$env:VCToolsInstallDir\include\module.modulemap"
Copy-Item "$env:SDKROOT\usr\share\visualc.apinotes" -destination "$env:VCToolsInstallDir\include\visualc.apinotes"
Copy-Item "$env:SDKROOT\usr\share\winsdk.modulemap" -destination "$env:UniversalCRTSdkDir\Include\$env:UCRTVersion\um\module.modulemap"
- name: SPM Windows build
shell: cmd
run: |
cd ${{ github.workspace}}
set SDKROOT=%SystemDrive%\Library\Developer\Platforms\Windows.platform\Developer\SDKs\Windows.sdk
%SystemDrive%\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin\swift-build.exe --build-tests -c debug -Xlinker /INCREMENTAL:NO -v
if not exist .build\x86_64-unknown-windows-msvc\debug\Alamofire.swiftmodule exit 1
10 changes: 0 additions & 10 deletions Alamofire.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1842,7 +1842,6 @@
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = "";
GCC_C_LANGUAGE_STANDARD = gnu11;
Expand All @@ -1856,7 +1855,6 @@
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "org.alamofire.Alamofire-watchOSTests";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SDKROOT = watchos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_VERSION = 5.0;
Expand All @@ -1875,7 +1873,6 @@
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
DEVELOPMENT_TEAM = "";
Expand All @@ -1890,7 +1887,6 @@
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "org.alamofire.Alamofire-watchOSTests";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SDKROOT = watchos;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 4;
Expand Down Expand Up @@ -2214,7 +2210,6 @@
isa = XCBuildConfiguration;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = NO;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = "";
Expand All @@ -2226,8 +2221,6 @@
);
PRODUCT_BUNDLE_IDENTIFIER = "org.alamofire.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "";
SDKROOT = iphoneos;
};
name = Debug;
Expand All @@ -2236,7 +2229,6 @@
isa = XCBuildConfiguration;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = NO;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "-";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = "";
Expand All @@ -2248,8 +2240,6 @@
);
PRODUCT_BUNDLE_IDENTIFIER = "org.alamofire.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "";
SDKROOT = iphoneos;
};
name = Release;
Expand Down
45 changes: 27 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
![Alamofire: Elegant Networking in Swift](https://raw.githubusercontent.com/Alamofire/Alamofire/master/Resources/AlamofireLogo.png)

[![Build Status](https://github.com/Alamofire/Alamofire/workflows/Alamofire%20CI/badge.svg?branch=master)](https://github.com/Alamofire/Alamofire/actions)
[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/Alamofire.svg)](https://img.shields.io/cocoapods/v/Alamofire.svg)
[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![Platform](https://img.shields.io/cocoapods/p/Alamofire.svg?style=flat)](https://alamofire.github.io/Alamofire)
[![Twitter](https://img.shields.io/badge/twitter-@AlamofireSF-blue.svg?style=flat)](https://twitter.com/AlamofireSF)
[![Gitter](https://badges.gitter.im/Alamofire/Alamofire.svg)](https://gitter.im/Alamofire/Alamofire?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![Open Source Helpers](https://www.codetriage.com/alamofire/alamofire/badges/users.svg)](https://www.codetriage.com/alamofire/alamofire)
[![Swift](https://img.shields.io/badge/Swift-5.1_5.2_5.3_5.4-orange?style=flat-square)](https://img.shields.io/badge/Swift-5.1_5.2_5.3_5.4-Orange?style=flat-square)
[![Platforms](https://img.shields.io/badge/Platforms-macOS_iOS_tvOS_watchOS_Linux_Windows-yellowgreen?style=flat-square)](https://img.shields.io/badge/Platforms-macOS_iOS_tvOS_watchOS_Linux_Windows-Green?style=flat-square)
[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/Alamofire.svg?style=flat-square)](https://img.shields.io/cocoapods/v/Alamofire.svg)
[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat-square)](https://github.com/Carthage/Carthage)
[![Swift Package Manager](https://img.shields.io/badge/Swift_Package_Manager-compatible-orange?style=flat-square)](https://img.shields.io/badge/Swift_Package_Manager-compatible-orange?style=flat-square)
[![Twitter](https://img.shields.io/badge/twitter-@AlamofireSF-blue.svg?style=flat-square)](https://twitter.com/AlamofireSF)
[![Swift Forums](https://img.shields.io/badge/Swift_Forums-Alamofire-orange?style=flat-square)](https://forums.swift.org/c/related-projects/alamofire/37)

Alamofire is an HTTP networking library written in Swift.

Expand Down Expand Up @@ -58,9 +58,21 @@ In order to keep Alamofire focused specifically on core networking implementatio

## Requirements

- iOS 10.0+ / macOS 10.12+ / tvOS 10.0+ / watchOS 3.0+
- Xcode 11+
- Swift 5.1+
| Platform | Minimum Swift Version | Installation | Status |
| --- | --- | --- | --- |
| iOS 10.0+ / macOS 10.12+ / tvOS 10.0+ / watchOS 3.0+ | 5.1 | [CocoaPods](#cocoapods), [Carthage](#carthage), [Swift Package Manager](#swift-package-manager), [Manual](#manually) | Fully Tested |
| Linux | Latest Only | [Swift Package Manager](#swift-package-manager) | Building But Unsupported |
| Windows | Latest Only | [Swift Package Manager](#swift-package-manager) | Building But Unsupported |

#### Known Issues on Linux and Windows

Alamofire builds on Linux and Windows but there are missing features and many issues in the underlying `swift-corelibs-foundation` that prevent full functionality and may cause crashes. These include:
- `ServerTrustManager` and associated certificate functionality is unavailable, so there is no certificate pinning and no client certificate support.
- Various methods of HTTP authentication may crash, including HTTP Basic and HTTP Digest. Crashes may occur if responses contain server challenges.
- Cache control through `CachedResponseHandler` and associated APIs is unavailable, as the underlying delegate methods aren't called.
- `URLSessionTaskMetrics` are never gathered.

Due to these issues, Alamofire is unsupported on Linux and Windows. Please report any crashes to the [Swift bug reporter](https://bugs.swift.org).

## Migration Guides

Expand All @@ -85,15 +97,15 @@ In order to keep Alamofire focused specifically on core networking implementatio
[CocoaPods](https://cocoapods.org) is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate Alamofire into your Xcode project using CocoaPods, specify it in your `Podfile`:

```ruby
pod 'Alamofire', '~> 5.2'
pod 'Alamofire', '~> 5.4'
```

### Carthage

[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate Alamofire into your Xcode project using Carthage, specify it in your `Cartfile`:

```ogdl
github "Alamofire/Alamofire" ~> 5.2
github "Alamofire/Alamofire" ~> 5.4
```

### Swift Package Manager
Expand All @@ -104,7 +116,7 @@ Once you have your Swift package set up, adding Alamofire as a dependency is as

```swift
dependencies: [
.package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.2.0"))
.package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.4.0"))
]
```

Expand Down Expand Up @@ -153,7 +165,6 @@ The following radars have some effect on the current implementation of Alamofire
- [`rdar://21349340`](http://www.openradar.me/radar?id=5517037090635776) - Compiler throwing warning due to toll-free bridging issue in the test case
- `rdar://26870455` - Background URL Session Configurations do not work in the simulator
- `rdar://26849668` - Some URLProtocol APIs do not properly handle `URLRequest`
- `FB7624529` - `urlSession(_:task:didFinishCollecting:)` never called on watchOS

## Resolved Radars

Expand All @@ -163,10 +174,8 @@ The following radars have been resolved over time after being filed against the
- (Resolved): 9/1/17 in Xcode 9 beta 6.
- [`rdar://36082113`](http://openradar.appspot.com/radar?id=4942308441063424) - `URLSessionTaskMetrics` failing to link on watchOS 3.0+
- (Resolved): Just add `CFNetwork` to your linked frameworks.

## Workarounds

- Collection of `URLSessionTaskMetrics` is currently disabled on watchOS due to `FB7624529`.
- `FB7624529` - `urlSession(_:task:didFinishCollecting:)` never called on watchOS
- (Resolved): Metrics now collected on watchOS 7+.

## FAQ

Expand Down
Loading

0 comments on commit a41c07a

Please sign in to comment.