require "json" package = JSON.parse(File.read(File.join(__dir__, "package.json"))) # package = JSON.parse(File.read('package.json')) connectConfig = JSON.parse(File.read('../../ConnectConfig.json')) repository = package["repository"]["url"] useRelease = connectConfig["Connect"]["useRelease"] dependencyName = useRelease ? 'AcousticConnect' : 'AcousticConnectDebug' iOSVersion = connectConfig["Connect"]["iOSVersion"] # Floor required by the RN bridge: # - `ConnectSDK.shared.enable(with:)` and `ConnectConfig` landed in 2.0.0 # (CA-135041) — anything older lacks the Swift symbols this file imports. # - Bundle-less init via `_connectApplyBundleDefaults` landed in 2.0.5 # (CA-136977, Release_Connect_Module_2_0_5, 2026-04-13). Without it, # consumers who don't bundle `EOCoreSettings.bundle` + `TLFResources.bundle` # fail to enable the SDK at all — the bridge ships no bundles and relies # on programmatic config, so this fix is load-bearing here. # Consumers can still pin a specific version via # `ConnectConfig.json -> Connect.iOSVersion`; CocoaPods composes both # constraints, so an attempted downgrade fails loudly at `pod install`. # # Push: the iOS Connect SDK ships push as part of the same pod (`ConnectPushConfig` # is in `ConnectSDK.shared.enable(with:)`), so this single floor covers both the # analytics and push code paths. If a future SDK major splits push into a # separate pod or moves push features to a higher floor, this is the natural # place to introduce a conditional floor keyed off # `ConnectConfig.json -> Connect.PushEnabled` (mirrors the Android conditional # on `connect-push-fcm` in `android/build.gradle`). sdkFloor = '>= 2.0.5' dependencyRequirements = iOSVersion.to_s.empty? ? [sdkFloor] : [sdkFloor, iOSVersion] # Write the merged consumer config to the resource-bundle source path AT POD INSTALL TIME. # This MUST happen before CocoaPods builds the AcousticConnectRNConfig bundle target, # which it does as a dependency of the parent target — too early for any build-time # script_phase to influence. Writing here ensures the bundle ships the consumer's # AppKey / PostMessageUrl / KillSwitchUrl from the very first build, instead of an # empty placeholder that causes the SDK to fall back to its bundled demo defaults. # See: ios/AcousticConnectRNConfig.json (placeholder shipped in the npm tarball; # overwritten here on every `pod install`). File.open(File.join(__dir__, 'ios', 'AcousticConnectRNConfig.json'), 'w') do |f| f.write(JSON.pretty_generate(connectConfig)) end puts "Merged ConnectConfig.json into ios/AcousticConnectRNConfig.json (install-time)" puts "*********react-native-acoustic-connect-beta.podspec*********" puts "connectConfig:" puts JSON.pretty_generate(connectConfig) puts "repository:#{repository}" puts "useRelease:#{useRelease}" puts "dependencyName:#{dependencyName}" puts "dependencyRequirements:#{dependencyRequirements.inspect}" puts "***************************************************************" Pod::Spec.new do |s| s.name = "AcousticConnectRN" # s.name = package["name"] s.version = package["version"] s.summary = package["description"] s.homepage = package["homepage"] s.license = package["license"] s.authors = package["author"] s.platforms = { :ios => min_ios_version_supported, :visionos => 1.0 } s.source = { :git => "https://github.com/ohernandezIBM/react-native-acoustic-connect-beta.git", :tag => "#{s.version}" } s.source_files = [ # Implementation (Swift) "ios/**/*.{swift}", # Autolinking/Registration (Objective-C++) "ios/**/*.{m,mm}", # Implementation (C++ objects) "cpp/**/*.{hpp,cpp}", ] s.pod_target_xcconfig = { # C++ compiler flags, mainly for folly. "GCC_PREPROCESSOR_DEFINITIONS" => "$(inherited) FOLLY_NO_CONFIG FOLLY_CFG_NO_COROUTINES" } s.resource_bundle = { 'AcousticConnectRNConfig' => ['ios/AcousticConnectRNConfig.json'], } s.resource = 'ios/AcousticConnectRNConfig.json' load 'nitrogen/generated/ios/AcousticConnectRN+autolinking.rb' add_nitrogen_files(s) s.dependency 'React-jsi' s.dependency 'React-callinvoker' s.dependency dependencyName, *dependencyRequirements install_modules_dependencies(s) end