Skip to content

Commit

Permalink
Add macOS and tvOS support to EpoxyCore (#143)
Browse files Browse the repository at this point in the history
* Add macOS and tvOS support to EpoxyCore

lint

* Fix main package build step, and CI job for EpoxyCore

* Update typealiases

* Remove 'UIView' from type names

* Improve project compatibility

* Try only running EpoxyCore job on Xcode 14

* Update version to 0.10.0

* Try to fix CI

* Fix Swift 5.6 build?

* Fix CI job?

* Manually specify deployment target, this seems to fix the problem in a clean checkout

* Update xcodeproj

* Revert rakefile changes to see if this isnt necessary anymore

* Fix macOS 13 SDK check

* Clean up

* Don't try to build for Xcode 13, which fails for some reason
  • Loading branch information
calda authored Jul 5, 2023
1 parent 9f9c93c commit fbcae5c
Show file tree
Hide file tree
Showing 23 changed files with 914 additions and 75 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ jobs:
- name: Build Package
run: bundle exec rake build:package

build-epoxy-core:
runs-on: macos-latest
strategy:
matrix:
xcode:
- '14.0.1' # Swift 5.7 (highest)
steps:
- uses: actions/checkout@v2
- uses: ./.github/actions/setup
with:
xcode: ${{ matrix.xcode }}
- name: Build EpoxyCore
run: bundle exec rake build:EpoxyCore

build-example:
runs-on: macos-latest
strategy:
Expand Down
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,21 @@ All notable changes to this project are documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/airbnb/epoxy-ios/compare/0.9.0...HEAD)
## [Unreleased](https://github.com/airbnb/epoxy-ios/compare/0.10.0...HEAD)

### Changed
- ...

### Fixed
- ...

## [0.10.0](https://github.com/airbnb/epoxy-ios/compare/0.9.0...0.10.0) - 2023-06-29

### Changed
- Dropped support for Swift 5.4.
- EpoxyCore now supports macOS and tvOS.
- Renamed EpoxyCore's `SwiftUIUIView` to `SwiftUIView`.
- Renamed EpoxyCore's `MeasuringUIViewRepresentable` to `MeasuringViewRepresentable`.
- Added `UIScrollView.keyboardAdjustsBottomBarOffset` escape hatch to disable bottom bar keyboard
avoidance for cases where the keyboard is avoided at a higher level (e.g. a
`UIPresentationController` subclass).
Expand Down
2 changes: 1 addition & 1 deletion ConfigurePodspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ def configure(spec:, name:, summary:, local_deps: [])
# The shared CocoaPods version number for Epoxy.
#
# Change this constant to increment the Podspec version for all Epoxy Podspecs from a single place.
version = '0.9.0'
version = '0.10.0'

spec.name = name
spec.summary = summary
Expand Down
3 changes: 3 additions & 0 deletions Epoxy.xcworkspace/contents.xcworkspacedata

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

7 changes: 7 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ namespace :build do
xcodebuild 'build -scheme Epoxy -destination generic/platform=iOS'
end

desc 'Builds the EpoxyCore package for iOS, macOS, and tvOS'
task :EpoxyCore do
xcodebuild 'build -scheme EpoxyCore -destination generic/platform=iOS'
xcodebuild 'build -scheme EpoxyCore -destination generic/platform=tvOS'
xcodebuild 'build -scheme EpoxyCore -destination generic/platform=macOS'
end

desc 'Builds the EpoxyExample app'
task :example do
xcodebuild 'build -scheme EpoxyExample -destination "platform=iOS Simulator,name=iPhone 12"'
Expand Down
587 changes: 587 additions & 0 deletions Sources/EpoxyCore/EpoxyCore.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "08E2E9042A4CD50700B47A18"
BuildableName = "EpoxyCore.framework"
BlueprintName = "EpoxyCore"
ReferencedContainer = "container:EpoxyCore.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "08E2E9042A4CD50700B47A18"
BuildableName = "EpoxyCore.framework"
BlueprintName = "EpoxyCore"
ReferencedContainer = "container:EpoxyCore.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
4 changes: 1 addition & 3 deletions Sources/EpoxyCore/Model/Providers/MakeViewProviding.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
// Created by eric_horacek on 12/1/20.
// Copyright © 2020 Airbnb Inc. All rights reserved.

import UIKit

// MARK: - MakeViewProviding

