Skip to content

Commit

Permalink
Merge pull request #1237 from AnthonyMDev/vision-os
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanfallet committed Apr 13, 2024
2 parents 0435dd1 + a2a550e commit 2d964a7
Show file tree
Hide file tree
Showing 12 changed files with 495 additions and 19 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
name: Build and test
on: [push, pull_request]
env:
IOS_SIMULATOR: "iPhone 14"
IOS_VERSION: "16.2"
IOS_SIMULATOR: "iPhone 15"
IOS_VERSION: "17.2"
jobs:
build:
runs-on: macos-13
runs-on: macos-14
steps:
- uses: actions/checkout@v2
- name: "Select Xcode"
# Currently only works with Xcode 14.2:
# https://github.com/CocoaPods/CocoaPods/issues/11839
run: |
xcode-select -p
sudo xcode-select -s /Applications/Xcode_14.2.app/Contents/Developer
sudo xcode-select -s /Applications/Xcode_15.3.app/Contents/Developer
- name: "Lint"
run: make lint
- name: "Run tests (PACKAGE_MANAGER_COMMAND: test)"
Expand Down Expand Up @@ -64,6 +64,10 @@ jobs:
env:
CARTHAGE_PLATFORM: tvOS
run: ./run-tests.sh
- name: "Run tests (CARTHAGE_PLATFORM: visionOS)"
env:
CARTHAGE_PLATFORM: visionOS
run: ./run-tests.sh
build-linux:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
source "https://rubygems.org"

gem 'cocoapods', :git => 'https://github.com/SagarSDagdu/CocoaPods.git', tag: '1.15.2.1-sagard'
13 changes: 6 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ GIT
xcodeproj (>= 1.23.0, < 2.0)

GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.7)
base64
Expand All @@ -45,7 +46,7 @@ GEM
json (>= 1.5.1)
atomos (0.1.3)
base64 (0.2.0)
bigdecimal (3.1.5)
bigdecimal (3.1.7)
claide (1.1.0)
cocoapods-core (1.15.2)
activesupport (>= 5.0, < 8)
Expand All @@ -69,8 +70,7 @@ GEM
colored2 (3.1.2)
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
drb (2.2.0)
ruby2_keywords
drb (2.2.1)
escape (0.0.4)
ethon (0.16.0)
ffi (>= 1.15.0)
Expand All @@ -81,18 +81,17 @@ GEM
httpclient (2.8.3)
i18n (1.14.4)
concurrent-ruby (~> 1.0)
json (2.7.1)
minitest (5.22.0)
json (2.7.2)
minitest (5.22.3)
molinillo (0.8.0)
mutex_m (0.2.0)
nanaimo (0.3.0)
nap (1.1.0)
netrc (0.11.0)
nkf (0.1.3)
nkf (0.2.0)
public_suffix (4.0.7)
rexml (3.2.6)
ruby-macho (2.5.1)
ruby2_keywords (0.0.5)
typhoeus (1.4.1)
ethon (>= 0.9.0)
tzinfo (2.0.6)
Expand Down
5 changes: 3 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.7
// swift-tools-version:5.9
import PackageDescription

let package = Package(
Expand All @@ -7,7 +7,8 @@ let package = Package(
.iOS(.v11),
.macOS(.v10_13),
.watchOS(.v4),
.tvOS(.v11)
.tvOS(.v11),
.visionOS(.v1)
],
products: [
.library(
Expand Down
15 changes: 15 additions & 0 deletions SQLite.swift.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ Pod::Spec.new do |s|
ss.source_files = 'Sources/SQLite/**/*.{c,h,m,swift}'
ss.exclude_files = 'Sources/**/Cipher.swift'
ss.library = 'sqlite3'

ss.ios.deployment_target = ios_deployment_target
ss.tvos.deployment_target = tvos_deployment_target
ss.osx.deployment_target = osx_deployment_target
ss.watchos.deployment_target = watchos_deployment_target

ss.test_spec 'tests' do |test_spec|
test_spec.resources = 'Tests/SQLiteTests/Resources/*'
Expand All @@ -51,6 +56,11 @@ Pod::Spec.new do |s|
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) SQLITE_SWIFT_STANDALONE=1'
}
ss.dependency 'sqlite3'

ss.ios.deployment_target = ios_deployment_target
ss.tvos.deployment_target = tvos_deployment_target
ss.osx.deployment_target = osx_deployment_target
ss.watchos.deployment_target = watchos_deployment_target

ss.test_spec 'tests' do |test_spec|
test_spec.resources = 'Tests/SQLiteTests/Resources/*'
Expand All @@ -68,6 +78,11 @@ Pod::Spec.new do |s|
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) SQLITE_HAS_CODEC=1 SQLITE_SWIFT_SQLCIPHER=1'
}
ss.dependency 'SQLCipher', '>= 4.0.0'

ss.ios.deployment_target = ios_deployment_target
ss.tvos.deployment_target = tvos_deployment_target
ss.osx.deployment_target = osx_deployment_target
ss.watchos.deployment_target = watchos_deployment_target

ss.test_spec 'tests' do |test_spec|
test_spec.resources = 'Tests/SQLiteTests/Resources/*'
Expand Down
340 changes: 340 additions & 0 deletions SQLite.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

71 changes: 71 additions & 0 deletions SQLite.xcodeproj/xcshareddata/xcschemes/SQLite visionOS.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1520"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DEB306B82B61CEF500F9D46B"
BuildableName = "SQLite.framework"
BlueprintName = "SQLite visionOS"
ReferencedContainer = "container:SQLite.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<TestPlans>
<TestPlanReference
reference = "container:Tests/SQLite visionOS.xctestplan"
default = "YES">
</TestPlanReference>
</TestPlans>
</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 = "DEB306B82B61CEF500F9D46B"
BuildableName = "SQLite.framework"
BlueprintName = "SQLite visionOS"
ReferencedContainer = "container:SQLite.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
2 changes: 1 addition & 1 deletion Tests/Carthage/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CARTHAGE := /usr/local/bin/carthage
CARTHAGE := $(shell which carthage)
CARTHAGE_PLATFORM := iOS
CARTHAGE_CONFIGURATION := Release
CARTHAGE_DIR := Carthage
Expand Down
24 changes: 24 additions & 0 deletions Tests/SQLite visionOS.xctestplan
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"configurations" : [
{
"id" : "72B91FD4-441C-4C06-9E92-CAEDCB7325AB",
"name" : "Configuration 1",
"options" : {

}
}
],
"defaultOptions" : {

},
"testTargets" : [
{
"target" : {
"containerPath" : "container:SQLite.xcodeproj",
"identifier" : "DEB306E72B61CF9500F9D46B",
"name" : "SQLiteTests visionOS"
}
}
],
"version" : 1
}
10 changes: 10 additions & 0 deletions Tests/SQLiteTests/TestHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ func assertSQL(_ expression1: @autoclosure () -> String, _ expression2: @autoclo
XCTAssertEqual(expression1(), expression2().asSQL(), file: file, line: line)
}

func extractAndReplace(_ value: String, regex: String, with replacement: String) -> (String, String) {
// We cannot use `Regex` because it is not available before iOS 16 :(
let regex = try! NSRegularExpression(pattern: regex)
let valueRange = NSRange(location: 0, length: value.utf16.count)
let match = regex.firstMatch(in: value, options: [], range: valueRange)!.range
let range = Range(match, in: value)!
let extractedValue = String(value[range])
return (value.replacingCharacters(in: range, with: replacement), extractedValue)
}

let table = Table("table")
let qualifiedTable = Table("table", database: "main")
let virtualTable = VirtualTable("virtual_table")
Expand Down
15 changes: 12 additions & 3 deletions Tests/SQLiteTests/Typed/QueryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,22 @@ class QueryTests: XCTestCase {
let insert = try emails.insert(value)
let encodedJSON = try JSONEncoder().encode(value1)
let encodedJSONString = String(data: encodedJSON, encoding: .utf8)!
assertSQL(

let expectedSQL =
"""
INSERT INTO \"emails\" (\"int\", \"string\", \"bool\", \"float\", \"double\", \"date\", \"uuid\", \"optional\",
\"sub\") VALUES (1, '2', 1, 3.0, 4.0, '1970-01-01T00:00:00.000', 'E621E1F8-C36C-495A-93FC-0C247A3E6E5F',
'optional', '\(encodedJSONString)')
""".replacingOccurrences(of: "\n", with: ""),
insert
""".replacingOccurrences(of: "\n", with: "")

// As JSON serialization gives a different result each time, we extract JSON and compare it by deserializing it
// and keep comparing the query but with the json replaced by the `JSON` string
let (expectedQuery, expectedJSON) = extractAndReplace(expectedSQL, regex: "\\{.*\\}", with: "JSON")
let (actualQuery, actualJSON) = extractAndReplace(insert.asSQL(), regex: "\\{.*\\}", with: "JSON")
XCTAssertEqual(expectedQuery, actualQuery)
XCTAssertEqual(
try JSONDecoder().decode(TestCodable.self, from: expectedJSON.data(using: .utf8)!),
try JSONDecoder().decode(TestCodable.self, from: actualJSON.data(using: .utf8)!)
)
}
#endif
Expand Down
5 changes: 3 additions & 2 deletions run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ if [ -n "$BUILD_SCHEME" ]; then
make test BUILD_SCHEME="$BUILD_SCHEME"
fi
elif [ -n "$VALIDATOR_SUBSPEC" ]; then
bundle install
if [ "$VALIDATOR_SUBSPEC" == "none" ]; then
pod lib lint --no-subspecs --fail-fast
bundle exec pod lib lint --no-subspecs --fail-fast
else
pod lib lint --subspec="${VALIDATOR_SUBSPEC}" --fail-fast
bundle exec pod lib lint --subspec="${VALIDATOR_SUBSPEC}" --fail-fast
fi
elif [ -n "$CARTHAGE_PLATFORM" ]; then
cd Tests/Carthage && make test CARTHAGE_PLATFORM="$CARTHAGE_PLATFORM"
Expand Down

0 comments on commit 2d964a7

Please sign in to comment.