diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a78db1..1f99bc6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# Release Date + +## Release Version + +- [minor] Added no-code SDK file based initialization + # 18-11-2025 ## 6.7.0 diff --git a/Examples/Podfile b/Examples/Podfile index 3975222..7d44fad 100644 --- a/Examples/Podfile +++ b/Examples/Podfile @@ -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' diff --git a/MoEngagePluginBase.podspec b/MoEngagePluginBase.podspec index bb8c999..11aefec 100644 --- a/MoEngagePluginBase.podspec +++ b/MoEngagePluginBase.podspec @@ -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} + CMD + test_file_glob = "Tests/#{s.name}Tests/**/*.{swift}" s.test_spec 'Tests' do |ts| ts.ios.deployment_target = '13.0' diff --git a/Sources/MoEngagePluginBase/MoEngagePlugin.swift b/Sources/MoEngagePluginBase/MoEngagePlugin.swift index 4253c6a..0779782 100644 --- a/Sources/MoEngagePluginBase/MoEngagePlugin.swift +++ b/Sources/MoEngagePluginBase/MoEngagePlugin.swift @@ -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. @@ -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 } @@ -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) { @@ -89,8 +85,6 @@ import MoEngageInApps #else MoEngage.sharedInstance.initializeDefaultLiveInstance(sdkConfig) #endif - - commonSetUp(identifier: sdkConfig.appId) } // MARK: Initialization of secondary instance @@ -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) { @@ -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 🛑") diff --git a/Sources/MoEngagePluginBase/MoEngagePluginConstants+Version.swift b/Sources/MoEngagePluginBase/MoEngagePluginConstants+Version.swift new file mode 100644 index 0000000..cd3365c --- /dev/null +++ b/Sources/MoEngagePluginBase/MoEngagePluginConstants+Version.swift @@ -0,0 +1,7 @@ +// Generated file, do not edit + +import Foundation + +extension MoEngagePluginConstants { + static let version = "6.7.0" +} diff --git a/Utilities/post_build.rb b/Utilities/post_build.rb index 6a61780..b273d37 100755 --- a/Utilities/post_build.rb +++ b/Utilities/post_build.rb @@ -55,3 +55,15 @@ File.open('Package.swift', 'w') do |file| file.write(package_swift) end + +version_constant = <