Skip to content

Commit

Permalink
SPM support
Browse files Browse the repository at this point in the history
  • Loading branch information
rlepinski committed Jul 2, 2024
1 parent 7699780 commit 07c5e74
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 36 deletions.
10 changes: 8 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,20 @@ let package = Package(
.package(url: "https://github.com/urbanairship/airship-mobile-framework-proxy.git", from: "7.0.0")
],
targets: [
.target(
name: "UaCapacitorAirship",
.target(
name: "UaCapacitorAirshipPlugin",
dependencies: [
.product(name: "Capacitor", package: "capacitor-swift-pm"),
.product(name: "Cordova", package: "capacitor-swift-pm"),
.product(name: "AirshipFrameworkProxy", package: "airship-mobile-framework-proxy")
],
path: "ios/Plugin"
),
.target(
name: "UaCapacitorAirship",
dependencies: [.target(name: "UaCapacitorAirshipPlugin")],
path: "ios/Bootloader",
publicHeadersPath: "Public"
)
]
)
14 changes: 12 additions & 2 deletions UaCapacitorAirship.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,19 @@ Pod::Spec.new do |s|
s.homepage = package['repository']['url']
s.author = package['author']
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
s.ios.deployment_target = '14.0'
s.dependency 'Capacitor'
s.swift_version = '5.1'
s.dependency "AirshipFrameworkProxy", "6.3.1"
s.dependency "AirshipFrameworkProxy", "7.0.0"
s.default_subspecs = ["Bootloader", "Plugin"]


s.subspec "Bootloader" do |bootloader|
bootloader.source_files = 'ios/Bootloader/**/*.{swift,h,m,c,cc,mm,cpp}'
end


s.subspec "Plugin" do |plugin|
plugin.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

#if __has_include(<UACapacitorAirship/UACapacitorAirship-Swift.h>)
#import <UACapacitorAirship/UACapacitorAirship-Swift.h>
#elif __has_include("UACapacitorAirship-Swift.h")
#import "UaCapacitorAirship-Swift.h"
#else
#import <Capacitor/
#import "UACapacitorAirship-Swift.h"
@import UaCapacitorAirshipPlugin;
#endif

