Repository navigation
Expand file tree
/
Copy pathcustomerio-reactnative.podspec
More file actions
102 lines (92 loc) · 5.16 KB
/
Copy pathcustomerio-reactnative.podspec
File metadata and controls
102 lines (92 loc) · 5.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
require "json"
require_relative "ios/cocoapods_swift_packages"
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
# For apps that build their pods with CocoaPods (bare React Native apps on CocoaPods, Expo apps on EAS Build).
# customerio-ios comes from its Swift package (ios/cocoapods_swift_packages.rb), never from a pod. React Native's
# Swift Package Manager mode doesn't use this file: spm/autolinking-plugin.js generates the package there.
Pod::Spec.new do |s|
s.name = "customerio-reactnative"
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 }
s.source = { :git => "https://github.com/customerio/customerio-reactnative.git", :tag => "#{s.version}" }
# Swift 5 language mode, as in the SwiftPM package (spm/autolinking-plugin.js).
s.swift_version = "5.0"
install_modules_dependencies(s)
# Optional modules and push provider: the 7.x subspecs below, or Podfile globals (`$customerio_location_enabled =
# true` before the targets), as in 7.x. android/gradle.properties is React Native's SwiftPM mode's, not read here.
switches = CustomerIO::SwiftPackages.module_switches
push_provider = switches["pushProvider"]
products = %w[DataPipelines MessagingInApp MessagingInbox] + CustomerIO::SwiftPackages::PUSH_PRODUCTS.fetch(push_provider, [])
defines = []
if switches["location"]
products << "Location"
defines << "-DCIO_LOCATION_ENABLED"
end
if switches["geofence"]
products << "LocationGeofence"
defines << "-DCIO_GEOFENCE_ENABLED"
end
if switches["liveActivities"]
products += %w[LiveActivities LiveActivities_Attributes LiveActivities_Templates]
defines << "-DCIO_LIVEACTIVITIES_ENABLED"
end
customerio_ios_version = package["cioNativeiOSSdkVersion"].to_s.sub(/\A=\s*/, "")
# As 7.x's `fcm` through CioFirebaseWrapper: FirebaseMessaging as a pod, so it shares one Firebase with the app's
# other Firebase pods. CioFirebaseWrapper (from customerio-ios's package) finds it at runtime.
firebase_messaging = ["FirebaseMessaging", ">= 8.7.0", "< 14.0.0"]
# Appended to what install_modules_dependencies set. The search path lets the .mm files import
# <CustomerIOReactNativeBridge/...>, a separate module only in SwiftPM mode. CUSTOMERIO_IOS_VERSION and
# CUSTOMERIO_IOS_PRODUCTS record the pin and the switches' products in the spec, so CocoaPods' incremental
# installation regenerates the target (and its package) when either changes.
xcconfig = (s.attributes_hash["pod_target_xcconfig"] || {}).dup
xcconfig["HEADER_SEARCH_PATHS"] = [xcconfig["HEADER_SEARCH_PATHS"] || "$(inherited)", "\"${PODS_TARGET_SRCROOT}/ios/bridge/include\""].join(" ")
xcconfig["OTHER_SWIFT_FLAGS"] = ([xcconfig["OTHER_SWIFT_FLAGS"] || "$(inherited)"] + defines).join(" ")
xcconfig["CUSTOMERIO_IOS_VERSION"] = customerio_ios_version
xcconfig["CUSTOMERIO_IOS_PRODUCTS"] = products.join(" ")
s.pod_target_xcconfig = xcconfig
# The bridge lives in `core`, which every other subspec depends on: CocoaPods leaves the root spec's own files
# out when a Podfile names only a subspec (a 7.x `pod 'customerio-reactnative/apn'` before autolinking).
# `core` is also the default, so a plain `pod 'customerio-reactnative'` (what autolinking adds) turns no module on.
# (`default_subspecs = :none` would leave the bridge out, and CocoaPods 1.17 crashes on it when a pod has two
# variants, such as two app targets with different linkage.)
s.default_subspec = "core"
s.subspec "core" do |ss|
ss.source_files = "ios/wrappers/**/*.{h,m,mm,swift}", "ios/bridge/**/*.{h,m}"
# Only the view-bridge protocols are public: Swift sees them through the pod's own module.
ss.public_header_files = "ios/bridge/include/**/*.h"
ss.dependency(*firebase_messaging) if push_provider == "fcm"
end
# The 7.x subspecs, which pick the push provider and optional modules as in 7.x. Their customerio-ios products
# are added at pod install (ios/cocoapods_swift_packages.rb), by the subspecs each pod target uses.
{
"location" => "-DCIO_LOCATION_ENABLED",
"geofence" => "-DCIO_GEOFENCE_ENABLED -DCIO_LOCATION_ENABLED",
"liveactivities" => "-DCIO_LIVEACTIVITIES_ENABLED",
"nopush" => nil,
"apn" => nil,
"fcm" => nil,
"fcm-core" => nil,
}.each do |name, subspec_defines|
s.subspec name do |ss|
ss.dependency "customerio-reactnative/core"
ss.dependency(*firebase_messaging) if name == "fcm"
ss.pod_target_xcconfig = { "OTHER_SWIFT_FLAGS" => "$(inherited) #{subspec_defines}" } if subspec_defines
end
end
CustomerIO::SwiftPackages.register(s,
version: customerio_ios_version,
products: products,
subspecs: CustomerIO::SwiftPackages::PUSH_PRODUCTS.merge(
"location" => %w[Location],
"geofence" => %w[Location LocationGeofence],
"liveactivities" => %w[LiveActivities LiveActivities_Attributes LiveActivities_Templates]
),
push_provider: push_provider,
# As 7.x's `nopush`: the push module without a provider, which the bridge imports.
no_push_products: %w[MessagingPush]
)
end