Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -192,4 +192,4 @@ iOSInjectionProject/
# Plugin ignore
# ==========
plugin/node_modules
plugin/dist
plugin/dist
3 changes: 3 additions & 0 deletions ios/IonicPortals.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions ios/IonicPortals/IonicPortals.podspec
Original file line number Diff line number Diff line change
@@ -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
61 changes: 61 additions & 0 deletions ios/IonicPortals/IonicPortals.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
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 */; };
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, ); }; };
Expand All @@ -24,6 +27,11 @@
/* 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 = "<group>"; };
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 = "<group>"; };
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 = "<group>"; };
E90B7D4F26A9CB880067D73E /* PortalManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PortalManager.swift; path = IonicPortals/PortalManager.swift; sourceTree = "<group>"; };
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 = "<group>"; };
E985F884269E2D260031F820 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
Expand All @@ -38,6 +46,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
3845A534A28C7E3728A0A58A /* Pods_IonicPortals.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -52,13 +61,35 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
1F249143665D3AA4301AD1DE /* Frameworks */ = {
isa = PBXGroup;
children = (
E44A8EABC3166358F2924543 /* Pods_IonicPortals.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
9D0BB0A71D75531B34F29BDB /* Pods */ = {
isa = PBXGroup;
children = (
2C8BCCA3D236847121E67C22 /* Pods-IonicPortals.debug.xcconfig */,
2514A9D89B5C400A41EF8FEB /* Pods-IonicPortals.release.xcconfig */,
);
name = Pods;
path = ../Pods;
sourceTree = "<group>";
};
E985F876269E2D260031F820 = {
isa = PBXGroup;
children = (
E90B7D4F26A9CB880067D73E /* PortalManager.swift */,
E90B7D4B26A9C4F40067D73E /* PortalBuilder.swift */,
E985F89E269E2D830031F820 /* Portal.swift */,
E985F882269E2D260031F820 /* IonicPortals */,
E985F88D269E2D260031F820 /* IonicPortalsTests */,
E985F881269E2D260031F820 /* Products */,
9D0BB0A71D75531B34F29BDB /* Pods */,
1F249143665D3AA4301AD1DE /* Frameworks */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -107,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 */,
Expand Down Expand Up @@ -193,11 +225,38 @@
};
/* 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;
buildActionMask = 2147483647;
files = (
E90B7D4C26A9C4F40067D73E /* PortalBuilder.swift in Sources */,
E90B7D5026A9CB880067D73E /* PortalManager.swift in Sources */,
E985F89F269E2D830031F820 /* Portal.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -345,6 +404,7 @@
};
E985F895269E2D260031F820 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 2C8BCCA3D236847121E67C22 /* Pods-IonicPortals.debug.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
Expand Down Expand Up @@ -372,6 +432,7 @@
};
E985F896269E2D260031F820 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 2514A9D89B5C400A41EF8FEB /* Pods-IonicPortals.release.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
Expand Down
15 changes: 14 additions & 1 deletion ios/IonicPortals/IonicPortals/Portal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,26 @@
//

import Foundation
import Capacitor

public class Portal {
public init() {

// MARK: - Instance Properties
public let name: String;
public var plugins: [CAPPlugin] = []
public var initialContext: Any?
public var startDir: String?

public init(_ name: String) {
print("Constructor")
self.name = name
}

public func HelloWorld() {
print("Hello World")
}

public func addPlugins(_ plugins: [CAPPlugin]) {
self.plugins = plugins
}
}
63 changes: 63 additions & 0 deletions ios/IonicPortals/IonicPortals/PortalBuilder.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//
// PortalManager.swift
// IonicPortals
//
// Created by Thomas Vidas on 7/22/21.
//

import Foundation
import Capacitor

typealias OnPortalBuilderComplete = (_ portal : Portal) -> Void

class PortalBuilder {

// MARK: - Static Properties

// MARK: - Instance Properties
private let name: String
private let onBuilderComplete: OnPortalBuilderComplete

private var startDir: String?
private var initialContext: Any?

// Initialization
public init(_ name: String, _ onComplete: @escaping OnPortalBuilderComplete) {
self.name = name
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
}


/**
* 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
}

/**
* 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.initialContext = self.initialContext
self.onBuilderComplete(portal)
return portal
}
}
68 changes: 68 additions & 0 deletions ios/IonicPortals/IonicPortals/PortalManager.swift
Original file line number Diff line number Diff line change
@@ -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<String, Portal>()

// 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)
})
}
}
27 changes: 27 additions & 0 deletions ios/Podfile
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -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
Loading