I'm trying to build a react-native wrapper module for the official Spotify SDK, using expo-modules. I've added the SDK in my .podspec
file using s.vendored_frameworks
. Example app's project pre-build works fine, but the framework's header files do not get copied, and while building the app for the Simulator, I get this error:
❌ (/Users/<username>/Library/Developer/Xcode/DerivedData/expospotifyexample-ayfjxgjzbhoakacqvfpiaawhvpwz/Build/Products/Debug-iphonesimulator/ExpoSpotify/ExpoSpotify-umbrella.h:13:9)
11 | #endif
12 |
> 13 | #import "SpotifyAppRemote.h"
| ^ 'SpotifyAppRemote.h' file not found
14 | #import "SpotifyiOS.h"
15 | #import "SPTAppRemote.h"
16 | #import "SPTAppRemoteAlbum.h"
It works fine if I manually copy SDK's header files to the path from the error.
my folder structure (just the important bits):
├─ example/
│ ├─ ios/
│ │ ├─ Pods/
│ │ │ ├─ Headers/
│ │ │ │ ├─ Public/
│ │ │ │ │ ├─ ExpoSpotify/
│ │ │ │ │ │ ├─ ExpoSpotify.modulemap
│ │ │ │ │ │ ├─ ExpoSpotify-umbrella.h
├─ ios/
│ ├─ SpotifyiOS.xcframework/
│ │ ├─ ios-arm64_armv7/
│ │ │ ├─ SpotifyiOS.framework/
│ │ │ │ ├─ Headers/
│ │ │ │ │ ├─ SpotifyAppRemote.h
│ │ │ │ ├─ Modules/
│ │ │ │ │ ├─ module.modulemap
│ │ ├─ ios-arm64_i386_x86_64-simulator/
│ │ │ ├─ SpotifyiOS.framework/
│ │ │ │ ├─ Headers/
│ │ │ │ │ ├─ SpotifyAppRemote.h
│ │ │ │ ├─ Modules/
│ │ │ │ │ ├─ module.modulemap
│ │ ├─ Info.plist
│ ├─ ExpoSpotify.podspec
│ ├─ ExpoSpotifyModule.swift
my .podspec file:
require 'json'
package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
Pod::Spec.new do |s|
s.name = 'ExpoSpotify'
s.version = package['version']
s.summary = package['description']
s.description = package['description']
s.license = package['license']
s.author = package['author']
s.homepage = package['homepage']
s.platform = :ios, '13.0'
s.swift_version = '5.4'
s.source = { git: 'https://github.com/' }
s.static_framework = true
s.dependency 'ExpoModulesCore'
# Swift/Objective-C compatibility
s.pod_target_xcconfig = {
'DEFINES_MODULE' => 'YES',
'SWIFT_COMPILATION_MODE' => 'wholemodule',
}
s.preserve_paths = "ExpoSpotify/SpotifyiOS.xcframework/**/*"
s.vendored_frameworks = 'ExpoSpotify/SpotifyiOS.xcframework'
s.source_files = "**/*.{h,m,swift}", 'ExpoSpotify/SpotifyiOS.xcframework/**/Headers/*.{h,m}'
end
One thing I've noticed. In the example apps example/ios/Pods/Headers/Public/ExpoSpotify-umbrella.h
file, the imports are doubled and flat:
#import "SpotifyAppRemote.h"
... other headers
#import "SpotifyAppRemote.h"
... other headers
but when I add to the .podspec the path to framework's modulemap:
s.header_mappings_dir = 'ExpoSpotify/ios/SpotifyiOS.xcframework/**/Modules'
then imports are relative (but wrong path)
#import "../../../../../SpotifyiOS.xcframework/ios-arm64_armv7/SpotifyiOS.framework/Headers/SpotifyAppRemote.h"
#import "../../../../../SpotifyiOS.xcframework/ios-arm64_i386_x86_64-simulator/SpotifyiOS.framework/Headers/SpotifyAppRemote.h"
if it ditch the ExpoSpotify in the path
s.preserve_paths = "SpotifyiOS.xcframework/**/*"
s.vendored_frameworks = 'SpotifyiOS.xcframework'
s.source_files = "**/*.{h,m,swift}", 'SpotifyiOS.xcframework/**/Headers/*.{h,m}'
s.header_mappings_dir = 'SpotifyiOS.xcframework/**/Modules'
The import path is shorter (still wrong):
#import "../../ios-arm64_armv7/SpotifyiOS.framework/Headers/SpotifyAppRemote.h"
#import "../../ios-arm64_i386_x86_64-simulator/SpotifyiOS.framework/Headers/SpotifyAppRemote.h"
I'm using MacBook with M2 processor, macOS Ventura (13.3.1), latest Xcode, Cocoapods 1.12.0.