Skip to content
Draft
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/android/build/
/ios/libzcashlc.xcframework/
/ios/ZCashLightClientKit/
/ios/vendored/
/ios/zcashlc.h
/lib/
/tmp/
Expand Down
74 changes: 71 additions & 3 deletions react-native-zcash.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,40 @@ require "json"

package = JSON.parse(File.read(File.join(__dir__, "package.json")))

# Each bundled C dep module (ios/vendored/cmodules/<Name>/ — headers +
# module.modulemap) becomes one relative clang include path, so the in-pod
# ZcashLightClientKit source can resolve the C modules that the pre-built Swift
# dependency modules (SwiftNIO / GRPC) import.
cmodule_flags = Dir.glob(File.join(__dir__, "ios/vendored/cmodules/*"))
.select { |p| File.directory?(p) }
.map { |p| "-Xcc -I\"$(PODS_TARGET_SRCROOT)/ios/vendored/cmodules/#{File.basename(p)}\"" }
.join(" ")

# The pre-built Swift modules under ios/vendored/ are only readable by the
# EXACT Swift compiler that produced them (the binary .swiftmodule format is
# not stable across compilers, and the stable alternative — library-evolution
# .swiftinterface — is unavailable because swift-nio rejects evolution builds
# by upstream policy; see apple/swift-nio#2470/#2897, closed "not planned").
# Fail fast with instructions instead of letting the build die later on a
# cryptic "module compiled with Swift X cannot be imported by Swift Y" error.
stamp_path = File.join(__dir__, "ios/vendored/swift-version.txt")
if File.exist?(stamp_path)
built_with = File.read(stamp_path).strip
local_swift = `xcrun swift --version 2>/dev/null`[/swiftlang-[0-9.]+/]
if !built_with.empty? && !local_swift.nil? && built_with != local_swift
raise <<~MSG
react-native-zcash: the prebuilt Swift dependency modules in ios/vendored/
were built with #{built_with}, but this machine's Swift compiler is
#{local_swift}. Binary .swiftmodule files only load under the exact
compiler that produced them.

Fix: rebuild the vendored dependencies with your toolchain:
cd node_modules/react-native-zcash && npm run update-sources
(or switch to the Xcode whose Swift is #{built_with})
MSG
end
end

Pod::Spec.new do |s|
s.name = package['name']
s.version = package['version']
Expand All @@ -15,6 +49,10 @@ Pod::Spec.new do |s|
:git => "https://github.com/EdgeApp/react-native-zcash.git",
:tag => "v#{s.version}"
}

# The bridge + the vendored ZcashLightClientKit Swift source, compiled in-pod
# as ONE module (so the bridge uses SDK types directly — see copySwift in
# scripts/updateSources.ts).
s.source_files =
"ios/react-native-zcash-Bridging-Header.h",
"ios/RNZcash.m",
Expand All @@ -25,10 +63,40 @@ Pod::Spec.new do |s|
"zcash-mainnet" => "ios/ZCashLightClientKit/Resources/checkpoints/mainnet/*.json",
"zcash-testnet" => "ios/ZCashLightClientKit/Resources/checkpoints/testnet/*.json"
}
s.vendored_frameworks = "ios/libzcashlc.xcframework"

s.dependency "MnemonicSwift", "~> 2.2"
s.dependency "gRPC-Swift", "~> 1.8"
s.dependency "SQLite.swift/standalone", "~> 0.14"
s.dependency "React-Core"

# The Rust core (a binaryTarget on the SDK's GitHub release) plus the
# pre-built SwiftPM deps (see below). Vendored frameworks are real link
# inputs: CocoaPods adds them to the app link, where the linker pulls
# members on demand to satisfy the in-pod SDK source's references.
s.vendored_frameworks =
"ios/libzcashlc.xcframework",
"ios/vendored/libZcashDeps.xcframework"

# ---------------------------------------------------------------------------
# The SDK's SwiftPM-only dependencies (grpc-swift, SwiftNIO, SwiftProtobuf,
# SQLite.swift) pre-built into one static lib per platform, plus their Swift
# and C modules. grpc-swift 1.24+ ships SwiftPM-only with no podspec, so these
# can no longer be CocoaPods `dependency`s; vendoring them as a static binary
# keeps the host app on STATIC frameworks (consuming the SDK via
# spm_dependency would force the whole app onto dynamic frameworks).
#
# sqlite3 is not in this binary: on Apple platforms SQLite.swift has no C-shim
# target — it imports the system `sqlite3` clang module — so its sqlite3_*
# references resolve at app link time from whatever the host links (in Edge,
# its own sqlite pod and/or the sqlite embedded in libzcashlc). Note: Edge's
# pre-existing duplicate-sqlite3 ld warnings come from libzcashlc vs
# react-native-piratechain's libpiratelc (both Rust cores embed sqlite3) and
# are unrelated to this package's deps binary.
#
# Regenerate ios/vendored/ with `npm run update-sources`
# (scripts/buildVendoredDeps.ts).
# ---------------------------------------------------------------------------
s.preserve_paths = "ios/vendored/**/*"
s.pod_target_xcconfig = {
"SWIFT_INCLUDE_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ios/vendored/modules\"",
"OTHER_SWIFT_FLAGS" => cmodule_flags
}
end
Loading
Loading