Skip to content

Commit

Permalink
Merge pull request #6187 from realm/tg/spm
Browse files Browse the repository at this point in the history
Add a SwiftPM package
  • Loading branch information
tgoyne authored Jun 28, 2019
2 parents e4e158f + fc6ec59 commit 93fca58
Show file tree
Hide file tree
Showing 116 changed files with 1,389 additions and 798 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ xcuserdata/
project.xcworkspace
*.xccheckout
DerivedData
/.build

# AppCode
.idea/
Expand Down Expand Up @@ -111,3 +112,7 @@ examples/ios/objc/Draw/Constants.h
## Sync testing
test-ros-instance
Realm/ObjectServerTests/node_modules

## Swiftpm
.swiftpm
.build
58 changes: 38 additions & 20 deletions .jenkins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ target:
- tvos
- osx-encryption
- osx-object-server
- swiftpm

# These are disabled because the machinen with the devices attached is currently offline
# - ios-device-objc-ios8
Expand All @@ -38,26 +39,26 @@ configuration:
# Combinations have to be excluded in a way that's hard to read.
# This table shows which jobs will run:

# +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
# | Configuration Matrix | osx | docs | ios-static | ios-dynamic | ios-swift | osx-swift | watchos | cocoapods-ios | cocoapods-osx | cocoapods-watchos | swiftlint | tvos | osx-encryption | osx-object-server | ios-device-objc-ios8 | ios-device-swift-ios8 | ios-device-objc-ios10 | ios-device-swift-ios10 | tvos-device |
# | -------------------- | --- | ---- | ---------- | ----------- | --------- | --------- | ------- | ------------- | ------------- | ----------------- | --------- | ---- | -------------- | ----------------- | -------------------- | --------------------- | --------------------- | ---------------------- | ----------- |
# | 9.2 | Debug | X | | X | | | | | | | | | | | | | | | | |
# | 9.2 | Release | X | | X | X | X | X | X | X | X | X | | X | X | X | X | | X | | |
# | -------------------- | --- | ---- | ---------- | ----------- | --------- | --------- | ------- | ------------- | ------------- | ----------------- | --------- | ---- | -------------- | ----------------- | -------------------- | --------------------- | --------------------- | ---------------------- | ----------- |
# | 9.3 | Debug | X | | | | | | | | | | | | | | | | | | |
# | 9.3 | Release | X | | X | X | X | X | X | X | X | X | | X | | | | | | | |
# | -------------------- | --- | ---- | ---------- | ----------- | --------- | --------- | ------- | ------------- | ------------- | ----------------- | --------- | ---- | -------------- | ----------------- | -------------------- | --------------------- | --------------------- | ---------------------- | ----------- |
# | 9.4 | Debug | X | | | | | | | | | | | | | | | | | | |
# | 9.4 | Release | X | | X | X | X | X | X | X | X | X | | X | | | | | | | |
# | -------------------- | --- | ---- | ---------- | ----------- | --------- | --------- | ------- | ------------- | ------------- | ----------------- | --------- | ---- | -------------- | ----------------- | -------------------- | --------------------- | --------------------- | ---------------------- | ----------- |
# | 10.0 | Debug | X | | | | | | | | | | | | | | | | | | |
# | 10.0 | Release | X | | X | X | X | X | X | X | X | X | | X | | | | | | | |
# | -------------------- | --- | ---- | ---------- | ----------- | --------- | --------- | ------- | ------------- | ------------- | ----------------- | --------- | ---- | -------------- | ----------------- | -------------------- | --------------------- | --------------------- | ---------------------- | ----------- |
# | 10.1 | Debug | X | | | | | | | | | | | | | | | | | | |
# | 10.1 | Release | X | | X | X | X | X | X | X | X | X | | X | | | | | | | |
# | -------------------- | --- | ---- | ---------- | ----------- | --------- | --------- | ------- | ------------- | ------------- | ----------------- | --------- | ---- | -------------- | ----------------- | -------------------- | --------------------- | --------------------- | ---------------------- | ----------- |
# | 10.2.1| Debug | X | | | X | X | X | X | | | | | X | | | | | | | |
# | 10.2.1| Release | X | X | X | X | X | X | X | X | X | X | X | X | X | X | | | X | | X |
# +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
# | Configuration Matrix | osx | docs | ios-static | ios-dynamic | ios-swift | osx-swift | watchos | cocoapods-ios | cocoapods-osx | cocoapods-watchos | swiftlint | swiftpm | tvos | osx-encryption | osx-object-server | ios-device-objc-ios8 | ios-device-swift-ios8 | ios-device-objc-ios10 | ios-device-swift-ios10 | tvos-device |
# | -------------------- | --- | ---- | ---------- | ----------- | --------- | --------- | ------- | ------------- | ------------- | ----------------- | --------- | ------- | ---- | -------------- | ----------------- | -------------------- | --------------------- | --------------------- | ---------------------- | ----------- |
# | 9.2 | Debug | X | | X | | | | | | | | | | | | | | | | | |
# | 9.2 | Release | X | | X | X | X | X | X | X | X | X | | | X | X | X | X | | X | | |
# | -------------------- | --- | ---- | ---------- | ----------- | --------- | --------- | ------- | ------------- | ------------- | ----------------- | --------- | ------- | ---- | -------------- | ----------------- | -------------------- | --------------------- | --------------------- | ---------------------- | ----------- |
# | 9.3 | Debug | X | | | | | | | | | | | | | | | | | | | |
# | 9.3 | Release | X | | X | X | X | X | X | X | X | X | | | X | | | | | | | |
# | -------------------- | --- | ---- | ---------- | ----------- | --------- | --------- | ------- | ------------- | ------------- | ----------------- | --------- | ------- | ---- | -------------- | ----------------- | -------------------- | --------------------- | --------------------- | ---------------------- | ----------- |
# | 9.4 | Debug | X | | | | | | | | | | | | | | | | | | | |
# | 9.4 | Release | X | | X | X | X | X | X | X | X | X | | | X | | | | | | | |
# | -------------------- | --- | ---- | ---------- | ----------- | --------- | --------- | ------- | ------------- | ------------- | ----------------- | --------- | ------- | ---- | -------------- | ----------------- | -------------------- | --------------------- | --------------------- | ---------------------- | ----------- |
# | 10.0 | Debug | X | | | | | | | | | | | | | | | | | | | |
# | 10.0 | Release | X | | X | X | X | X | X | X | X | X | | | X | | | | | | | |
# | -------------------- | --- | ---- | ---------- | ----------- | --------- | --------- | ------- | ------------- | ------------- | ----------------- | --------- | ------- | ---- | -------------- | ----------------- | -------------------- | --------------------- | --------------------- | ---------------------- | ----------- |
# | 10.1 | Debug | X | | | | | | | | | | | | | | | | | | | |
# | 10.1 | Release | X | | X | X | X | X | X | X | X | X | | | X | | | | | | | |
# | -------------------- | --- | ---- | ---------- | ----------- | --------- | --------- | ------- | ------------- | ------------- | ----------------- | --------- | ------- | ---- | -------------- | ----------------- | -------------------- | --------------------- | --------------------- | ---------------------- | ----------- |
# | 10.2.1| Debug | X | | | X | X | X | X | | | | | | X | | | | | | | |
# | 10.2.1| Release | X | X | X | X | X | X | X | X | X | X | X | X | X | X | X | | | X | | X |
# +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

exclude:
Expand Down Expand Up @@ -206,6 +207,23 @@ exclude:
- target: swiftlint
configuration: Debug

################
# swiftpm
################
# Just run on 10.2 Release
- xcode_version: 9.2
target: swiftpm
- xcode_version: 9.3
target: swiftpm
- xcode_version: 9.4
target: swiftpm
- xcode_version: 10.0
target: swiftpm
- xcode_version: 10.1
target: swiftpm
- target: swiftpm
configuration: Debug

################
# tvos
################
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
x.y.z Release notes (yyyy-MM-dd)
=============================================================
### Enhancements
* None.
* Add support for including Realm via Swift Package Manager.

### Fixed
* <How to hit and notice issue? what was the impact?> ([#????](https://github.com/realm/realm-js/issues/????), since v?.?.?)
Expand Down
3 changes: 2 additions & 1 deletion Configuration/Realm/Tests iOS static.xcconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "Tests.xcconfig"

CONFIGURATION_BUILD_DIR = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)-static;
CONFIGURATION_TEMP_DIR = $(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)-static;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;

TEST_HOST[sdk=iphone*] = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/TestHost.app/TestHost;
TEST_HOST[sdk=iphone*] = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)-static/TestHost static.app/TestHost static;
4 changes: 4 additions & 0 deletions Configuration/TestHost-static.xcconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "TestHost.xcconfig"

CONFIGURATION_BUILD_DIR = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)-static;
CONFIGURATION_TEMP_DIR = $(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)-static;
1 change: 1 addition & 0 deletions Configuration/TestHost.xcconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
SUPPORTED_PLATFORMS = macosx iphonesimulator iphoneos appletvos appletvsimulator;

CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
LD_RUNPATH_SEARCH_PATHS = $(inherited) @executable_path/Frameworks;
INFOPLIST_FILE = Realm/Tests/TestHost/Info.plist;
Expand Down
132 changes: 132 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
// swift-tools-version:5.0

import PackageDescription
import Foundation

let coreVersionStr = "5.20.0"
let cocoaVersionStr = "3.16.2"

let coreVersionPieces = coreVersionStr.split(separator: ".")
let cxxSettings: [CXXSetting] = [
.headerSearchPath("."),
.headerSearchPath("include"),
.headerSearchPath("Realm/ObjectStore/src"),
.define("REALM_SPM", to: "1"),
.define("REALM_COCOA_VERSION", to: "@\"\(cocoaVersionStr)\""),
.define("REALM_VERSION", to: "\"\(coreVersionStr)\""),

.define("REALM_NO_CONFIG"),
.define("REALM_INSTALL_LIBEXECDIR", to: ""),
.define("REALM_ENABLE_ASSERTIONS", to: "1"),
.define("REALM_ENABLE_ENCRYPTION", to: "1"),

.define("REALM_VERSION_MAJOR", to: String(coreVersionPieces[0])),
.define("REALM_VERSION_MINOR", to: String(coreVersionPieces[1])),
.define("REALM_VERSION_PATCH", to: String(coreVersionPieces[2])),
.define("REALM_VERSION_EXTRA", to: "\"\""),
.define("REALM_VERSION_STRING", to: "\"\(coreVersionStr)\""),
]

let package = Package(
name: "Realm",
products: [
.library(
name: "Realm",
targets: ["Realm"]),
.library(
name: "RealmSwift",
targets: ["Realm", "RealmSwift"]),
],
dependencies: [
.package(url: "https://github.com/realm/realm-core", .branch("master")),
],
targets: [
.target(
name: "Realm",
dependencies: ["RealmCore"],
path: ".",
exclude: [
"Realm/NSError+RLMSync.m",
"Realm/RLMJSONModels.m",
"Realm/RLMNetworkClient.mm",
"Realm/RLMRealm+Sync.mm",
"Realm/RLMRealmConfiguration+Sync.mm",
"Realm/RLMSyncConfiguration.mm",
"Realm/RLMSyncCredentials.m",
"Realm/RLMSyncManager.mm",
"Realm/RLMSyncPermission.mm",
"Realm/RLMSyncPermissionResults.mm",
"Realm/RLMSyncSession.mm",
"Realm/RLMSyncSessionRefreshHandle.mm",
"Realm/RLMSyncSubscription.mm",
"Realm/RLMSyncUser.mm",
"Realm/RLMSyncUtil.mm",

"Realm/ObjectServerTests",
"Realm/Swift",
"Realm/Tests",
"Realm/TestUtils",
"Realm/ObjectStore/external",
"Realm/ObjectStore/tests",
"Realm/ObjectStore/src/server",
"Realm/ObjectStore/src/sync",
"Realm/ObjectStore/src/impl/generic",
"Realm/ObjectStore/src/impl/epoll",
"Realm/ObjectStore/src/impl/android",
"Realm/ObjectStore/src/impl/windows",
],
sources: ["Realm"],
publicHeadersPath: "include",
cxxSettings: cxxSettings
),
.target(
name: "RealmSwift",
dependencies: ["Realm"],
path: "RealmSwift",
exclude: [
"Sync.swift",
"ObjectiveCSupport+Sync.swift",
"Tests",
]
),
.target(
name: "RealmTestSupport",
dependencies: ["Realm"],
path: "Realm/TestUtils",
cxxSettings: cxxSettings + [
// Command-line `swift build` resolves header search paths
// relative to the package root, while Xcode resolves them
// relative to the target root, so we need both.
.headerSearchPath("Realm"),
.headerSearchPath(".."),
]
),
.testTarget(
name: "RealmTests",
dependencies: ["Realm", "RealmTestSupport"],
path: "Realm/Tests",
exclude: [
"Swift",
"TestHost",
"PrimitiveArrayPropertyTests.tpl.m",
],
cxxSettings: cxxSettings + [
.headerSearchPath("Realm"),
.headerSearchPath(".."),
.headerSearchPath("../ObjectStore/src"),
]
),
.testTarget(
name: "RealmObjcSwiftTests",
dependencies: ["Realm", "RealmTestSupport"],
path: "Realm/Tests/Swift"
),
.testTarget(
name: "RealmSwiftTests",
dependencies: ["RealmSwift", "RealmTestSupport"],
path: "RealmSwift/Tests",
exclude: ["TestUtils.mm"]
)
],
cxxLanguageStandard: .cxx14
)
Loading

0 comments on commit 93fca58

Please sign in to comment.