From e8474478b0a1bc50730dbdd8509bfc73d75250fb Mon Sep 17 00:00:00 2001 From: Thomas Vidas Date: Thu, 22 Jul 2021 11:52:57 -0400 Subject: [PATCH 1/4] feat(ios): Add PortalManager class, stub out Portal and PortalBuilder files --- .../IonicPortals.xcodeproj/project.pbxproj | 8 +++ ios/IonicPortals/IonicPortals/Portal.swift | 7 ++ .../IonicPortals/PortalBuilder.swift | 26 +++++++ .../IonicPortals/PortalManager.swift | 68 +++++++++++++++++++ 4 files changed, 109 insertions(+) create mode 100644 ios/IonicPortals/IonicPortals/PortalBuilder.swift create mode 100644 ios/IonicPortals/IonicPortals/PortalManager.swift diff --git a/ios/IonicPortals/IonicPortals.xcodeproj/project.pbxproj b/ios/IonicPortals/IonicPortals.xcodeproj/project.pbxproj index 4c30827b..2561bcef 100644 --- a/ios/IonicPortals/IonicPortals.xcodeproj/project.pbxproj +++ b/ios/IonicPortals/IonicPortals.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + E90B7D4C26A9C4F40067D73E /* PortalBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = E90B7D4B26A9C4F40067D73E /* PortalBuilder.swift */; }; + E90B7D5026A9CB880067D73E /* PortalManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = E90B7D4F26A9CB880067D73E /* PortalManager.swift */; }; E985F88A269E2D260031F820 /* IonicPortals.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E985F880269E2D260031F820 /* IonicPortals.framework */; }; E985F88F269E2D260031F820 /* IonicPortalsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E985F88E269E2D260031F820 /* IonicPortalsTests.swift */; }; E985F891269E2D260031F820 /* IonicPortals.h in Headers */ = {isa = PBXBuildFile; fileRef = E985F883269E2D260031F820 /* IonicPortals.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -24,6 +26,8 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + E90B7D4B26A9C4F40067D73E /* PortalBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = PortalBuilder.swift; path = IonicPortals/PortalBuilder.swift; sourceTree = ""; }; + E90B7D4F26A9CB880067D73E /* PortalManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PortalManager.swift; path = IonicPortals/PortalManager.swift; sourceTree = ""; }; E985F880269E2D260031F820 /* IonicPortals.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = IonicPortals.framework; sourceTree = BUILT_PRODUCTS_DIR; }; E985F883269E2D260031F820 /* IonicPortals.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IonicPortals.h; sourceTree = ""; }; E985F884269E2D260031F820 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -55,6 +59,8 @@ E985F876269E2D260031F820 = { isa = PBXGroup; children = ( + E90B7D4F26A9CB880067D73E /* PortalManager.swift */, + E90B7D4B26A9C4F40067D73E /* PortalBuilder.swift */, E985F89E269E2D830031F820 /* Portal.swift */, E985F882269E2D260031F820 /* IonicPortals */, E985F88D269E2D260031F820 /* IonicPortalsTests */, @@ -198,6 +204,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + E90B7D4C26A9C4F40067D73E /* PortalBuilder.swift in Sources */, + E90B7D5026A9CB880067D73E /* PortalManager.swift in Sources */, E985F89F269E2D830031F820 /* Portal.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/ios/IonicPortals/IonicPortals/Portal.swift b/ios/IonicPortals/IonicPortals/Portal.swift index 1dd756bf..bae79d8c 100644 --- a/ios/IonicPortals/IonicPortals/Portal.swift +++ b/ios/IonicPortals/IonicPortals/Portal.swift @@ -8,8 +8,15 @@ import Foundation public class Portal { + + + // MARK: - Instance Properties + + public let name: String; + public init() { print("Constructor") + name = ""; } public func HelloWorld() { diff --git a/ios/IonicPortals/IonicPortals/PortalBuilder.swift b/ios/IonicPortals/IonicPortals/PortalBuilder.swift new file mode 100644 index 00000000..b0b1c12b --- /dev/null +++ b/ios/IonicPortals/IonicPortals/PortalBuilder.swift @@ -0,0 +1,26 @@ +// +// PortalManager.swift +// IonicPortals +// +// Created by Thomas Vidas on 7/22/21. +// + +import Foundation + +typealias OnPortalBuilderComplete = (_ portal : Portal) -> Void + +class PortalBuilder { + + // MARK: - Static Properties + + + // MARK: - Instance Properties + + + // Initialization + + public init(_ name: String, _ onComplete: OnPortalBuilderComplete) { + + } + +} diff --git a/ios/IonicPortals/IonicPortals/PortalManager.swift b/ios/IonicPortals/IonicPortals/PortalManager.swift new file mode 100644 index 00000000..29ad2011 --- /dev/null +++ b/ios/IonicPortals/IonicPortals/PortalManager.swift @@ -0,0 +1,68 @@ +// +// PortalManager.swift +// IonicPortals +// +// Created by Thomas Vidas on 7/22/21. +// + +import Foundation + +enum PortalError: Error { + case notFound(String) + case alreadyExists(String) +} + +class PortalManager { + + // MARK: - Static Properties + + static let shared = PortalManager() + + // MARK: - Instance Properties + + private var portals = Dictionary() + + // Initialization + + private init() {} + + /** + * Returns the number of `Portal` objects in the `PortalManager`. + * - returns: The count of `Portal` objects. + */ + public func count() -> Int { + return portals.count + } + + /** + * Adds a `Portal` object given the `name` of the portal. + * - Parameter portal: The `Portal` to add to the manager. + */ + public func addPortal(_ portal: Portal) -> Void { + portals[portal.name] = portal + } + + /** + * Returns a `Portal` object given the name of the portal + * - Parameter name: The Portal name + * - throws: `PortalError.notFound` if the `Portal` does not exist + * - returns: The existing `Portal` class with name `name`. + */ + public func getPortal(_ name: String) throws -> Portal { + guard let output = portals[name] else { + throw PortalError.notFound("Portal with portalId \(name) not found in PortalManager") + } + return output + } + + /** + * A helper method to build `Portal` classes and add them to the manager. Classes built with newPortal are added to the `PortalManager` automatically. + * - Parameter name: The `Portal` name + * - returns: A `PortalBuilder` object that has a fluent API to construct a `Portal`. + */ + public func newPortal(_ name: String) -> PortalBuilder { + return PortalBuilder(name, { (portal) in + PortalManager.shared.addPortal(portal) + }) + } +} From 52a409048e2d4860e5afe692b711326eff8397f2 Mon Sep 17 00:00:00 2001 From: Thomas Vidas Date: Fri, 23 Jul 2021 11:51:42 -0400 Subject: [PATCH 2/4] fix(iOS): Add podspec and podfile to project --- .gitignore | 4 +- .../contents.xcworkspacedata | 3 + ios/IonicPortals/IonicPortals.podspec | 14 ++++ .../IonicPortals.xcodeproj/project.pbxproj | 53 +++++++++++++++ ios/IonicPortals/IonicPortals/Portal.swift | 1 + ios/Podfile | 27 ++++++++ ios/Podfile.lock | 21 ++++++ .../PortalsTestApp.xcodeproj/project.pbxproj | 65 ++++++++++++++++++- 8 files changed, 184 insertions(+), 4 deletions(-) create mode 100644 ios/IonicPortals/IonicPortals.podspec create mode 100644 ios/Podfile create mode 100644 ios/Podfile.lock diff --git a/.gitignore b/.gitignore index 6c5ecff0..26d64551 100644 --- a/.gitignore +++ b/.gitignore @@ -153,7 +153,7 @@ playground.xcworkspace # you should judge for yourself, the pros and cons are mentioned at: # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control # -# Pods/ +Pods/ # # Add this line if you want to avoid checking in source code from the Xcode workspace # *.xcworkspace @@ -192,4 +192,4 @@ iOSInjectionProject/ # Plugin ignore # ========== plugin/node_modules -plugin/dist \ No newline at end of file +plugin/dist diff --git a/ios/IonicPortals.xcworkspace/contents.xcworkspacedata b/ios/IonicPortals.xcworkspace/contents.xcworkspacedata index d9e18947..e2d01ceb 100644 --- a/ios/IonicPortals.xcworkspace/contents.xcworkspacedata +++ b/ios/IonicPortals.xcworkspace/contents.xcworkspacedata @@ -7,4 +7,7 @@ + + diff --git a/ios/IonicPortals/IonicPortals.podspec b/ios/IonicPortals/IonicPortals.podspec new file mode 100644 index 00000000..98fc6f03 --- /dev/null +++ b/ios/IonicPortals/IonicPortals.podspec @@ -0,0 +1,14 @@ +require 'json' + +Pod::Spec.new do |s| + s.name = 'IonicPortals' + s.version = '0.0.1' + s.summary = 'Portals Description' + s.license = 'Portals License' + s.homepage = 'https://ionic.io/portals' + s.author = 'Ionic' + s.source_files = 'IonicPortals/**/*.{swift,h,m,c,cc,mm,cpp}' + s.ios.deployment_target = '12.0' + s.dependency 'Portals' + s.swift_version = '5.1' +end diff --git a/ios/IonicPortals/IonicPortals.xcodeproj/project.pbxproj b/ios/IonicPortals/IonicPortals.xcodeproj/project.pbxproj index 2561bcef..eebe94a7 100644 --- a/ios/IonicPortals/IonicPortals.xcodeproj/project.pbxproj +++ b/ios/IonicPortals/IonicPortals.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 3845A534A28C7E3728A0A58A /* Pods_IonicPortals.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E44A8EABC3166358F2924543 /* Pods_IonicPortals.framework */; }; E90B7D4C26A9C4F40067D73E /* PortalBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = E90B7D4B26A9C4F40067D73E /* PortalBuilder.swift */; }; E90B7D5026A9CB880067D73E /* PortalManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = E90B7D4F26A9CB880067D73E /* PortalManager.swift */; }; E985F88A269E2D260031F820 /* IonicPortals.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E985F880269E2D260031F820 /* IonicPortals.framework */; }; @@ -26,6 +27,9 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 2514A9D89B5C400A41EF8FEB /* Pods-IonicPortals.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-IonicPortals.release.xcconfig"; path = "Target Support Files/Pods-IonicPortals/Pods-IonicPortals.release.xcconfig"; sourceTree = ""; }; + 2C8BCCA3D236847121E67C22 /* Pods-IonicPortals.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-IonicPortals.debug.xcconfig"; path = "Target Support Files/Pods-IonicPortals/Pods-IonicPortals.debug.xcconfig"; sourceTree = ""; }; + E44A8EABC3166358F2924543 /* Pods_IonicPortals.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_IonicPortals.framework; sourceTree = BUILT_PRODUCTS_DIR; }; E90B7D4B26A9C4F40067D73E /* PortalBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = PortalBuilder.swift; path = IonicPortals/PortalBuilder.swift; sourceTree = ""; }; E90B7D4F26A9CB880067D73E /* PortalManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PortalManager.swift; path = IonicPortals/PortalManager.swift; sourceTree = ""; }; E985F880269E2D260031F820 /* IonicPortals.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = IonicPortals.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -42,6 +46,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 3845A534A28C7E3728A0A58A /* Pods_IonicPortals.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -56,6 +61,24 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 1F249143665D3AA4301AD1DE /* Frameworks */ = { + isa = PBXGroup; + children = ( + E44A8EABC3166358F2924543 /* Pods_IonicPortals.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 9D0BB0A71D75531B34F29BDB /* Pods */ = { + isa = PBXGroup; + children = ( + 2C8BCCA3D236847121E67C22 /* Pods-IonicPortals.debug.xcconfig */, + 2514A9D89B5C400A41EF8FEB /* Pods-IonicPortals.release.xcconfig */, + ); + name = Pods; + path = ../Pods; + sourceTree = ""; + }; E985F876269E2D260031F820 = { isa = PBXGroup; children = ( @@ -65,6 +88,8 @@ E985F882269E2D260031F820 /* IonicPortals */, E985F88D269E2D260031F820 /* IonicPortalsTests */, E985F881269E2D260031F820 /* Products */, + 9D0BB0A71D75531B34F29BDB /* Pods */, + 1F249143665D3AA4301AD1DE /* Frameworks */, ); sourceTree = ""; }; @@ -113,6 +138,7 @@ isa = PBXNativeTarget; buildConfigurationList = E985F894269E2D260031F820 /* Build configuration list for PBXNativeTarget "IonicPortals" */; buildPhases = ( + 6F34B2740496582483E29D5A /* [CP] Check Pods Manifest.lock */, E985F87B269E2D260031F820 /* Headers */, E985F87C269E2D260031F820 /* Sources */, E985F87D269E2D260031F820 /* Frameworks */, @@ -199,6 +225,31 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 6F34B2740496582483E29D5A /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-IonicPortals-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ E985F87C269E2D260031F820 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -353,6 +404,7 @@ }; E985F895269E2D260031F820 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 2C8BCCA3D236847121E67C22 /* Pods-IonicPortals.debug.xcconfig */; buildSettings = { CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; @@ -380,6 +432,7 @@ }; E985F896269E2D260031F820 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 2514A9D89B5C400A41EF8FEB /* Pods-IonicPortals.release.xcconfig */; buildSettings = { CLANG_ENABLE_MODULES = YES; CODE_SIGN_STYLE = Automatic; diff --git a/ios/IonicPortals/IonicPortals/Portal.swift b/ios/IonicPortals/IonicPortals/Portal.swift index bae79d8c..414e008b 100644 --- a/ios/IonicPortals/IonicPortals/Portal.swift +++ b/ios/IonicPortals/IonicPortals/Portal.swift @@ -6,6 +6,7 @@ // import Foundation +import Capacitor public class Portal { diff --git a/ios/Podfile b/ios/Podfile new file mode 100644 index 00000000..e3733cb2 --- /dev/null +++ b/ios/Podfile @@ -0,0 +1,27 @@ +source 'https://github.com/native-portal/podspecs.git' + +platform :ios, '12.0' +workspace 'IonicPortals' + +def testapp_pods + # none +end + +def capacitor_pods + # Comment the next line if you're not using Swift and don't want to use dynamic frameworks + use_frameworks! + podspec :path => './IonicPortals/IonicPortals.podspec' + pod 'Portals' + pod 'CapacitorCordova' +end + +target 'IonicPortals' do + project './IonicPortals/IonicPortals.xcodeproj' + capacitor_pods +end + +target 'PortalsTestApp (iOS)' do + project './PortalsTestApp/PortalsTestApp.xcodeproj' + capacitor_pods + testapp_pods +end diff --git a/ios/Podfile.lock b/ios/Podfile.lock new file mode 100644 index 00000000..9c7f468e --- /dev/null +++ b/ios/Podfile.lock @@ -0,0 +1,21 @@ +PODS: + - CapacitorCordova (3.0.1) + - Portals (3.0.1): + - CapacitorCordova (= 3.0.1) + +DEPENDENCIES: + - CapacitorCordova + - Portals + +SPEC REPOS: + https://github.com/native-portal/podspecs.git: + - CapacitorCordova + - Portals + +SPEC CHECKSUMS: + CapacitorCordova: 19b9a7bfa2e24a18281258c269390a7b38cb2eaf + Portals: 30c3554216671a1e092c24f0215045b1426185d4 + +PODFILE CHECKSUM: a2102afa5b92a3d22f1e7af35386d31e5c3c334e + +COCOAPODS: 1.10.0 diff --git a/ios/PortalsTestApp/PortalsTestApp.xcodeproj/project.pbxproj b/ios/PortalsTestApp/PortalsTestApp.xcodeproj/project.pbxproj index 0902eaa2..88286b69 100644 --- a/ios/PortalsTestApp/PortalsTestApp.xcodeproj/project.pbxproj +++ b/ios/PortalsTestApp/PortalsTestApp.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + BC5925F02FA8099E098526D4 /* Pods_PortalsTestApp__iOS_.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DB808F557ADC62A7FAD03BE3 /* Pods_PortalsTestApp__iOS_.framework */; }; E985F816269E259D0031F820 /* PortalsTestAppApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = E985F803269E259C0031F820 /* PortalsTestAppApp.swift */; }; E985F817269E259D0031F820 /* PortalsTestAppApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = E985F803269E259C0031F820 /* PortalsTestAppApp.swift */; }; E985F818269E259D0031F820 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E985F804269E259C0031F820 /* ContentView.swift */; }; @@ -32,6 +33,9 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 09680184EB42C0DC6C11256E /* Pods-PortalsTestApp (iOS).debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PortalsTestApp (iOS).debug.xcconfig"; path = "Target Support Files/Pods-PortalsTestApp (iOS)/Pods-PortalsTestApp (iOS).debug.xcconfig"; sourceTree = ""; }; + 0E99D95CF46AC2C97E26C361 /* Pods-PortalsTestApp (iOS).release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PortalsTestApp (iOS).release.xcconfig"; path = "Target Support Files/Pods-PortalsTestApp (iOS)/Pods-PortalsTestApp (iOS).release.xcconfig"; sourceTree = ""; }; + DB808F557ADC62A7FAD03BE3 /* Pods_PortalsTestApp__iOS_.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_PortalsTestApp__iOS_.framework; sourceTree = BUILT_PRODUCTS_DIR; }; E985F803269E259C0031F820 /* PortalsTestAppApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PortalsTestAppApp.swift; sourceTree = ""; }; E985F804269E259C0031F820 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; E985F805269E259D0031F820 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; @@ -49,6 +53,7 @@ buildActionMask = 2147483647; files = ( E985F89B269E2D550031F820 /* IonicPortals.framework in Frameworks */, + BC5925F02FA8099E098526D4 /* Pods_PortalsTestApp__iOS_.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -62,6 +67,16 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 7CC64A1A195DD76703AF9D8C /* Pods */ = { + isa = PBXGroup; + children = ( + 09680184EB42C0DC6C11256E /* Pods-PortalsTestApp (iOS).debug.xcconfig */, + 0E99D95CF46AC2C97E26C361 /* Pods-PortalsTestApp (iOS).release.xcconfig */, + ); + name = Pods; + path = ../Pods; + sourceTree = ""; + }; E985F7FD269E259C0031F820 = { isa = PBXGroup; children = ( @@ -70,6 +85,7 @@ E985F813269E259D0031F820 /* macOS */, E985F80B269E259D0031F820 /* Products */, E985F824269E25E60031F820 /* Frameworks */, + 7CC64A1A195DD76703AF9D8C /* Pods */, ); sourceTree = ""; }; @@ -113,6 +129,7 @@ isa = PBXGroup; children = ( E985F89A269E2D550031F820 /* IonicPortals.framework */, + DB808F557ADC62A7FAD03BE3 /* Pods_PortalsTestApp__iOS_.framework */, ); name = Frameworks; sourceTree = ""; @@ -124,18 +141,18 @@ isa = PBXNativeTarget; buildConfigurationList = E985F81E269E259D0031F820 /* Build configuration list for PBXNativeTarget "PortalsTestApp (iOS)" */; buildPhases = ( + 9F3B401080EA2DF2EEB9F9B2 /* [CP] Check Pods Manifest.lock */, E985F807269E259D0031F820 /* Frameworks */, E985F89D269E2D550031F820 /* Embed Frameworks */, E985F806269E259D0031F820 /* Sources */, E985F808269E259D0031F820 /* Resources */, + 91CD9E7CAA49D4EA8A6DAF79 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); dependencies = ( ); name = "PortalsTestApp (iOS)"; - packageProductDependencies = ( - ); productName = "PortalsTestApp (iOS)"; productReference = E985F80A269E259D0031F820 /* PortalsTestApp.app */; productType = "com.apple.product-type.application"; @@ -212,6 +229,48 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 91CD9E7CAA49D4EA8A6DAF79 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-PortalsTestApp (iOS)/Pods-PortalsTestApp (iOS)-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-PortalsTestApp (iOS)/Pods-PortalsTestApp (iOS)-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-PortalsTestApp (iOS)/Pods-PortalsTestApp (iOS)-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 9F3B401080EA2DF2EEB9F9B2 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-PortalsTestApp (iOS)-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ E985F806269E259D0031F820 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -347,6 +406,7 @@ }; E985F81F269E259D0031F820 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 09680184EB42C0DC6C11256E /* Pods-PortalsTestApp (iOS).debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; @@ -369,6 +429,7 @@ }; E985F820269E259D0031F820 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 0E99D95CF46AC2C97E26C361 /* Pods-PortalsTestApp (iOS).release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; From 619795f4fb27d16babe615c563ce9f5fb64df1cc Mon Sep 17 00:00:00 2001 From: Thomas Vidas Date: Fri, 23 Jul 2021 12:02:00 -0400 Subject: [PATCH 3/4] feat(iOS): PortalBuilder class --- ios/IonicPortals/IonicPortals/Portal.swift | 13 +++++-- .../IonicPortals/PortalBuilder.swift | 38 ++++++++++++++++++- .../Shared/PortalsTestAppApp.swift | 2 +- 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/ios/IonicPortals/IonicPortals/Portal.swift b/ios/IonicPortals/IonicPortals/Portal.swift index 414e008b..74387607 100644 --- a/ios/IonicPortals/IonicPortals/Portal.swift +++ b/ios/IonicPortals/IonicPortals/Portal.swift @@ -10,17 +10,22 @@ import Capacitor public class Portal { - // MARK: - Instance Properties - public let name: String; + public var plugins: [CAPPlugin] = [] + public var initialContext: Any? + public var startDir: String? - public init() { + public init(_ name: String) { print("Constructor") - name = ""; + self.name = name } public func HelloWorld() { print("Hello World") } + + public func addPlugins(_ plugins: [CAPPlugin]) { + self.plugins = plugins + } } diff --git a/ios/IonicPortals/IonicPortals/PortalBuilder.swift b/ios/IonicPortals/IonicPortals/PortalBuilder.swift index b0b1c12b..b154d2ca 100644 --- a/ios/IonicPortals/IonicPortals/PortalBuilder.swift +++ b/ios/IonicPortals/IonicPortals/PortalBuilder.swift @@ -6,6 +6,7 @@ // import Foundation +import Capacitor typealias OnPortalBuilderComplete = (_ portal : Portal) -> Void @@ -15,12 +16,45 @@ class PortalBuilder { // MARK: - Instance Properties + private let name: String + private let onBuilderComplete: OnPortalBuilderComplete + private var startDir: String? + private var plugins: [CAPPlugin] = [] + private var initialContext: Any? // Initialization + public init(_ name: String, _ onComplete: @escaping OnPortalBuilderComplete) { + self.name = name + self.onBuilderComplete = onComplete + } + + public func setStartDir(startDir: String) -> PortalBuilder { + self.startDir = startDir + return self + } + + public func addPlugin(plugin: CAPPlugin) -> PortalBuilder { + plugins.append(plugin) + return self + } + + public func setInitialContext(initialContext: Any) -> PortalBuilder { + self.initialContext = initialContext + return self + } - public init(_ name: String, _ onComplete: OnPortalBuilderComplete) { - + public func setPlugins(plugins: [CAPPlugin]) -> PortalBuilder { + self.plugins = plugins + return self } + public func create() -> Portal { + let portal = Portal(self.name) + portal.startDir = self.startDir ?? portal.name + portal.addPlugins(plugins) + portal.initialContext = self.initialContext + self.onBuilderComplete(portal) + return portal + } } diff --git a/ios/PortalsTestApp/Shared/PortalsTestAppApp.swift b/ios/PortalsTestApp/Shared/PortalsTestAppApp.swift index 1c6b57ba..76ec8b3e 100644 --- a/ios/PortalsTestApp/Shared/PortalsTestAppApp.swift +++ b/ios/PortalsTestApp/Shared/PortalsTestAppApp.swift @@ -11,7 +11,7 @@ import IonicPortals @main struct PortalsTestAppApp: App { init() { - let p = Portal(); + let p = Portal("Hello"); p.HelloWorld(); } From 93e8c1421f36bf5cb9ef9b36174f96ef4a793844 Mon Sep 17 00:00:00 2001 From: Thomas Vidas Date: Mon, 26 Jul 2021 10:07:54 -0400 Subject: [PATCH 4/4] refactor(ios): Remove plugin builder options and add appledocs on functions --- .../IonicPortals/PortalBuilder.swift | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/ios/IonicPortals/IonicPortals/PortalBuilder.swift b/ios/IonicPortals/IonicPortals/PortalBuilder.swift index b154d2ca..13eae297 100644 --- a/ios/IonicPortals/IonicPortals/PortalBuilder.swift +++ b/ios/IonicPortals/IonicPortals/PortalBuilder.swift @@ -14,13 +14,11 @@ class PortalBuilder { // MARK: - Static Properties - // MARK: - Instance Properties private let name: String private let onBuilderComplete: OnPortalBuilderComplete private var startDir: String? - private var plugins: [CAPPlugin] = [] private var initialContext: Any? // Initialization @@ -29,30 +27,35 @@ class PortalBuilder { self.onBuilderComplete = onComplete } + /** + * Sets the starting directory entry point for the web app if you have multiple web apps to choose from + * - Parameter startDir: The relative file path of the folder that contains your web app + * - Returns: self + */ public func setStartDir(startDir: String) -> PortalBuilder { self.startDir = startDir return self } - public func addPlugin(plugin: CAPPlugin) -> PortalBuilder { - plugins.append(plugin) - return self - } - + + /** + * Sets an initial context for the web application to pass the web application an initial state + * - Parameter initialContext: An object that can be serialized into JSON + * - Returns: self + */ public func setInitialContext(initialContext: Any) -> PortalBuilder { self.initialContext = initialContext return self } - public func setPlugins(plugins: [CAPPlugin]) -> PortalBuilder { - self.plugins = plugins - return self - } - + /** + * Sets an initial context for the web application to pass the web application an initial state + * - Parameter initialContext: An object that can be serialized into JSON + * - Returns: A newly created portal + */ public func create() -> Portal { let portal = Portal(self.name) portal.startDir = self.startDir ?? portal.name - portal.addPlugins(plugins) portal.initialContext = self.initialContext self.onBuilderComplete(portal) return portal