Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added SPM Support #49

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ xcuserdata
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
.build/
.swiftpm/

# CocoaPods
#
Expand Down
26 changes: 26 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// swift-tools-version:5.3

import PackageDescription

let package = Package(
name: "Solar",
products: [
.library(name: "Solar", targets: ["Solar"]),
],
dependencies: [ ],
targets: [
.target(
name: "Solar",
dependencies: [],
path: "Solar",
exclude: ["Info-iOS.plist", "Info-watchOS.plist"]),

.testTarget(
name: "SolarTests",
dependencies: ["Solar"],
path: "Solar iOSTests",
exclude: ["Info.plist"],
resources: [.copy("CorrectResults.json")]
),
]
)
8 changes: 7 additions & 1 deletion Solar iOSTests/Solar_iOSTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ final class Solar_iOSTests: XCTestCase {
private let testAccuracy: TimeInterval = 60 * 5

private lazy var cities: [City] = {
#if SWIFT_PACKAGE
let bundle = Bundle.module
#else
let bundle = Bundle(for: type(of: self))
#endif

guard
let resultsURLString = Bundle(for: type(of: self)).path(forResource: "CorrectResults", ofType: "json"),
let resultsURLString = bundle.path(forResource: "CorrectResults", ofType: "json"),
let data = try? Data(contentsOf: URL(fileURLWithPath: resultsURLString)),
let dictionary = try? JSONSerialization.jsonObject(with: data, options: []),
let cityDictionaries = dictionary as? [[String : Any]]
Expand Down
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>