ioscocoapodsreact-native-iospodspecxcframework

What should be the Podspec file for using local .xcframework in React Native library?


I created a React Native library that is a wrapper for using the native iOS framework in the React Native Projects. Earlier I was using .framework & it was working fine. Now I am facing an issue in using this library with .xcframework instead of .framework.

I added this library as a dependency to the project & then on running pod install getting the below error:

[!] [Xcodeproj] Generated duplicate UUIDs:

When I opened the project & try to build it, it builds successfully for the device but fails on the simulator.

Below is the Podspec file that I am using in the library project:

Pod::Spec.new do |s|
  s.name         = "react-native-myLibrary"
  s.version      = "1.0.0"
  s.summary      = "react-native-myLibrary"
  s.description  = <<-DESC
                    react-native-myLibrary
                   DESC
  
  s.homepage     = "https://github.com/geektimecoil/react-native-onesignal"
  s.license      = "MIT"
  s.author       = { "author" => "author@domain.cn" }
  s.platform     = :ios, "10.0"
  s.source       = { :http => 'file:' + __dir__ + '/' }

  s.source_files = "**/*.{h,m,swift}"
  s.requires_arc = true
  s.vendored_frameworks = 'MyLibrary.xcframework'

  s.dependency "React"
end

On searching for the solution I found that this error is caused by s.source_files = "**/*.{h,m,swift}". So, I commented this line & run pod install again. The error was gone but no dependency is being added to the Project target. Can anyone provide me the Podspec file to use for local .xcframework in React Native Library. Thanks in advance!


Solution

  • I was able to fix this issue using:

    s.source_files = "ios/*.{h,m,swift}"
    s.vendored_frameworks = 'ios/Frameworks/MyLibrary.xcframework'
    

    & also by updating the Framework Search Paths from the Build Settings to $(inherited).