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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Release Date

## Release Version

- [minor] Added no-code SDK file based initialization

# 18-11-2025

## 6.7.0
Expand Down
33 changes: 20 additions & 13 deletions Examples/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,28 @@

use_frameworks!

def moengage_dev_pods
test_source = nil
# test_source = { :git => 'https://github.com/moengage/MoEngage-iPhone-SDK.git', :branch => '' }
# test_source = { :path => '../../MoEngage-iPhone-SDK' }
return unless test_source
pod 'MoEngage-iOS-SDK', **test_source
pod 'MoEngageSecurity', **test_source
pod 'MoEngageCore', **test_source
pod 'MoEngageMessaging', **test_source
pod 'MoEngageSDK', **test_source
pod 'MoEngageTriggerEvaluator', **test_source
pod 'MoEngageInApps', **test_source
pod 'MoEngageCards', **test_source
pod 'MoEngageInbox', **test_source
pod 'MoEngageGeofence', **test_source
pod 'MoEngageRichNotification', **test_source
pod 'MoEngageRealTimeTrigger', **test_source
end

platform :ios, '13.0'
target 'MoEngagePluginBaseCocoaiOS' do
# test_source = { :git => 'https://github.com/moengage/MoEngage-iPhone-SDK.git', :branch => 'MOEN-37979_ver-upgrade' }
# pod 'MoEngage-iOS-SDK', **test_source
# pod 'MoEngageSecurity', **test_source
# pod 'MoEngageCore', **test_source
# pod 'MoEngageMessaging', **test_source
# pod 'MoEngageSDK', **test_source
# pod 'MoEngageTriggerEvaluator', **test_source
# pod 'MoEngageInApps', **test_source
# pod 'MoEngageCards', **test_source
# pod 'MoEngageInbox', **test_source
# pod 'MoEngageGeofence', **test_source
# pod 'MoEngageRichNotification', **test_source
# pod 'MoEngageRealTimeTrigger', **test_source
moengage_dev_pods
pod 'MoEngagePluginBase', :testspecs => ['Tests'], :path => '../'
pod 'MoEngagePluginGeofence', :path => '../../apple-plugin-geofence'
pod 'MoEngagePluginInbox', :path => '../../apple-plugin-inbox'
Expand Down
7 changes: 7 additions & 0 deletions MoEngagePluginBase.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ Pod::Spec.new do |s|
s.dependency 'MoEngage-iOS-SDK', config.sdkVerMin
s.dependency 'MoEngage-iOS-SDK/InApps'

version_file = "Sources/#{s.name}/MoEngagePluginConstants+Version.swift"
s.prepare_command = <<-CMD
echo "// Generated file, do not edit\n" > #{version_file}
echo "import Foundation\n" >> #{version_file}
echo "extension MoEngagePluginConstants {\n static let version = \\"#{s.version}\\"\n}" >> #{version_file}
Comment on lines +46 to +48
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The version file generation in post_build.rb (lines 59-66) uses a different format than the podspec's prepare_command (lines 46-48). The podspec uses echo with explicit \n newlines, while post_build.rb uses a heredoc. Consider using the same approach in both places for consistency. The heredoc approach in post_build.rb is cleaner and more readable, so consider updating the podspec to match this style.

Suggested change
echo "// Generated file, do not edit\n" > #{version_file}
echo "import Foundation\n" >> #{version_file}
echo "extension MoEngagePluginConstants {\n static let version = \\"#{s.version}\\"\n}" >> #{version_file}
cat <<EOF > #{version_file}
// Generated file, do not edit
import Foundation
extension MoEngagePluginConstants {
static let version = "#{s.version}"
}
EOF

Copilot uses AI. Check for mistakes.
CMD

test_file_glob = "Tests/#{s.name}Tests/**/*.{swift}"
s.test_spec 'Tests' do |ts|
ts.ios.deployment_target = '13.0'
Expand Down
36 changes: 20 additions & 16 deletions Sources/MoEngagePluginBase/MoEngagePlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import MoEngageInApps
MoEngage.sharedInstance.initializeLiveInstance(sdkConfig, sdkState: sdkState)
}
}
commonSetUp(identifier: sdkConfig.appId)
}

/// Initialize default instance SDK with provided `Info.plist` configuration.
Expand All @@ -54,7 +53,6 @@ import MoEngageInApps
MoEngageLogger.logDefault(message: "App ID is empty. Please provide a valid App ID to setup the SDK.")
return nil
}
commonSetUp(identifier: sdkConfig.appId)
return sdkConfig
}

Expand All @@ -78,8 +76,6 @@ import MoEngageInApps
#else
MoEngage.sharedInstance.initializeDefaultLiveInstance(sdkConfig, sdkState: sdkState)
#endif

commonSetUp(identifier: sdkConfig.appId)
}

private func initializeMoEngageDefaultInstance(sdkConfig: MoEngageSDKConfig, launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) {
Expand All @@ -89,8 +85,6 @@ import MoEngageInApps
#else
MoEngage.sharedInstance.initializeDefaultLiveInstance(sdkConfig)
#endif

commonSetUp(identifier: sdkConfig.appId)
}

// MARK: Initialization of secondary instance
Expand All @@ -113,8 +107,6 @@ import MoEngageInApps
MoEngage.sharedInstance.initializeLiveInstance(sdkConfig, sdkState: sdkState)
#endif

commonSetUp(identifier: sdkConfig.appId)

}

private func initializeMoEngageSecondaryInstance(sdkConfig: MoEngageSDKConfig, launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) {
Expand All @@ -123,21 +115,33 @@ import MoEngageInApps
#else
MoEngage.sharedInstance.initializeLiveInstance(sdkConfig)
#endif

commonSetUp(identifier: sdkConfig.appId)
}

@objc public func trackPluginInfo(_ pluginType: String, version: String) {
let integrationInfo = MoEngageIntegrationInfo(pluginType: pluginType, version: version)
MoEngageCoreIntegrator.sharedInstance.addIntergrationInfo(info: integrationInfo)
}

private func commonSetUp(identifier: String) {
setDelegates(identifier: identifier)
}

extension MoEngagePlugin: MoEngageModule.Item {
static let context: MoEngageSynchronizationContext = "com.moengage.pluginBase"

public static func getInfo(sdkInstance: MoEngageSDKInstance) -> MoEngageModule.Info {
return .init(name: "pluginBase", version: MoEngagePluginConstants.version)
}

// MARK: Delegate setup
private func setDelegates(identifier: String) {

public static func process(event: MoEngageModule.Event, sdkInstance: MoEngageSDKInstance) {
context.execute {
switch event {
case .`init`:
Self.setDelegates(identifier: sdkInstance.sdkConfig.appId)
default:
break
}
}
}

private static func setDelegates(identifier: String) {
_ = MoEngagePluginInAppDelegateHandler(identifier: identifier)
#if os(tvOS)
MoEngageLogger.logDefault(message: "MoEngagePluginMessageDelegateHandler is unavailable for tvOS 🛑")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Generated file, do not edit

import Foundation

extension MoEngagePluginConstants {
static let version = "6.7.0"
}
12 changes: 12 additions & 0 deletions Utilities/post_build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,15 @@
File.open('Package.swift', 'w') do |file|
file.write(package_swift)
end

version_constant = <<VERSION
// Generated file, do not edit
import Foundation

extension MoEngagePluginConstants {
static let version = "#{config.packages.find { |package| package.name == 'MoEngagePluginBase' }.version}"
}
VERSION
File.open('Sources/MoEngagePluginBase/MoEngagePluginConstants+Version.swift', 'w') do |file|
file.write(version_constant)
end
Loading