Skip to content

Commit dcc0f60

Browse files
committed
Initial commit
0 parents  commit dcc0f60

21 files changed

+805
-0
lines changed

.github/workflows/ci.yml

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- '*'
10+
workflow_dispatch:
11+
12+
concurrency:
13+
group: ci-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
xcodebuild-latest:
18+
name: xcodebuild (16.2)
19+
if: |
20+
!contains(github.event.head_commit.message, '[ci skip]') &&
21+
!contains(github.event.head_commit.message, '[ci skip xcodebuild-latest]')
22+
runs-on: macos-15
23+
strategy:
24+
matrix:
25+
command: [test, '']
26+
platform: [IOS, MAC_CATALYST, MACOS, TVOS, VISIONOS, WATCHOS]
27+
xcode: ['16.2']
28+
steps:
29+
- uses: actions/checkout@v4
30+
- name: Select Xcode ${{ matrix.xcode }}
31+
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
32+
- name: Install visionOS runtime
33+
if: matrix.platform == 'visionOS'
34+
run: |
35+
sudo xcodebuild -runFirstLaunch
36+
sudo xcrun simctl list
37+
sudo xcodebuild -downloadPlatform visionOS
38+
sudo xcodebuild -runFirstLaunch
39+
- name: List available devices
40+
run: xcrun simctl list devices available
41+
- name: Cache derived data
42+
uses: actions/cache@v3
43+
with:
44+
path: |
45+
~/.derivedData
46+
key: |
47+
deriveddata-xcodebuild-${{ matrix.platform }}-${{ matrix.xcode }}-${{ matrix.command }}-${{ hashFiles('**/Sources/**/*.swift', '**/Tests/**/*.swift') }}
48+
restore-keys: |
49+
deriveddata-xcodebuild-${{ matrix.platform }}-${{ matrix.xcode }}-${{ matrix.command }}-
50+
- name: Set IgnoreFileSystemDeviceInodeChanges flag
51+
run: defaults write com.apple.dt.XCBuild IgnoreFileSystemDeviceInodeChanges -bool YES
52+
- name: Update mtime for incremental builds
53+
uses: chetan/git-restore-mtime-action@v2
54+
- name: Debug
55+
run: make XCODEBUILD_ARGUMENT="${{ matrix.command }}" CONFIG=Debug PLATFORM="${{ matrix.platform }}" WORKSPACE=Package.xcworkspace xcodebuild
56+
- name: Release
57+
if: matrix.command != 'test'
58+
run: make XCODEBUILD_ARGUMENT="${{ matrix.command }}" CONFIG=Release PLATFORM="${{ matrix.platform }}" WORKSPACE=Package.xcworkspace xcodebuild

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.DS_Store
2+
/.build
3+
/Packages
4+
xcuserdata/
5+
DerivedData/
6+
.swiftpm/configuration/registries.json
7+
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
8+
.netrc

.spi.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
version: 1
2+
builder:
3+
configs:
4+
- documentation_targets: [ExistentialTrampoline]
5+
swift_version: 6.0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
6+
<true/>
7+
</dict>
8+
</plist>

ACKNOWLEDGMENTS.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Initially I was challenged with the idea of creating AnyView from Any by https://github.com/glukianets at the end of 2k22.
2+
3+
It was fun, I successfully passed the challenge, and now I challenge u, my reader, to implement similar thing without use of `_openExistential` (it is possible tho even more tricky) 😎

LICENCE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 CaptureContext
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
CONFIG = Debug
2+
3+
DERIVED_DATA_PATH = ~/.derivedData/$(CONFIG)
4+
5+
PLATFORM_IOS = iOS Simulator,id=$(call udid_for,iOS,iPhone \d\+ Pro [^M])
6+
PLATFORM_MACOS = macOS
7+
PLATFORM_MAC_CATALYST = macOS,variant=Mac Catalyst
8+
PLATFORM_TVOS = tvOS Simulator,id=$(call udid_for,tvOS,TV)
9+
PLATFORM_VISIONOS = visionOS Simulator,id=$(call udid_for,visionOS,Vision)
10+
PLATFORM_WATCHOS = watchOS Simulator,id=$(call udid_for,watchOS,Watch)
11+
12+
PLATFORM = IOS
13+
DESTINATION = platform="$(PLATFORM_$(PLATFORM))"
14+
15+
PLATFORM_ID = $(shell echo "$(DESTINATION)" | sed -E "s/.+,id=(.+)/\1/")
16+
17+
WORKSPACE = Package.xcworkspace
18+
SCHEME = swift-existential-container
19+
20+
XCODEBUILD_ARGUMENT = test
21+
22+
XCODEBUILD_FLAGS = \
23+
-configuration $(CONFIG) \
24+
-derivedDataPath $(DERIVED_DATA_PATH) \
25+
-destination $(DESTINATION) \
26+
-scheme "$(SCHEME)" \
27+
-skipMacroValidation \
28+
-workspace $(WORKSPACE)
29+
30+
XCODEBUILD_COMMAND = xcodebuild $(XCODEBUILD_ARGUMENT) $(XCODEBUILD_FLAGS)
31+
32+
ifneq ($(strip $(shell which xcbeautify)),)
33+
XCODEBUILD = set -o pipefail && $(XCODEBUILD_COMMAND) | xcbeautify --quiet
34+
else
35+
XCODEBUILD = $(XCODEBUILD_COMMAND)
36+
endif
37+
38+
TEST_RUNNER_CI = $(CI)
39+
40+
warm-simulator:
41+
@test "$(PLATFORM_ID)" != "" \
42+
&& xcrun simctl boot $(PLATFORM_ID) \
43+
&& open -a Simulator --args -CurrentDeviceUDID $(PLATFORM_ID) \
44+
|| exit 0
45+
46+
xcodebuild: warm-simulator
47+
$(XCODEBUILD)
48+
49+
# Workaround for debugging Swift Testing tests: https://github.com/cpisciotta/xcbeautify/issues/313
50+
xcodebuild-raw: warm-simulator
51+
$(XCODEBUILD_COMMAND)
52+
53+
build-for-library-evolution:
54+
swift build \
55+
-q \
56+
-c release \
57+
--target "$(SCHEME)" \
58+
-Xswiftc -emit-module-interface \
59+
-Xswiftc -enable-library-evolution
60+
61+
.PHONY: build-for-library-evolution format warm-simulator xcodebuild xcodebuild-raw
62+
63+
define udid_for
64+
$(shell xcrun simctl list devices available '$(1)' | grep '$(2)' | sort -r | head -1 | awk -F '[()]' '{ print $$(NF-3) }')
65+
endef

