From c123ebcada58fefc0069cd462c698638c8314055 Mon Sep 17 00:00:00 2001 From: Dariusz Rybicki <dariusz@elixxir.io> Date: Wed, 1 Jun 2022 12:54:26 +0200 Subject: [PATCH] Add Swift Package for example app --- Example/Example.xcodeproj/project.pbxproj | 20 ++--- Example/ExampleApp/.gitignore | 9 +++ .../xcschemes/AppFeature.xcscheme | 78 +++++++++++++++++++ Example/ExampleApp/Package.swift | 36 +++++++++ .../Sources/AppFeature}/App.swift | 2 +- .../Sources/AppFeature/AppView.swift} | 8 +- .../AppFeatureTests/AppFeatureTests.swift | 8 ++ 7 files changed, 143 insertions(+), 18 deletions(-) create mode 100644 Example/ExampleApp/.gitignore create mode 100644 Example/ExampleApp/.swiftpm/xcode/xcshareddata/xcschemes/AppFeature.xcscheme create mode 100644 Example/ExampleApp/Package.swift rename Example/{ExampleApp (iOS) => ExampleApp/Sources/AppFeature}/App.swift (83%) rename Example/{ExampleApp (iOS)/ContentView.swift => ExampleApp/Sources/AppFeature/AppView.swift} (50%) create mode 100644 Example/ExampleApp/Tests/AppFeatureTests/AppFeatureTests.swift diff --git a/Example/Example.xcodeproj/project.pbxproj b/Example/Example.xcodeproj/project.pbxproj index 804dacad..eea192d9 100644 --- a/Example/Example.xcodeproj/project.pbxproj +++ b/Example/Example.xcodeproj/project.pbxproj @@ -7,18 +7,15 @@ objects = { /* Begin PBXBuildFile section */ - 312C371A28475E62003E9E39 /* App.swift in Sources */ = {isa = PBXBuildFile; fileRef = 312C371928475E62003E9E39 /* App.swift */; }; - 312C371C28475E62003E9E39 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 312C371B28475E62003E9E39 /* ContentView.swift */; }; 312C371E28475E63003E9E39 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 312C371D28475E63003E9E39 /* Assets.xcassets */; }; - 312C372C28476503003E9E39 /* ElixxirDAppsSDK in Frameworks */ = {isa = PBXBuildFile; productRef = 312C372B28476503003E9E39 /* ElixxirDAppsSDK */; }; + 316D95EE28477B0E008475F9 /* AppFeature in Frameworks */ = {isa = PBXBuildFile; productRef = 316D95ED28477B0E008475F9 /* AppFeature */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ 312C371628475E62003E9E39 /* dApps Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "dApps Example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; - 312C371928475E62003E9E39 /* App.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = App.swift; sourceTree = "<group>"; }; - 312C371B28475E62003E9E39 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; }; 312C371D28475E63003E9E39 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 312C3728284761DC003E9E39 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; + 316D95EB28477ACA008475F9 /* ExampleApp */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = ExampleApp; sourceTree = "<group>"; }; 31B3342F2847669900865D82 /* ExampleAppIcon */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = ExampleAppIcon; sourceTree = "<group>"; }; /* End PBXFileReference section */ @@ -27,7 +24,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 312C372C28476503003E9E39 /* ElixxirDAppsSDK in Frameworks */, + 316D95EE28477B0E008475F9 /* AppFeature in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -38,6 +35,7 @@ isa = PBXGroup; children = ( 312C3727284761C7003E9E39 /* ExampleApp (iOS) */, + 316D95EB28477ACA008475F9 /* ExampleApp */, 31B3342F2847669900865D82 /* ExampleAppIcon */, 312C371728475E62003E9E39 /* Products */, ); @@ -54,8 +52,6 @@ 312C3727284761C7003E9E39 /* ExampleApp (iOS) */ = { isa = PBXGroup; children = ( - 312C371928475E62003E9E39 /* App.swift */, - 312C371B28475E62003E9E39 /* ContentView.swift */, 312C371D28475E63003E9E39 /* Assets.xcassets */, 312C3728284761DC003E9E39 /* Info.plist */, ); @@ -79,7 +75,7 @@ ); name = "ExampleApp (iOS)"; packageProductDependencies = ( - 312C372B28476503003E9E39 /* ElixxirDAppsSDK */, + 316D95ED28477B0E008475F9 /* AppFeature */, ); productName = ExampleApp; productReference = 312C371628475E62003E9E39 /* dApps Example.app */; @@ -134,8 +130,6 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 312C371C28475E62003E9E39 /* ContentView.swift in Sources */, - 312C371A28475E62003E9E39 /* App.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -340,9 +334,9 @@ /* End XCConfigurationList section */ /* Begin XCSwiftPackageProductDependency section */ - 312C372B28476503003E9E39 /* ElixxirDAppsSDK */ = { + 316D95ED28477B0E008475F9 /* AppFeature */ = { isa = XCSwiftPackageProductDependency; - productName = ElixxirDAppsSDK; + productName = AppFeature; }; /* End XCSwiftPackageProductDependency section */ }; diff --git a/Example/ExampleApp/.gitignore b/Example/ExampleApp/.gitignore new file mode 100644 index 00000000..3b298120 --- /dev/null +++ b/Example/ExampleApp/.gitignore @@ -0,0 +1,9 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj +xcuserdata/ +DerivedData/ +.swiftpm/config/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc diff --git a/Example/ExampleApp/.swiftpm/xcode/xcshareddata/xcschemes/AppFeature.xcscheme b/Example/ExampleApp/.swiftpm/xcode/xcshareddata/xcschemes/AppFeature.xcscheme new file mode 100644 index 00000000..076cfa82 --- /dev/null +++ b/Example/ExampleApp/.swiftpm/xcode/xcshareddata/xcschemes/AppFeature.xcscheme @@ -0,0 +1,78 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Scheme + LastUpgradeVersion = "1340" + version = "1.3"> + <BuildAction + parallelizeBuildables = "YES" + buildImplicitDependencies = "YES"> + <BuildActionEntries> + <BuildActionEntry + buildForTesting = "YES" + buildForRunning = "YES" + buildForProfiling = "YES" + buildForArchiving = "YES" + buildForAnalyzing = "YES"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "AppFeature" + BuildableName = "AppFeature" + BlueprintName = "AppFeature" + ReferencedContainer = "container:"> + </BuildableReference> + </BuildActionEntry> + </BuildActionEntries> + </BuildAction> + <TestAction + buildConfiguration = "Debug" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + shouldUseLaunchSchemeArgsEnv = "YES" + codeCoverageEnabled = "YES"> + <Testables> + <TestableReference + skipped = "NO"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "AppFeatureTests" + BuildableName = "AppFeatureTests" + BlueprintName = "AppFeatureTests" + ReferencedContainer = "container:"> + </BuildableReference> + </TestableReference> + </Testables> + </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 = "AppFeature" + BuildableName = "AppFeature" + BlueprintName = "AppFeature" + ReferencedContainer = "container:"> + </BuildableReference> + </MacroExpansion> + </ProfileAction> + <AnalyzeAction + buildConfiguration = "Debug"> + </AnalyzeAction> + <ArchiveAction + buildConfiguration = "Release" + revealArchiveInOrganizer = "YES"> + </ArchiveAction> +</Scheme> diff --git a/Example/ExampleApp/Package.swift b/Example/ExampleApp/Package.swift new file mode 100644 index 00000000..ecfd6b23 --- /dev/null +++ b/Example/ExampleApp/Package.swift @@ -0,0 +1,36 @@ +// swift-tools-version: 5.6 + +import PackageDescription + +let package = Package( + name: "ExampleApp", + platforms: [ + .iOS(.v15), + ], + products: [ + .library( + name: "AppFeature", + targets: ["AppFeature"] + ), + ], + dependencies: [ + .package(path: "../../"), // elixxir-dapps-sdk-swift + ], + targets: [ + .target( + name: "AppFeature", + dependencies: [ + .product( + name: "ElixxirDAppsSDK", + package: "elixxir-dapps-sdk-swift" + ), + ] + ), + .testTarget( + name: "AppFeatureTests", + dependencies: [ + .target(name: "AppFeature"), + ] + ), + ] +) diff --git a/Example/ExampleApp (iOS)/App.swift b/Example/ExampleApp/Sources/AppFeature/App.swift similarity index 83% rename from Example/ExampleApp (iOS)/App.swift rename to Example/ExampleApp/Sources/AppFeature/App.swift index 5b1dbc21..47af3dbc 100644 --- a/Example/ExampleApp (iOS)/App.swift +++ b/Example/ExampleApp/Sources/AppFeature/App.swift @@ -4,7 +4,7 @@ import SwiftUI struct App: SwiftUI.App { var body: some Scene { WindowGroup { - ContentView() + AppView() } } } diff --git a/Example/ExampleApp (iOS)/ContentView.swift b/Example/ExampleApp/Sources/AppFeature/AppView.swift similarity index 50% rename from Example/ExampleApp (iOS)/ContentView.swift rename to Example/ExampleApp/Sources/AppFeature/AppView.swift index 8660747e..ac856328 100644 --- a/Example/ExampleApp (iOS)/ContentView.swift +++ b/Example/ExampleApp/Sources/AppFeature/AppView.swift @@ -1,16 +1,16 @@ import SwiftUI -struct ContentView: View { +struct AppView: View { var body: some View { - Text("Hello, world!") + Text("AppView") .padding() } } #if DEBUG -struct ContentView_Previews: PreviewProvider { +struct AppView_Previews: PreviewProvider { static var previews: some View { - ContentView() + AppView() } } #endif diff --git a/Example/ExampleApp/Tests/AppFeatureTests/AppFeatureTests.swift b/Example/ExampleApp/Tests/AppFeatureTests/AppFeatureTests.swift new file mode 100644 index 00000000..23825304 --- /dev/null +++ b/Example/ExampleApp/Tests/AppFeatureTests/AppFeatureTests.swift @@ -0,0 +1,8 @@ +import XCTest +@testable import AppFeature + +final class AppFeatureTests: XCTestCase { + func testExample() throws { + XCTAssert(true) + } +} -- GitLab