/// The capability of constructing a `UIView`.
public protocol MakeViewProviding {
/// The view constructed when the `MakeView` closure is called.
associatedtype View: UIView
associatedtype View: ViewType

/// A closure that's called to construct an instance of `View`.
typealias MakeView = () -> View
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Created by eric_horacek on 12/16/20.
// Copyright © 2020 Airbnb Inc. All rights reserved.

#if !os(macOS)
import UIKit

/// The capability of providing a `UITraitCollection` instance.
Expand All @@ -10,3 +11,4 @@ public protocol TraitCollectionProviding {
/// The `UITraitCollection` instance provided by this type.
var traitCollection: UITraitCollection { get }
}
#endif
4 changes: 1 addition & 3 deletions Sources/EpoxyCore/Model/Providers/ViewProviding.swift
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
// Created by eric_horacek on 12/16/20.
// Copyright © 2020 Airbnb Inc. All rights reserved.

import UIKit

/// The capability of providing an `View` instance
///
/// Typically conformed to by the `CallbackContext` of a `CallbackContextEpoxyModeled`.
public protocol ViewProviding {
/// The `UIView` view of this type.
associatedtype View: UIView
associatedtype View: ViewType

/// The `UIView` view instance provided by this type.
var view: View { get }
Expand Down
4 changes: 1 addition & 3 deletions Sources/EpoxyCore/Model/ViewEpoxyModeled.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// Created by eric_horacek on 12/4/20.
// Copyright © 2020 Airbnb Inc. All rights reserved.

import UIKit

/// An Epoxy model with an associated `UIView` type.
public protocol ViewEpoxyModeled: EpoxyModeled {
/// The view type associated with this model.
///
/// An instance of this view is typically configured by this model.
associatedtype View: UIView
associatedtype View: ViewType
}
2 changes: 2 additions & 0 deletions Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import SwiftUI

#if !os(macOS)
// MARK: - EpoxySwiftUIUIHostingController

/// A `UIHostingController` that hosts SwiftUI views within an Epoxy container, e.g. an Epoxy
Expand Down Expand Up @@ -41,3 +42,4 @@ open class EpoxySwiftUIHostingController<Content: View>: UIHostingController<Con
view.backgroundColor = .clear
}
}
#endif
4 changes: 4 additions & 0 deletions Sources/EpoxyCore/SwiftUI/EpoxySwiftUIHostingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import Combine
import SwiftUI

#if !os(macOS)

// MARK: - SwiftUIHostingViewReuseBehavior

/// The reuse behavior of an `EpoxySwiftUIHostingView`.
Expand Down Expand Up @@ -380,3 +382,5 @@ struct EpoxyHostingWrapper<Content: View>: View {
.environment(\.epoxyIntrinsicContentSizeInvalidator, environment.intrinsicContentSizeInvalidator)
}
}

#endif
16 changes: 8 additions & 8 deletions Sources/EpoxyCore/SwiftUI/EpoxyableView+SwiftUIView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ extension StyledView where Self: ContentConfigurableView & BehaviorsConfigurable
content: Content,
style: Style,
behaviors: Behaviors? = nil)
-> SwiftUIUIView<Self, (content: Content, style: Style)>
-> SwiftUIView<Self, (content: Content, style: Style)>
{
SwiftUIUIView(storage: (content: content, style: style)) {
SwiftUIView(storage: (content: content, style: style)) {
let view = Self(style: style)
view.setContent(content, animated: false)
return view
Expand Down Expand Up @@ -74,9 +74,9 @@ extension StyledView
public static func swiftUIView(
content: Content,
behaviors: Behaviors? = nil)
-> SwiftUIUIView<Self, Content>
-> SwiftUIView<Self, Content>
{
SwiftUIUIView(storage: content) {
SwiftUIView(storage: content) {
let view = Self()
view.setContent(content, animated: false)
return view
Expand Down Expand Up @@ -118,9 +118,9 @@ extension StyledView
public static func swiftUIView(
style: Style,
behaviors: Behaviors? = nil)
-> SwiftUIUIView<Self, Style>
-> SwiftUIView<Self, Style>
{
SwiftUIUIView(storage: style) {
SwiftUIView(storage: style) {
Self(style: style)
}
.configure { context in
Expand Down Expand Up @@ -157,8 +157,8 @@ extension StyledView
/// MyView.swiftUIView(…).sizing(.intrinsicSize)
/// ```
/// The sizing defaults to `.automatic`.
public static func swiftUIView(behaviors: Behaviors? = nil) -> SwiftUIUIView<Self, Void> {
SwiftUIUIView {
public static func swiftUIView(behaviors: Behaviors? = nil) -> SwiftUIView<Self, Void> {
SwiftUIView {
Self()
}
.configure { context in
Expand Down
Loading

0 comments on commit fbcae5c

Please sign in to comment.