Package.swift

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// swift-tools-version: 6.0
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "swift-existential-container",
7+
products: [
8+
.library(
9+
name: "ExistentialContainer",
10+
targets: ["ExistentialContainer"]
11+
),
12+
],
13+
targets: [
14+
.target(name: "ExistentialContainer"),
15+
.testTarget(
16+
name: "ExistentialContainerTests",
17+
dependencies: [
18+
.target(name: "ExistentialContainer")
19+
]
20+
),
21+
]
22+
)

Package.xcworkspace/contents.xcworkspacedata

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
6+
<false/>
7+
</dict>
8+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1610"
4+
version = "1.7">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES"
8+
buildArchitectures = "Automatic">
9+
<BuildActionEntries>
10+
<BuildActionEntry
11+
buildForTesting = "YES"
12+
buildForRunning = "YES"
13+
buildForProfiling = "YES"
14+
buildForArchiving = "YES"
15+
buildForAnalyzing = "YES">
16+
<BuildableReference
17+
BuildableIdentifier = "primary"
18+
BlueprintIdentifier = "ExistentialContainer"
19+
BuildableName = "ExistentialContainer"
20+
BlueprintName = "ExistentialContainer"
21+
ReferencedContainer = "container:">
22+
</BuildableReference>
23+
</BuildActionEntry>
24+
</BuildActionEntries>
25+
</BuildAction>
26+
<TestAction
27+
buildConfiguration = "Debug"
28+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
29+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
30+
shouldUseLaunchSchemeArgsEnv = "YES"
31+
shouldAutocreateTestPlan = "YES">
32+
</TestAction>
33+
<LaunchAction
34+
buildConfiguration = "Debug"
35+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
36+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
37+
launchStyle = "0"
38+
useCustomWorkingDirectory = "NO"
39+
ignoresPersistentStateOnLaunch = "NO"
40+
debugDocumentVersioning = "YES"
41+
debugServiceExtension = "internal"
42+
allowLocationSimulation = "YES">
43+
</LaunchAction>
44+
<ProfileAction
45+
buildConfiguration = "Release"
46+
shouldUseLaunchSchemeArgsEnv = "YES"
47+
savedToolIdentifier = ""
48+
useCustomWorkingDirectory = "NO"
49+
debugDocumentVersioning = "YES">
50+
<MacroExpansion>
51+
<BuildableReference
52+
BuildableIdentifier = "primary"
53+
BlueprintIdentifier = "ExistentialContainer"
54+
BuildableName = "ExistentialContainer"
55+
BlueprintName = "ExistentialContainer"
56+
ReferencedContainer = "container:">
57+
</BuildableReference>
58+
</MacroExpansion>
59+
</ProfileAction>
60+
<AnalyzeAction
61+
buildConfiguration = "Debug">
62+
</AnalyzeAction>
63+
<ArchiveAction
64+
buildConfiguration = "Release"
65+
revealArchiveInOrganizer = "YES">
66+
</ArchiveAction>
67+
</Scheme>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1610"
4+
version = "1.7">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES"
8+
buildArchitectures = "Automatic">
9+
</BuildAction>
10+
<TestAction
11+
buildConfiguration = "Debug"
12+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
13+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
14+
shouldUseLaunchSchemeArgsEnv = "YES"
15+
shouldAutocreateTestPlan = "YES">
16+
<Testables>
17+
<TestableReference
18+
skipped = "NO">
19+
<BuildableReference
20+
BuildableIdentifier = "primary"
21+
BlueprintIdentifier = "ExistentialContainerTests"
22+
BuildableName = "ExistentialContainerTests"
23+
BlueprintName = "ExistentialContainerTests"
24+
ReferencedContainer = "container:">
25+
</BuildableReference>
26+
</TestableReference>
27+
</Testables>
28+
</TestAction>
29+
<LaunchAction
30+
buildConfiguration = "Debug"
31+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
32+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
33+
launchStyle = "0"
34+
useCustomWorkingDirectory = "NO"
35+
ignoresPersistentStateOnLaunch = "NO"
36+
debugDocumentVersioning = "YES"
37+
debugServiceExtension = "internal"
38+
allowLocationSimulation = "YES">
39+
</LaunchAction>
40+
<ProfileAction
41+
buildConfiguration = "Release"
42+
shouldUseLaunchSchemeArgsEnv = "YES"
43+
savedToolIdentifier = ""
44+
useCustomWorkingDirectory = "NO"
45+
debugDocumentVersioning = "YES">
46+
</ProfileAction>
47+
<AnalyzeAction
48+
buildConfiguration = "Debug">
49+
</AnalyzeAction>
50+
<ArchiveAction
51+
buildConfiguration = "Release"
52+
revealArchiveInOrganizer = "YES">
53+
</ArchiveAction>
54+
</Scheme>

0 commit comments

Comments
 (0)