[Chore] Reorganize project structure for SPM (#248)

* Adjust folder structure to match Swift package structure

* Update package manifest

* Add bundle helper

# Conflicts:
#	Sources/Down/Views/DownView.swift

* Add bundle helper to xcode proj

* Update codecov config

* Update build phase script

* Update podspec

* Try to fix podspec

* Try to fix podspec again
This commit is contained in:
John Nguyen
2021-02-28 14:26:02 +01:00
committed by GitHub
parent 4c1c888152
commit 4fb13c2fac
216 changed files with 132 additions and 57 deletions
+11 -11
View File
@@ -2,22 +2,22 @@ Pod::Spec.new do |spec|
spec.name = "Down"
spec.summary = "Blazing fast Markdown rendering in Swift, built upon cmark."
spec.version = "0.9.5"
spec.homepage = "https://github.com/iwasrobbed/Down"
spec.homepage = "https://github.com/johnxnguyen/Down"
spec.license = { :type => "MIT", :file => "LICENSE" }
spec.authors = { "Rob Phillips" => "rob@robphillips.me" }
spec.source = { :git => "https://github.com/iwasrobbed/Down.git", :tag => "v" + spec.version.to_s }
spec.source_files = "Source/{AST,cmark,Enums & Options,Extensions,Renderers}/**/*.{h,c,swift}", "Source/*"
spec.ios.source_files = "Source/Views/**"
spec.osx.source_files = "Source/Views/**"
spec.public_header_files = "Source/*.h"
spec.authors = { "John Nguyen" => "polyxo@protonmail.com" }
spec.source = { :git => "https://github.com/johnxnguyen/Down.git", :tag => "v" + spec.version.to_s }
spec.source_files = "Sources/Down/{AST,Enums & Options,Extensions,Renderers}/**/*.swift", "Sources/cmark/*.{h,c}", "Sources/Down/*"
spec.ios.source_files = "Sources/Down/Views/**"
spec.osx.source_files = "Sources/Down/Views/**"
spec.public_header_files = "Sources/Down/*.h"
spec.ios.deployment_target = "9.0"
spec.tvos.deployment_target = "9.0"
spec.osx.deployment_target = "10.11"
spec.requires_arc = true
spec.module_name = "Down"
spec.preserve_paths = "Source/cmark/include/module.modulemap", "Source/cmark/*.inc", "Source/cmark/COPYING"
spec.pod_target_xcconfig = { 'SWIFT_INCLUDE_PATHS' => '$(SRCROOT)/Down/Source/cmark/**' }
spec.ios.resource = 'Resources/DownView.bundle'
spec.osx.resource = 'Resources/DownView.bundle'
spec.preserve_paths = "Sources/cmark/include/module.modulemap", "Sources/cmark/*.inc", "Sources/cmark/COPYING"
spec.pod_target_xcconfig = { 'SWIFT_INCLUDE_PATHS' => '$(SRCROOT)/Down/Sources/cmark/**' }
spec.ios.resource = 'Sources/Down/Resources/DownView.bundle'
spec.osx.resource = 'Sources/Down/Resources/DownView.bundle'
spec.swift_versions = ['5.0', '5.1']
end
+66 -36
View File
@@ -77,7 +77,6 @@
EE48C7DB22EC946F004815ED /* ColorCollection.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE48C7DA22EC946F004815ED /* ColorCollection.swift */; };
EE4F77C322FF3F170026A983 /* DownStylerConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE4F77C222FF3F170026A983 /* DownStylerConfiguration.swift */; };
EE5F2BA42262564A00B7C0F3 /* Styler.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE5F2BA32262564A00B7C0F3 /* Styler.swift */; };
EE641A9125E29D4B0025879A /* SnapshotTesting in Frameworks */ = {isa = PBXBuildFile; productRef = EE641A9025E29D4B0025879A /* SnapshotTesting */; };
EE8F38CC22BFB2420056270E /* NodeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE8F38CB22BFB2420056270E /* NodeTests.swift */; };
EE8F38CE22BFEDE50056270E /* ListItemPrefixGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE8F38CD22BFEDE50056270E /* ListItemPrefixGenerator.swift */; };
EE97253E22C130D8004D3B3A /* NSMutableAttributedString+AttributesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE97253D22C130D8004D3B3A /* NSMutableAttributedString+AttributesTests.swift */; };
@@ -98,6 +97,9 @@
EEBA154D234484BF00B54ECB /* ListItemStyleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE335C4922EDC85900648842 /* ListItemStyleTests.swift */; };
EEBA154E234484BF00B54ECB /* StylerTestSuite.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE59C30122ECF0BD006EE8A8 /* StylerTestSuite.swift */; };
EEBA154F234484C300B54ECB /* VisitorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE64FEEF225BEB3900A35B34 /* VisitorTests.swift */; };
EEBE62F025E28F3D005CCAD6 /* BundleHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEBE62EF25E28F3D005CCAD6 /* BundleHelper.swift */; };
EED7FED725E303000033E33A /* SnapshotTesting in Frameworks */ = {isa = PBXBuildFile; productRef = EED7FED625E303000033E33A /* SnapshotTesting */; };
EED7FED825E3133C0033E33A /* DownView (macOS).bundle in Resources */ = {isa = PBXBuildFile; fileRef = 14C5E33621877FCD00D5380C /* DownView (macOS).bundle */; };
EED8DA8E22BE404F00E54492 /* DownStyler.swift in Sources */ = {isa = PBXBuildFile; fileRef = EED8DA8D22BE404F00E54492 /* DownStyler.swift */; };
EED8DA9022BECBAE00E54492 /* NSAttributedString+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = EED8DA8F22BECBAE00E54492 /* NSAttributedString+Helpers.swift */; };
EED8DA9222BECBF200E54492 /* NSMutableAttributedString+Attributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = EED8DA9122BECBF200E54492 /* NSMutableAttributedString+Attributes.swift */; };
@@ -299,6 +301,7 @@
EEBA153A2344845500B54ECB /* DownSnapshotTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DownSnapshotTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
EEBA153C2344845500B54ECB /* DownSnapshotTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DownSnapshotTests.swift; sourceTree = "<group>"; };
EEBA153E2344845500B54ECB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
EEBE62EF25E28F3D005CCAD6 /* BundleHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BundleHelper.swift; sourceTree = "<group>"; };
EED8DA8D22BE404F00E54492 /* DownStyler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DownStyler.swift; sourceTree = "<group>"; };
EED8DA8F22BECBAE00E54492 /* NSAttributedString+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSAttributedString+Helpers.swift"; sourceTree = "<group>"; };
EED8DA9122BECBF200E54492 /* NSMutableAttributedString+Attributes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSMutableAttributedString+Attributes.swift"; sourceTree = "<group>"; };
@@ -349,7 +352,7 @@
buildActionMask = 2147483647;
files = (
EEBA15422344849600B54ECB /* Down.framework in Frameworks */,
EE641A9125E29D4B0025879A /* SnapshotTesting in Frameworks */,
EED7FED725E303000033E33A /* SnapshotTesting in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -382,23 +385,21 @@
path = Configurations;
sourceTree = "<group>";
};
D41689B41CFFE6BB00E5802B /* Resources */ = {
D41689B41CFFE6BB00E5802B /* Supporting Files */ = {
isa = PBXGroup;
children = (
90A40A971EC0309A004F2E91 /* Configurations */,
90A40A951EC02FF6004F2E91 /* Down-Info.plist */,
90A40A961EC02FF6004F2E91 /* DownTests-Info.plist */,
D41689B51CFFE6BB00E5802B /* DownView.bundle */,
14C5E33621877FCD00D5380C /* DownView (macOS).bundle */,
);
path = Resources;
path = "Supporting Files";
sourceTree = "<group>";
};
D4201E761CFA5151008EEC6E = {
isa = PBXGroup;
children = (
D4201E9B1CFA59A5008EEC6E /* Source */,
D41689B41CFFE6BB00E5802B /* Resources */,
D4201E9B1CFA59A5008EEC6E /* Sources */,
D41689B41CFFE6BB00E5802B /* Supporting Files */,
D4201EC41CFA59A5008EEC6E /* Tests */,
EEBA153B2344845500B54ECB /* DownSnapshotTests */,
D4201E811CFA5151008EEC6E /* Products */,
@@ -418,31 +419,19 @@
name = Products;
sourceTree = "<group>";
};
D4201E9B1CFA59A5008EEC6E /* Source */ = {
D4201E9B1CFA59A5008EEC6E /* Sources */ = {
isa = PBXGroup;
children = (
D4CF88961CFF94B300F07FD1 /* Down.h */,
D4201EF01CFA59F2008EEC6E /* Down.swift */,
EEF1376D2259E4BA00D7DDE0 /* AST */,
D44875E71CFA6CF30037A624 /* Enums & Options */,
D43AE5C81CFFAE39006E1522 /* Extensions */,
D44875E21CFA6B120037A624 /* Renderers */,
D43AE5CB1CFFD068006E1522 /* Views */,
EED7D92025C6DA4300E52D18 /* Down */,
D4201EF61CFA5D63008EEC6E /* cmark */,
);
path = Source;
path = Sources;
sourceTree = "<group>";
};
D4201EC41CFA59A5008EEC6E /* Tests */ = {
isa = PBXGroup;
children = (
EE59C30022ECF08E006EE8A8 /* Styler */,
907C64611EC120530095FEE1 /* Fixtures */,
D4201EC51CFA59A5008EEC6E /* BindingTests.swift */,
D41689B21CFFE28200E5802B /* DownViewTests.swift */,
D4F948DB1D00A4A800C9C0F6 /* NSAttributedStringTests.swift */,
D438696B1D00D27700E95A1F /* StringTests.swift */,
EEC752BE22C4AE1300EC729C /* AST */,
EED7D92725C6DB9100E52D18 /* DownTests */,
);
path = Tests;
sourceTree = "<group>";
@@ -503,6 +492,7 @@
isa = PBXGroup;
children = (
D43AE5D91CFFD0D0006E1522 /* DownView.swift */,
EEBE62EF25E28F3D005CCAD6 /* BundleHelper.swift */,
);
path = Views;
sourceTree = "<group>";
@@ -661,6 +651,44 @@
path = AST;
sourceTree = "<group>";
};
EED7D92025C6DA4300E52D18 /* Down */ = {
isa = PBXGroup;
children = (
EED7D94425C6DF2D00E52D18 /* Resources */,
D4CF88961CFF94B300F07FD1 /* Down.h */,
D4201EF01CFA59F2008EEC6E /* Down.swift */,
EEF1376D2259E4BA00D7DDE0 /* AST */,
D44875E71CFA6CF30037A624 /* Enums & Options */,
D43AE5C81CFFAE39006E1522 /* Extensions */,
D44875E21CFA6B120037A624 /* Renderers */,
D43AE5CB1CFFD068006E1522 /* Views */,
);
path = Down;
sourceTree = "<group>";
};
EED7D92725C6DB9100E52D18 /* DownTests */ = {
isa = PBXGroup;
children = (
EE59C30022ECF08E006EE8A8 /* Styler */,
907C64611EC120530095FEE1 /* Fixtures */,
D4201EC51CFA59A5008EEC6E /* BindingTests.swift */,
D41689B21CFFE28200E5802B /* DownViewTests.swift */,
D4F948DB1D00A4A800C9C0F6 /* NSAttributedStringTests.swift */,
D438696B1D00D27700E95A1F /* StringTests.swift */,
EEC752BE22C4AE1300EC729C /* AST */,
);
path = DownTests;
sourceTree = "<group>";
};
EED7D94425C6DF2D00E52D18 /* Resources */ = {
isa = PBXGroup;
children = (
D41689B51CFFE6BB00E5802B /* DownView.bundle */,
14C5E33621877FCD00D5380C /* DownView (macOS).bundle */,
);
path = Resources;
sourceTree = "<group>";
};
EED8DA9522BECCF000E54492 /* Helpers */ = {
isa = PBXGroup;
children = (
@@ -814,7 +842,7 @@
);
name = DownSnapshotTests;
packageProductDependencies = (
EE641A9025E29D4B0025879A /* SnapshotTesting */,
EED7FED625E303000033E33A /* SnapshotTesting */,
);
productName = DownSnapshotTests;
productReference = EEBA153A2344845500B54ECB /* DownSnapshotTests.xctest */;
@@ -856,7 +884,7 @@
);
mainGroup = D4201E761CFA5151008EEC6E;
packageReferences = (
EE641A8F25E29D4B0025879A /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */,
EED7FED525E303000033E33A /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */,
);
productRefGroup = D4201E811CFA5151008EEC6E /* Products */;
projectDirPath = "";
@@ -874,6 +902,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
EED7FED825E3133C0033E33A /* DownView (macOS).bundle in Resources */,
14C5E33521877CE900D5380C /* DownView.bundle in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -912,7 +941,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nRESOURCE_PATH=$SRCROOT/Resources\n\nFILENAME_IN_BUNDLE=DownView.bundle\n\nBUILD_APP_DIR=${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.framework/Resources\n\necho \"$RESOURCE_PATH\"\necho \"$BUILD_APP_DIR\"\n\nif [ \"$PLATFORM_NAME\" == \"macosx\" ]; then\n echo $BUILD_APP_DIR\n rm -r \"$BUILD_APP_DIR/$FILENAME_IN_BUNDLE/\"\n cp -R \"$RESOURCE_PATH/DownView (macOS).bundle\" \"$BUILD_APP_DIR/$FILENAME_IN_BUNDLE/\"\nfi\n";
shellScript = "# Type a script or drag a script file from your workspace to insert its path.\nRESOURCE_PATH=$SRCROOT/Sources/Down/Resources\n\nFILENAME_IN_BUNDLE=DownView.bundle\n\nBUILD_APP_DIR=${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.framework/Resources\n\necho \"$RESOURCE_PATH\"\necho \"$BUILD_APP_DIR\"\n\nif [ \"$PLATFORM_NAME\" == \"macosx\" ]; then\n echo $BUILD_APP_DIR\n rm -r \"$BUILD_APP_DIR/$FILENAME_IN_BUNDLE/\"\n cp -R \"$RESOURCE_PATH/DownView (macOS).bundle\" \"$BUILD_APP_DIR/$FILENAME_IN_BUNDLE/\"\nfi\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
@@ -941,6 +970,7 @@
EEF8580F22FA101C0025370B /* DownDebugLayoutManager.swift in Sources */,
8A569F6F1E6B3EDE008BE2AC /* DownAttributedStringRenderable.swift in Sources */,
EEEBEE55225D2A4E00AE438D /* Paragraph.swift in Sources */,
EEBE62F025E28F3D005CCAD6 /* BundleHelper.swift in Sources */,
8A569F721E6B3EDE008BE2AC /* DownHTMLRenderable.swift in Sources */,
EED8DA9422BECC2100E54492 /* UIFont+Traits.swift in Sources */,
EE44848B2301E51C0065C836 /* CodeBlockOptions.swift in Sources */,
@@ -1066,11 +1096,11 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = "Resources/Down-Info.plist";
INFOPLIST_FILE = "Supporting Files/Down-Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_INCLUDE_PATHS = "${SRCROOT}/Source/cmark";
SWIFT_INCLUDE_PATHS = "${SRCROOT}/Sources/cmark";
"VALID_ARCHS[sdk=iphonesimulator*]" = "i386 x86_64 arm64";
};
name = Debug;
@@ -1088,11 +1118,11 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = "Resources/Down-Info.plist";
INFOPLIST_FILE = "Supporting Files/Down-Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_INCLUDE_PATHS = "${SRCROOT}/Source/cmark";
SWIFT_INCLUDE_PATHS = "${SRCROOT}/Sources/cmark";
"VALID_ARCHS[sdk=iphonesimulator*]" = "i386 x86_64 arm64";
};
name = Release;
@@ -1106,7 +1136,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
);
INFOPLIST_FILE = "Resources/DownTests-Info.plist";
INFOPLIST_FILE = "Supporting Files/DownTests-Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = com.downMarkdown.DownTests;
"TARGETED_DEVICE_FAMILY[sdk=appletvos*]" = 3;
"TARGETED_DEVICE_FAMILY[sdk=appletvsimulator*]" = 3;
@@ -1122,7 +1152,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
);
INFOPLIST_FILE = "Resources/DownTests-Info.plist";
INFOPLIST_FILE = "Supporting Files/DownTests-Info.plist";
PRODUCT_BUNDLE_IDENTIFIER = com.downMarkdown.DownTests;
"TARGETED_DEVICE_FAMILY[sdk=appletvos*]" = 3;
"TARGETED_DEVICE_FAMILY[sdk=appletvsimulator*]" = 3;
@@ -1351,7 +1381,7 @@
/* End XCConfigurationList section */
/* Begin XCRemoteSwiftPackageReference section */
EE641A8F25E29D4B0025879A /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */ = {
EED7FED525E303000033E33A /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/pointfreeco/swift-snapshot-testing.git";
requirement = {
@@ -1362,9 +1392,9 @@
/* End XCRemoteSwiftPackageReference section */
/* Begin XCSwiftPackageProductDependency section */
EE641A9025E29D4B0025879A /* SnapshotTesting */ = {
EED7FED625E303000033E33A /* SnapshotTesting */ = {
isa = XCSwiftPackageProductDependency;
package = EE641A8F25E29D4B0025879A /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */;
package = EED7FED525E303000033E33A /* XCRemoteSwiftPackageReference "swift-snapshot-testing" */;
productName = SnapshotTesting;
};
/* End XCSwiftPackageProductDependency section */
+17 -6
View File
@@ -1,4 +1,4 @@
// swift-tools-version:5.1
// swift-tools-version:5.3
import PackageDescription
@@ -19,24 +19,35 @@ let package = Package(
.target(
name: "libcmark",
dependencies: [],
path: "Source/cmark",
exclude: ["include"],
path: "Sources/cmark",
exclude: [
"include",
"case_fold_switch.inc",
"entities.inc",
"COPYING"
],
publicHeadersPath: "./"
),
.target(
name: "Down",
dependencies: ["libcmark"],
path: "Source/",
exclude: ["cmark", "Down.h"]
path: "Sources/Down",
exclude: ["Down.h"],
resources: [
.copy("Resources/DownView.bundle"),
.copy("Resources/DownView (macOS).bundle"),
]
),
.testTarget(
name: "DownTests",
dependencies: ["Down"],
path: "Tests/",
path: "Tests/DownTests",
exclude: [
"AST/VisitorTests.swift",
"AST/__Snapshots__",
"DownViewTests.swift",
"Fixtures",
"Styler/__Snapshots__",
"Styler/BlockQuoteStyleTests.swift",
"Styler/CodeBlockStyleTests.swift",
"Styler/DownDebugLayoutManagerTests.swift",
+34
View File
@@ -0,0 +1,34 @@
import class Foundation.Bundle
// This helps us find the bundle when imported through the Swift Package Manager.
private class BundleFinder {}
extension Foundation.Bundle {
/// Returns the resource bundle associated with the current Swift module.
static var moduleBundle: Bundle? = {
let bundleName = "Down_Down"
let candidates = [
// Bundle should be present here when the package is linked into an App.
Bundle.main.resourceURL,
// Bundle should be present here when the package is linked into a framework.
Bundle(for: BundleFinder.self).resourceURL,
// For command-line tools.
Bundle.main.bundleURL,
]
for candidate in candidates {
let bundlePath = candidate?.appendingPathComponent(bundleName + ".bundle")
if let bundle = bundlePath.flatMap(Bundle.init(url:)) {
return bundle
}
}
return nil
}()
}
@@ -38,8 +38,8 @@ open class DownView: WKWebView {
if let templateBundle = templateBundle {
self.bundle = templateBundle
} else {
let classBundle = Bundle(for: DownView.self)
let url = classBundle.url(forResource: "DownView", withExtension: "bundle")!
let moduleBundle = Bundle.moduleBundle ?? Bundle(for: DownView.self)
let url = moduleBundle.url(forResource: "DownView", withExtension: "bundle")!
self.bundle = Bundle(url: url)!
}

Some files were not shown because too many files have changed in this diff Show More