Skip to content

Commit

Permalink
Merge pull request #27 from tradingview/feature/spm
Browse files Browse the repository at this point in the history
Add spm support
  • Loading branch information
makedonsky94 authored Oct 22, 2021
2 parents 873a0f2 + 4baeead commit 8b3023b
Show file tree
Hide file tree
Showing 95 changed files with 75 additions and 21 deletions.
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@
*.xcarchive
**/xcuserdata/**

Pods/
Pods/

.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
2 changes: 1 addition & 1 deletion Example/LightweightCharts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"error: SwiftLint does not exist, install it using brew install swiftlint\"\n exit 1\nfi\n";
shellScript = "#if which swiftlint >/dev/null; then\n # swiftlint\n#else\n # echo \"error: SwiftLint does not exist, install it using brew #install swiftlint\"\n #exit 1\n#fi\n";
};
DA29DE437F7165F7E6B7BF21 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
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>
2 changes: 1 addition & 1 deletion Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ EXTERNAL SOURCES:
:path: "../"

SPEC CHECKSUMS:
LightweightCharts: f4f71d444412003d793ba5dee4c38dc7aea66097
LightweightCharts: 1a6c10a3eccb065f3a270dd0c26515ca714f786a

PODFILE CHECKSUM: 10aa45b030d82b96cfc0e4e3b143c5488576107b

Expand Down
18 changes: 2 additions & 16 deletions LightweightCharts.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,8 @@ Pod::Spec.new do |s|
s.author = { 'TradingView, Inc.' => '[email protected]' }
s.source = { :git => 'https://github.com/tradingview/LightweightChartsIOS.git', :tag => s.version }
s.ios.deployment_target = '10.0'
s.source_files = 'LightweightCharts/**/*.swift'
s.resources = 'LightweightCharts/Assets/*'
s.source_files = 'Sources/LightweightCharts/**/*.swift'
s.resources = 'Sources/LightweightCharts/Assets/*'
s.swift_version = '5.0'

s.script_phase = {
:name => 'LightweightCharts',

:script => 'LIBRARY=${TEMP_DIR}/lightweight-charts.js
if [ "${CONFIGURATION}" = "Release" ]; then
curl -o $LIBRARY https://unpkg.com/[email protected]/dist/lightweight-charts.standalone.production.js
else
curl -o $LIBRARY https://unpkg.com/[email protected]/dist/lightweight-charts.standalone.development.js
fi
cp -f $LIBRARY ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/lightweight-charts.js'
}

end
Empty file removed LightweightCharts/Assets/.gitkeep
Empty file.
Empty file removed LightweightCharts/Classes/.gitkeep
Empty file.
28 changes: 28 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// swift-tools-version:5.5
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "LightweightCharts",
platforms: [
.iOS(.v10)
],
products: [
.library(
name: "LightweightCharts",
targets: ["LightweightCharts"]),
],
dependencies: [],
targets: [
.target(
name: "LightweightCharts",
dependencies: [],
exclude: ["Extensions/Bundle+Resources.swift"],
resources: [
.process("Assets/content-setup.js"),
.process("Assets/lightweight-charts.js"),
.process("Assets/wrapper_functions.js")
])
]
)
7 changes: 7 additions & 0 deletions Sources/LightweightCharts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
File renamed without changes.
7 changes: 7 additions & 0 deletions Sources/LightweightCharts/Assets/lightweight-charts.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Sources/LightweightCharts/Extensions/Bundle+Resources.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Foundation

extension Bundle {
static var module: Bundle = {
Bundle(for: LightweightCharts.self)
}()
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import UIKit

extension UIColor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,11 @@ public class LightweightCharts: UIView {
}

private func loadScript(withName fileName: String) throws -> String {
let bundle = Bundle(for: LightweightCharts.self)
let bundle = Bundle.module
let pathForJSRuntime = bundle.path(forResource: fileName, ofType: "js")
guard let path = pathForJSRuntime else { return "" }
guard let path = pathForJSRuntime else {
return ""
}
return try String(contentsOfFile: path, encoding: .utf8)
}

Expand Down

0 comments on commit 8b3023b

Please sign in to comment.