@implementation AirshipCapacitorBootstrap
Expand Down
File renamed without changes.
28 changes: 18 additions & 10 deletions ios/Plugin.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
20C0B05DCFC8E3958A738AF2 /* Pods_PluginTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F6753A823D3815DB436415E3 /* Pods_PluginTests.framework */; };
50ADFF92201F53D600D50D53 /* UaCapacitorAirship.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50ADFF88201F53D600D50D53 /* UaCapacitorAirship.framework */; };
50ADFF97201F53D600D50D53 /* AirshipTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50ADFF96201F53D600D50D53 /* AirshipTests.swift */; };
50ADFF99201F53D600D50D53 /* AirshipPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 50ADFF8B201F53D600D50D53 /* AirshipPlugin.h */; settings = {ATTRIBUTES = (Public, ); }; };
50ADFFA42020D75100D50D53 /* Capacitor.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50ADFFA52020D75100D50D53 /* Capacitor.framework */; };
50ADFFA82020EE4F00D50D53 /* AirshipPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 50ADFFA72020EE4F00D50D53 /* AirshipPlugin.m */; };
50E1A94820377CB70090CE1A /* AirshipPlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E1A94720377CB70090CE1A /* AirshipPlugin.swift */; };
6EDE5F202B9FCF3600E33D04 /* AirshipCapacitorVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EDE5F1C2B9FCF3600E33D04 /* AirshipCapacitorVersion.swift */; };
6EDE5F212B9FCF3600E33D04 /* AirshipCapacitorBootstrap.h in Headers */ = {isa = PBXBuildFile; fileRef = 6EDE5F1D2B9FCF3600E33D04 /* AirshipCapacitorBootstrap.h */; };
Expand All @@ -34,13 +32,11 @@
/* Begin PBXFileReference section */
3B2A61DA5A1F2DD4F959604D /* Pods_Plugin.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Plugin.framework; sourceTree = BUILT_PRODUCTS_DIR; };
50ADFF88201F53D600D50D53 /* UaCapacitorAirship.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = UaCapacitorAirship.framework; sourceTree = BUILT_PRODUCTS_DIR; };
50ADFF8B201F53D600D50D53 /* AirshipPlugin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AirshipPlugin.h; sourceTree = "<group>"; };
50ADFF8C201F53D600D50D53 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
50ADFF91201F53D600D50D53 /* PluginTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PluginTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
50ADFF96201F53D600D50D53 /* AirshipTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AirshipTests.swift; sourceTree = "<group>"; };
50ADFF98201F53D600D50D53 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
50ADFFA52020D75100D50D53 /* Capacitor.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Capacitor.framework; sourceTree = BUILT_PRODUCTS_DIR; };
50ADFFA72020EE4F00D50D53 /* AirshipPlugin.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AirshipPlugin.m; sourceTree = "<group>"; };
50E1A94720377CB70090CE1A /* AirshipPlugin.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AirshipPlugin.swift; sourceTree = "<group>"; };
5E23F77F099397094342571A /* Pods-Plugin.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Plugin.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Plugin/Pods-Plugin.debug.xcconfig"; sourceTree = "<group>"; };
6EDE5F1C2B9FCF3600E33D04 /* AirshipCapacitorVersion.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AirshipCapacitorVersion.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -78,6 +74,7 @@
50ADFF7E201F53D600D50D53 = {
isa = PBXGroup;
children = (
6ECEF8102C34B0B300E7144C /* Bootloader */,
50ADFF8A201F53D600D50D53 /* Plugin */,
50ADFF95201F53D600D50D53 /* PluginTests */,
50ADFF89201F53D600D50D53 /* Products */,
Expand All @@ -99,12 +96,8 @@
isa = PBXGroup;
children = (
6EDE5F1F2B9FCF3600E33D04 /* AirshipCapacitorAutopilot.swift */,
6EDE5F1D2B9FCF3600E33D04 /* AirshipCapacitorBootstrap.h */,
6EDE5F1E2B9FCF3600E33D04 /* AirshipCapacitorBootstrap.m */,
6EDE5F1C2B9FCF3600E33D04 /* AirshipCapacitorVersion.swift */,
50E1A94720377CB70090CE1A /* AirshipPlugin.swift */,
50ADFF8B201F53D600D50D53 /* AirshipPlugin.h */,
50ADFFA72020EE4F00D50D53 /* AirshipPlugin.m */,
50ADFF8C201F53D600D50D53 /* Info.plist */,
);
path = Plugin;
Expand All @@ -119,6 +112,23 @@
path = PluginTests;
sourceTree = "<group>";
};
6ECEF8102C34B0B300E7144C /* Bootloader */ = {
isa = PBXGroup;
children = (
6ECEF8112C34B12A00E7144C /* Public */,
6EDE5F1E2B9FCF3600E33D04 /* AirshipCapacitorBootstrap.m */,
);
path = Bootloader;
sourceTree = "<group>";
};
6ECEF8112C34B12A00E7144C /* Public */ = {
isa = PBXGroup;
children = (
6EDE5F1D2B9FCF3600E33D04 /* AirshipCapacitorBootstrap.h */,
);
path = Public;
sourceTree = "<group>";
};
8C8E7744173064A9F6D438E3 /* Pods */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -147,7 +157,6 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
50ADFF99201F53D600D50D53 /* AirshipPlugin.h in Headers */,
6EDE5F212B9FCF3600E33D04 /* AirshipCapacitorBootstrap.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -324,7 +333,6 @@
50E1A94820377CB70090CE1A /* AirshipPlugin.swift in Sources */,
6EDE5F202B9FCF3600E33D04 /* AirshipCapacitorVersion.swift in Sources */,
6EDE5F232B9FCF3600E33D04 /* AirshipCapacitorAutopilot.swift in Sources */,
50ADFFA82020EE4F00D50D53 /* AirshipPlugin.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
8 changes: 6 additions & 2 deletions ios/Plugin/AirshipCapacitorAutopilot.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
/* Copyright Airship and Contributors */

#if canImport(AirshipKit)
import AirshipKit
#elseif canImport(AirshipCore)
import AirshipCore
#endif

import AirshipFrameworkProxy
import Capacitor

Expand Down Expand Up @@ -84,8 +89,7 @@ extension AirshipCapacitorAutopilot: AirshipProxyDelegate {
@MainActor
public func onAirshipReady() {
Airship.analytics.registerSDKExtension(
// todo, add capacitor
AirshipSDKExtension.cordova,
AirshipSDKExtension.capacitor,
version: AirshipCapacitorVersion.version
)
}
Expand Down
7 changes: 0 additions & 7 deletions ios/Plugin/AirshipPlugin.h

This file was deleted.

9 changes: 0 additions & 9 deletions ios/Plugin/AirshipPlugin.m

This file was deleted.

16 changes: 14 additions & 2 deletions ios/Plugin/AirshipPlugin.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
import Foundation
import Capacitor

#if canImport(AirshipKit)
import AirshipKit
#elseif canImport(AirshipCore)
import AirshipCore
#endif

import AirshipFrameworkProxy

/**
* Please read the Capacitor iOS Plugin Development Guide
* here: https://capacitorjs.com/docs/plugins/ios
*/
@objc(AirshipPlugin)
public class AirshipPlugin: CAPPlugin {

public class AirshipPlugin: CAPPlugin, CAPBridgedPlugin {

public let identifier = "AirshipPlugin"
public let jsName = "Airship"
public let pluginMethods: [CAPPluginMethod] = [
CAPPluginMethod(name: "perform", returnType: CAPPluginReturnPromise)
]

private static let eventNames: [AirshipProxyEventType: String] = [
.authorizedNotificationSettingsChanged: "ios_authorized_notification_settings_changed",
.pushTokenReceived: "push_token_received",
Expand Down

0 comments on commit 07c5e74

Please sign in to comment.