Skip to content

Commit

Permalink
feat(ios): migrate to spm
Browse files Browse the repository at this point in the history
  • Loading branch information
rdlabo committed Nov 27, 2024
1 parent 8a288dd commit 7315ec5
Show file tree
Hide file tree
Showing 32 changed files with 3,011 additions and 1,729 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ node_modules/
Pods
Build
xcuserdata
.swiftpm

# macOS files
.DS_Store
Expand Down
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
2 changes: 1 addition & 1 deletion CapacitorCommunityAdmob.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ 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.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}'
s.ios.deployment_target = '13.0'
s.swift_version = '5.1'
s.static_framework = true
Expand Down
30 changes: 30 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// swift-tools-version: 5.9
import PackageDescription

let package = Package(
name: "CapacitorCommunityAdmob",
platforms: [.iOS(.v13)],
products: [
.library(
name: "CapacitorCommunityAdmob",
targets: ["AdMobPlugin"])
],
dependencies: [
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", branch: "main")
.package(url: "https://github.com/googleads/swift-package-manager-google-mobile-ads.git", from: "11.12.0")
],
targets: [
.target(
name: "AdMobPlugin",
dependencies: [
.product(name: "Capacitor", package: "capacitor-swift-pm"),
.product(name: "Cordova", package: "capacitor-swift-pm")
.product(name: "AdMob", package: "swift-package-manager-google-mobile-ads")
],
path: "ios/Sources/AdMobPlugin"),
.testTarget(
name: "AdMobPluginTests",
dependencies: ["AdMobPlugin"],
path: "ios/Tests/AdMobPluginTests")
]
)
3 changes: 1 addition & 2 deletions demo/angular/ios/App/App/capacitor.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"webDir": "www",
"cordova": {},
"packageClassList": [
"AdMob",
"AdMob"
"AdMobPlugin"
]
}
6 changes: 3 additions & 3 deletions demo/angular/ios/App/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PODS:
- Capacitor (6.0.0):
- CapacitorCordova
- CapacitorCommunityAdmob (6.0.0-0):
- CapacitorCommunityAdmob (6.0.0):
- Capacitor
- Google-Mobile-Ads-SDK (= 11.3.0)
- CapacitorCordova (6.0.0)
Expand Down Expand Up @@ -29,11 +29,11 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
Capacitor: 559d073c4ca6c27f8e7002c807eea94c3ba435a9
CapacitorCommunityAdmob: 859fda175acca723a87cb9419059fe5d818df617
CapacitorCommunityAdmob: f7638ab0789cd2d3a05ad6d015ca45ae76b63ea7
CapacitorCordova: 8c4bfdf69368512e85b1d8b724dd7546abeb30af
Google-Mobile-Ads-SDK: 301a16c461c331ba34ff4dab40a22ab7c147af61
GoogleUserMessagingPlatform: b1ad7bb1ee3ce64749d4fec24f667b36e45c396c

PODFILE CHECKSUM: caf5c0243508aa7da79d79fc34adc99fda665398

COCOAPODS: 1.13.0
COCOAPODS: 1.15.2
8 changes: 8 additions & 0 deletions ios/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
.build
/Packages
xcuserdata/
DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
694 changes: 0 additions & 694 deletions ios/Plugin.xcodeproj/project.pbxproj

This file was deleted.

10 changes: 0 additions & 10 deletions ios/Plugin.xcworkspace/contents.xcworkspacedata

This file was deleted.

8 changes: 0 additions & 8 deletions ios/Plugin.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist

This file was deleted.

10 changes: 0 additions & 10 deletions ios/Plugin/AdMob.h

This file was deleted.

23 changes: 0 additions & 23 deletions ios/Plugin/AdMob.m

This file was deleted.

24 changes: 0 additions & 24 deletions ios/Plugin/Info.plist

This file was deleted.

26 changes: 0 additions & 26 deletions ios/PluginTests/Info.plist

This file was deleted.

26 changes: 0 additions & 26 deletions ios/PluginTests/PluginTests.swift

This file was deleted.

17 changes: 0 additions & 17 deletions ios/Podfile

This file was deleted.

33 changes: 0 additions & 33 deletions ios/Podfile.lock

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,28 @@ import GoogleMobileAds
import AppTrackingTransparency
#endif

@objc(AdMob)
public class AdMob: CAPPlugin {
@objc(AdMobPlugin)
public class AdMobPlugin: CAPPlugin, CAPBridgedPlugin {
public let identifier = "AdMob"
public let jsName = "AdMob"
public let pluginMethods: [CAPPluginMethod] = [
CAPPluginMethod(name: "initialize", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "trackingAuthorizationStatus", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "requestConsentInfo", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "requestTrackingAuthorization", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "showConsentForm", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "resetConsentInfo", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "setApplicationMuted", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "setApplicationVolume", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "showBanner", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "resumeBanner", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "hideBanner", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "removeBanner", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "prepareInterstitial", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "showInterstitial", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "prepareRewardVideoAd", returnType: CAPPluginReturnPromise),
CAPPluginMethod(name: "showRewardVideoAd", returnType: CAPPluginReturnPromise)
]

var testingDevices: [String] = []

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Capacitor
import GoogleMobileAds

class BannerExecutor: NSObject, GADBannerViewDelegate {
weak var plugin: AdMob?
weak var plugin: AdMobPlugin?
var bannerView: GADBannerView!

func showBanner(_ call: CAPPluginCall, _ request: GADRequest, _ adUnitID: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import GoogleMobileAds
import UserMessagingPlatform

class ConsentExecutor: NSObject {
weak var plugin: AdMob?
weak var plugin: AdMobPlugin?

func requestConsentInfo(_ call: CAPPluginCall, _ debugGeography: Int, _ testDeviceIdentifiers: [String], _ tagForUnderAgeOfConsent: Bool) {
let parameters = UMPRequestParameters()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Capacitor
import GoogleMobileAds

class AdInterstitialExecutor: NSObject, GADFullScreenContentDelegate {
weak var plugin: AdMob?
weak var plugin: AdMobPlugin?
var interstitial: GADInterstitialAd!

func prepareInterstitial(_ call: CAPPluginCall, _ request: GADRequest, _ adUnitID: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Capacitor
import GoogleMobileAds

class AdRewardExecutor: NSObject, GADFullScreenContentDelegate {
weak var plugin: AdMob?
weak var plugin: AdMobPlugin?
var rewardedAd: GADRewardedAd!

func prepareRewardVideoAd(_ call: CAPPluginCall, _ request: GADRequest, _ adUnitID: String) {
Expand Down
15 changes: 15 additions & 0 deletions ios/Tests/AdMobPluginTests/AdMobPluginTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import XCTest
@testable import AdMobPlugin

class AdMobTests: XCTestCase {
func testEcho() {
// This is an example of a functional test case for a plugin.
// Use XCTAssert and related functions to verify your tests produce the correct results.

// let implementation = AdMob()
// let value = "Hello, World!"
// let result = implementation.echo(value)
//
// XCTAssertEqual(value, result)
}
}
Loading

0 comments on commit 7315ec5

Please sign in to comment.