HomeiOS Developmentreact native - Utilizing expo-modules with third get together native xcframeworks (iOS)

react native – Utilizing expo-modules with third get together native xcframeworks (iOS)


I am attempting to construct a wrapper module for the Official Spotify SDK utilizing expo-modules. I’ve added the SDK in my .podspec file utilizing s.vendored_frameworks. Instance app’s venture pre construct works nice, however the frameworks header recordsdata don’t get copied, and whereas constructing the app for the Simulator, I get this error:

❌  (/Customers/<username>/Library/Developer/Xcode/DerivedData/expospotifyexample-ayfjxgjzbhoakacqvfpiaawhvpwz/Construct/Merchandise/Debug-iphonesimulator/ExpoSpotify/ExpoSpotify-umbrella.h:13:9)

  11 | #endif
  12 | 
> 13 | #import "SpotifyAppRemote.h"
     |         ^ 'SpotifyAppRemote.h' file not discovered
  14 | #import "SpotifyiOS.h"
  15 | #import "SPTAppRemote.h"
  16 | #import "SPTAppRemoteAlbum.h"

It really works nice if I manually copy SDK’s header recordsdata to the trail from the error.

my folder construction (simply the necessary bits):

├─ instance/
│  ├─ 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
│  │  ├─ Data.plist
│  ├─ ExpoSpotify.podspec
│  ├─ ExpoSpotifyModule.swift

my .podspec file:

require 'json'

package deal = JSON.parse(File.learn(File.be part of(__dir__, '..', 'package deal.json')))

Pod::Spec.new do |s|
  s.title="ExpoSpotify"
  s.model        = package deal['version']
  s.abstract        = package deal['description']
  s.description    = package deal['description']
  s.license        = package deal['license']
  s.writer         = package deal['author']
  s.homepage       = package deal['homepage']
  s.platform       = :ios, '13.0'
  s.swift_version  = '5.4'
  s.supply         = { git: 'https://github.com/kvbalib/expo-spotify' }
  s.static_framework = true

  s.dependency 'ExpoModulesCore'

  # Swift/Goal-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}'
finish

One factor I’ve observed. Within the instance apps instance/ios/Pods/Headers/Public/ExpoSpotify-umbrella.h file, the imports are doubled and flat:

#import "SpotifyAppRemote.h"
... different headers
#import "SpotifyAppRemote.h"
... different headers

however once I add to the .podspec the trail to framework’s modulemap:

s.header_mappings_dir="ExpoSpotify/ios/SpotifyiOS.xcframework/**/Modules"

then imports are relative (however unsuitable 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 within 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 (nonetheless unsuitable):

#import "../../ios-arm64_armv7/SpotifyiOS.framework/Headers/SpotifyAppRemote.h"
#import "../../ios-arm64_i386_x86_64-simulator/SpotifyiOS.framework/Headers/SpotifyAppRemote.h"

I am utilizing MacBook with M2 processor, macOS Ventura (13.3.1), newest Xcode, Cocoapods 1.12.0.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments