Here is a content of my Podfile.
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/react-native-unimodules/cocoapods.rb'
require_relative '../node_modules/#react-native-community/cli-platform-ios/native_modules'
platform :ios, '10.0'
target 'test' do
use_unimodules!
config = use_native_modules!
use_react_native!(
:path => config["reactNativePath"],
:hermes_enabled => true
)
def find_and_replace(dir, findstr, replacestr)
Dir[dir].each do |name|
text = File.read(name)
replace = text.gsub(findstr,replacestr)
if text != replace
puts "Fix: " + name
File.open(name, "w") { |file| file.puts replace }
STDOUT.flush
end
end
Dir[dir + '*/'].each(&method(:find_and_replace))
end
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable these next few lines.
use_flipper!({ 'Flipper-Folly' => '2.5.3', 'Flipper' => '0.87.0', 'Flipper-RSocket' => '1.3.1' })
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
# https://stackoverflow.com/a/67308343/10540870
## Fix for XCode 12.5 & RN 0.62.2 - See https://github.com/facebook/react-native/issues/28405
find_and_replace("../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm",
"_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules")
find_and_replace("../node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm",
"RCTBridgeModuleNameForClass(strongModule))", "RCTBridgeModuleNameForClass(Class(strongModule)))")
find_and_replace("Pods/Headers/Private/RCT-Folly/folly/synchronization/DistributedMutex-inl.h",
"atomic_notify_one(state)", "folly::atomic_notify_one(state)")
find_and_replace("Pods/Flipper-Folly/folly/synchronization/DistributedMutex-inl.h",
"atomic_wait_until(&state, previous | data, deadline)", "folly::atomic_wait_until(&state, previous | data, deadline)")
end
# Other native modules
end
I can build the project locally. Both, ios and android run is great. But I've got this issue while running the docker build. I got this on a first local run as well but this one has dissappeared after removing Pods and reinstalling these. Docker image is doing the same algorithm but this error keeps coming.
Related
I'm trying to update an application built with expo + react native and I encounter the last problem.
expo.dev
Visual Code terminal
🍎 iOS build failed:
Starting from Xcode 14, resource bundles are signed by default, which requires
setting the development team for each resource bundle target.
To resolve this issue, downgrade to an older Xcode version using the "image" field in
eas.json, or turn off signing resource bundles in your Podfile:
https://expo.fyi/r/disable-bundle-resource-signing
Learn more: https://docs.expo.dev/build-reference/infrastructure/#ios-build-server-
configurations
I tried to solve this problem by cleaning cache and reinstalling all pods.
I went to the permissions in xcode, I tried logging in with an apple developer account but still the same.
I tried to see the changes in this link https://expo.fyi/r/disable-bundle-resource-signing but it is very different from mine, I made the changes but all app is broken when i try to build.
Expo Version: 43.00
cocoapods: "1.11.2"
eas cli version: ">= 0.38.1"
xCode Version: 13.2.1
Podfile
require File.join(File.dirname(`node --print
"require.resolve('expo/package.json')"`), "scripts/autolinking")
require File.join(File.dirname(`node --print "require.resolve('react-
native/package.json')"`), "scripts/react_native_pods")
require File.join(File.dirname(`node --print "require.resolve('#react-native-
community/cli-platform-ios/package.json')"`), "native_modules")
platform :ios, '12.0'
require 'json'
podfile_properties = JSON.parse(File.read('./Podfile.properties.json')) rescue {}
target 'appName' do
use_expo_modules!
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
:hermes_enabled => podfile_properties['expo.jsEngine'] == 'hermes'
)
# Uncomment to opt-in to using Flipper
#
# if !ENV['CI']
# use_flipper!('Flipper' => '0.75.1', 'Flipper-Folly' => '2.5.3', 'Flipper-RSocket'
=> '1.3.1')
# end
post_install do |installer|
react_native_post_install(installer)
# Workaround `Cycle inside FBReactNativeSpec` error for react-native 0.64
# Reference: https://github.com/software-mansion/react-native-screens/issues/842#issuecomment-812543933
installer.pods_project.targets.each do |target|
if (target.name&.eql?('FBReactNativeSpec'))
target.build_phases.each do |build_phase|
if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs'))
target.build_phases.move(build_phase, 0)
end
end
end
end
end
end
How can i solve this problem in may case?
To solve the problem, follow these steps:
In terminal:
cd ios
pod deintegrate
After changing the code from Podfile with this one.
require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
require File.join(File.dirname(`node --print "require.resolve('react- native/package.json')"`), "scripts/react_native_pods")
require File.join(File.dirname(`node --print "require.resolve('#react-native-community/cli-platform-ios/package.json')"`), "native_modules")
platform :ios, '12.0'
require 'json'
podfile_properties = JSON.parse(File.read('./Podfile.properties.json'))
rescue {}
target 'YOUR APP NAME' do
use_expo_modules!
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
:hermes_enabled => podfile_properties['expo.jsEngine'] == 'hermes'
)
# Uncomment to opt-in to using Flipper
#
# if !ENV['CI']
# use_flipper!('Flipper' => '0.75.1', 'Flipper-Folly' => '2.5.3',
'Flipper-RSocket' => '1.3.1')
# end
post_install do |installer|
react_native_post_install(installer)
# __apply_Xcode_12_5_M1_post_install_workaround(installer)
# This is necessary for Xcode 14, because it signs resource bundles by default
# when building for devices.
installer.target_installation_results.pod_target_installation_results
.each do |pod_name, target_installation_result|
target_installation_result.resource_bundle_targets.each do |resource_bundle_target|
resource_bundle_target.build_configurations.each do |config|
config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
end
end
end
end
end
After run on terminal:
pod install
pod update
cd ..
These changes worked for me and allowed me to adapt the application
This is just a workaround, not a fix. In fact, you may have multiple targets with different team IDs.
This post_install script in podfile fixed it. As it seems, setting the own developer team is necessary. Replace Your Team ID with the TeamID of your project.
Adding to what #Pruteanu Alexandru answer
cd ios
pod deintegrate
After changing/adding the code from/to Podfile with this one.
post_install do |installer|
installer.generated_projects.each do |project|
project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings["DEVELOPMENT_TEAM"] = "Your Team ID"
end
end
end
end
Your PodFile might look like this:
post_install do |installer|
react_native_post_install(installer)
# Workaround `Cycle inside FBReactNativeSpec` error for react-native 0.64
# Reference: https://github.com/software-mansion/react-native-screens/issues/842#issuecomment-812543933
installer.pods_project.targets.each do |target|
if (target.name&.eql?('FBReactNativeSpec'))
target.build_phases.each do |build_phase|
if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs'))
target.build_phases.move(build_phase, 0)
end
end
end
end
installer.generated_projects.each do |project|
project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings["DEVELOPMENT_TEAM"] = "YOUR TEAM ID"
end
end
end
end
After run this on terminal:
pod install
pod update
cd ..
I inherited a React Native project (previous developer is not reachable anymore) and building the iOS App with npx react-native run-ios always fails with:
** BUILD FAILED **
The following build commands failed:
SwiftCompile normal x86_64 Compiling\ DatabaseBridge.swift /Users/myuser/code/myapp/myapp_android/node_modules/#nozbe/watermelondb/native/ios/WatermelonDB/DatabaseBridge.swift (in target 'WatermelonDB' from project 'Pods')
CompileSwift normal x86_64 /Users/daniel/code/myapp/myapp_android/node_modules/#nozbe/watermelondb/native/ios/WatermelonDB/DatabaseBridge.swift (in target 'WatermelonDB' from project 'Pods')
(2 failures)
Before this step i ran pod install in the ios-Folder.
My Podfile
require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/#react-native-community/cli-platform-ios/native_modules'
deployment_target = Gem::Version.new('12.0')
platform :ios, deployment_target
target 'MyApp' do
use_expo_modules!
post_integrate do |installer|
begin
expo_patch_react_imports!(installer)
rescue => e
Pod::UI.warn e
end
begin
expo_patch_react_imports!(installer)
rescue => e
Pod::UI.warn e
end
end
config = use_native_modules!
pod 'simdjson', path: '../node_modules/#nozbe/simdjson'
# use_frameworks! :linkage => :static # -> this might run into conflicts with flipper (see below)
# or:
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi', :modular_headers => true
pod 'SDWebImage', :modular_headers => true
pod 'SDWebImageWebPCoder', :modular_headers => true
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => false
)
target 'MyAppTests' do
inherit! :complete
# Pods for testing
end
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
use_flipper!()
post_install do |installer|
react_native_post_install(installer)
# Uncomment if using a M1 Mac with XCode 12.5
# __apply_Xcode_12_5_M1_post_install_workaround(installer)
# target -> https://www.rubydoc.info/gems/xcodeproj/Xcodeproj/Project/Object/PBXNativeTarget
installer.pods_project.targets.each do |target|
case target.name
# Ignore RCT-Folly because it only works with 9.0 as a deployment target
when 'RCT-Folly'
next
else
# Explicitly set pods deployment target for each build config to app deployment target
target.build_configurations.each do |config|
current_pod_target = config.build_settings['IPHONEOS_DEPLOYMENT_TARGET']
pod_ios_deployment_target = Gem::Version.new(current_pod_target)
if pod_ios_deployment_target <= deployment_target
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
end
end
end
end
Package Versions
From my package.json:
...
"#nozbe/watermelondb": "^0.24.0",
"react-native": "0.67.2",
...
Update
After famfamfam's Comment I tried building with Xcode (Until now I tried using the integrated terminal of VS Code) and there I receive a similar yet different error message (See Image):
Any advice on how to debug and/or fix this will be highly appreciated
I've iOS framework which is exported as .framework and uploaded to the GitHub private repository. This iOS framework has internal dependency of aws3. I've .podspec also created and added in GitHub.
While I try to add this framework as dependency using Cocoapods in native iOS application, everything works as expected.
According to new requirement we've , we should use this framework API's in our react native project. If I simply (for testing purposes) add this framework dependency in the podfile of the rect native generated iOS folder, and run pod install, everything works as expected. When I run the app, app crashed on the launch with message stating that **"AWSCore.framework/awscore" not found**.
Can someone please let me know if you have come across this issue and how did you resolve.
require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")
require File.join(File.dirname(`node --print "require.resolve('#react-native-community/cli-platform-ios/package.json')"`), "native_modules")
require 'json'
podfile_properties = JSON.parse(File.read(File.join(__dir__, 'Podfile.properties.json'))) rescue {}
platform :ios, podfile_properties['ios.deploymentTarget'] || '14.0'
install! 'cocoapods',
:deterministic_uuids => false
target 'newReactNative' do
use_expo_modules!
config = use_native_modules!
use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']
# Flags change depending on the env values.
flags = get_default_flags()
use_react_native!(
:path => config[:reactNativePath],
:hermes_enabled => flags[:hermes_enabled] || podfile_properties['expo.jsEngine'] == 'hermes',
:fabric_enabled => flags[:fabric_enabled],
# An absolute path to your application root.
:app_path => "#{Dir.pwd}/.."
)
# Uncomment to opt-in to using Flipper
# Note that if you have use_frameworks! enabled, Flipper will not work
#
# if !ENV['CI']
# use_flipper!()
# end
pod 'CustomPod', :git => 'url', :tag => 'tagNum'
post_install do |installer|
react_native_post_install(installer)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
# This is necessary for Xcode 14, because it signs resource bundles by default
# when building for devices.
installer.target_installation_results.pod_target_installation_results
.each do |pod_name, target_installation_result|
target_installation_result.resource_bundle_targets.each do |resource_bundle_target|
resource_bundle_target.build_configurations.each do |config|
config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
end
end
end
end
post_integrate do |installer|
begin
expo_patch_react_imports!(installer)
rescue => e
Pod::UI.warn e
end
end
end
I'm currently trying to add OneSignal to my react native expo (bare) IOS build and have followed OneSignal's guide as shown here: https://documentation.onesignal.com/docs/react-native-sdk-setup
However, Xcode has flagged up a compiler error of: No such module 'OneSignal'
Here is my Podfile that includes the OneSignalXCFramework import:
require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")
require File.join(File.dirname(`node --print "require.resolve('#react-native-community/cli-platform-ios/package.json')"`), "native_modules")
platform :ios, '12.0'
require 'json'
podfile_properties = JSON.parse(File.read('./Podfile.properties.json')) rescue {}
target '<NAME>' do
use_expo_modules!
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
:hermes_enabled => podfile_properties['expo.jsEngine'] == 'hermes'
)
# Uncomment to opt-in to using Flipper
#
# if !ENV['CI']
# use_flipper!('Flipper' => '0.75.1', 'Flipper-Folly' => '2.5.3', 'Flipper-RSocket' => '1.3.1')
# end
post_install do |installer|
react_native_post_install(installer)
# Workaround `Cycle inside FBReactNativeSpec` error for react-native 0.64
# Reference: https://github.com/software-mansion/react-native-screens/issues/842#issuecomment-812543933
installer.pods_project.targets.each do |target|
if (target.name&.eql?('FBReactNativeSpec'))
target.build_phases.each do |build_phase|
if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs'))
target.build_phases.move(build_phase, 0)
end
end
end
end
target.build_configurations.each do |config|
# some older pods don't support some architectures, anything over iOS 11 resolves that
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
end
end
post_integrate do |installer|
begin
expo_patch_react_imports!(installer)
rescue => e
Pod::UI.warn e
end
end
end
target 'OneSignalNotificationServiceExtension' do
pod 'OneSignalXCFramework', '>= 3.0', '< 4.0'
end
As a side note, I've already tried to add pod 'OneSignal' or use_frameworks! into the PodFile. Has anyone else experienced this issue before?
Xcode 14.0.1 update & Swift 5.7 - Using SPM(Swift Package Manager)
Recently I have integrated one signal into my project using SPM. it worked fine until I tried to upload the build to app store connect and it started showing me the same error. Here's how I fixed this issue.
Step 1:
Removed the one signal dependency
Step 2:
added again one signal Notification framework as a dependency.
On the Choose package products popup.
Select OneSignal to add to the project as a target.
Select OneSignalExtension to be added to the oneSignalNotificationService extension as a target.
Now go to "NotificationService.swift" file in OneSignalNotificationExtension and replace > import Onesignal with >import OneSignalExtension.
Also replace oneSignal in code with OneSignalExtension.
Add Package and build.
i have this Error . RCTConvert+AirMap.h file not found Error on React Native on IOS
I was able to fix this with:
Adding $(SRCROOT)/../node_modules/react-native-maps/lib/ios/AirMaps in the project target header
Moving the pod 'react-native-google-maps', path: rn_maps_path above use_native_modules (it was previously below that) in the Podfile
Added:
post_install do |installer|
//...
installer.pods_project.targets.each do |target|
if target.name == 'react-native-google-maps'
target.build_configurations.each do |config|
config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
end
end
end
end
after step 3 if still not working remove all the cache
(pod deintegrate, pod install, remove derived data, clean build)
Latest Update
For config similar or latest
"react": "17.0.1",
"react-native": "0.64.2",
"react-native-cli": "^2.0.1",
"react-native-maps": "^0.28.0",
Its pretty much easier to configure React Native Maps using GoogleMap and other map providers.
Auto-linking does not solve the problem so you will have to manually tell xcode where the native code is.
There are 2 ways to tell
Manually add files/folders to Xcode using these instructions here
The Simplest. No need to goto Xcode for tweaking header search path
2. Simplest
# Podfile
pod 'react-native-google-maps', :path => '../../../node_modules/react-native-maps/'
pod 'react-native-maps', :path => '../../../node_modules/react-native-maps/'
# These might not be necessary
# Please build without these. If could not build, add these as well
pod 'GoogleMaps'
pod 'Google-Maps-iOS-Utils'
in AppDelegate.m file
#import <FlipperKitReactPlugin/FlipperKitReactPlugin.h> // this line is alreaady there. Add the line below
#import <GoogleMaps/GoogleMaps.h>
...
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions // this line is alreaady there. Add the line below
{
+ [GMSServices provideAPIKey:#"AIzaEEBBLn-PhCDDD1AnC_h66yH8LEEUkd14WW0"]; // add this line using the api key obtained from Google Console
Notes:
replace AIzaEEBBLn-PhCDDD1AnC_h66yH8LEEUkd14WW0 with your own API Key from google console.
In my case I am using monorepo technique so '../../../node_modules/react-native-maps/'. In your case its '../node_modules/react-native-maps/'
+ and - sign should be used. They are language defined entities. No type error
this is due to the static framework using. you need some changing in your podfile. here is the pod file for react-native 0.70.6
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/#react-native-community/cli-platform-ios/native_modules'
platform :ios, '13.0'
install! 'cocoapods', :deterministic_uuids => false
production = ENV["PRODUCTION"] == "1"
pod 'Google-Mobile-Ads-SDK' ,"9.12.0"
pod 'GoogleMobileAdsMediationFacebook','6.11.0.0'
pod 'GoogleMaps'
pod 'Google-Maps-iOS-Utils'
target 'myApp' do
config = use_native_modules!
$static_framework = []
$RNFirebaseAsStaticFramework = true
$RNGoogleMobileAdsAsStaticFramework = true
$RNAdMobAsStaticFramework = true
$FirebaseSDKVersion = '10.2.0'
use_frameworks! :linkage => :static
pre_install do |installer|
Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
installer.pod_targets.each do |pod|
if pod.name.eql?('RNPermissions') || pod.name.start_with?('Permission-')
def pod.build_type;
# Uncomment the line corresponding to your CocoaPods version
Pod::BuildType.static_library # >= 1.9
# Pod::Target::BuildType.static_library # < 1.9
end
end
end
end
# Flags change depending on the env values.
flags = get_default_flags()
use_react_native!(
:path => config[:reactNativePath],
# Hermes is now enabled by default. Disable by setting this flag to false.
# Upcoming versions of React Native may rely on get_default_flags(), but
# we make it explicit here to aid in the React Native upgrade process.
:hermes_enabled => true,
:fabric_enabled => flags[:fabric_enabled],
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
# :flipper_configuration => FlipperConfiguration.enabled,
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
$static_framework += [
'react-native-maps',
'react-native-google-maps',
'Google-Maps-iOS-Utils',
'GoogleMaps',
'RNFirebaseAsStaticFramework',
'RNGoogleMobileAdsAsStaticFramework',
'RNAdMobAsStaticFramework'
]
permissions_path = '../node_modules/react-native-permissions/ios'
pod 'Permission-Camera', :path => "#{permissions_path}/Camera"
pod 'Permission-Contacts', :path => "#{permissions_path}/Contacts"
pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary"
pod 'Permission-PhotoLibraryAddOnly', :path => "#{permissions_path}/PhotoLibraryAddOnly"
pod 'react-native-google-maps', :path => '../node_modules/react-native-maps'
target 'myAppTest' do
inherit! :complete
# Pods for testing
end
# ****** THIS IS THE MAGIC ******
pre_install do |installer|
Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
installer.pod_targets.each do |pod|
if $static_framework.include?(pod.name)
def pod.build_type;
Pod::BuildType.static_library # >= 1.9
end
end
end
end
# ****** THIS IS THE MAGIC ENDED ******
post_install do |installer|
react_native_post_install(installer)
#############
installer.pods_project.targets.each do |target|
### Added for Maps
if target.name == 'RCT-Folly'
target.build_configurations.each do |config|
config.build_settings['HEADER_SEARCH_PATHS'] = "$(inherited) ${PODS_ROOT}/fmt/include"
end
end
#### Added For Maps Ended
if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle"
target.build_configurations.each do |config|
config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
# config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "i386 arm64"
end
end
end
############
# __apply_Xcode_12_5_M1_post_install_workaround(installer) # comment for maps
## there two linesare added for maps
installer.pods_project.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
end
end
Additional statements need to be added to Podfile:
# Podfile:
...
# Platform should be at least 13.0
platform :ios, '13.0'
...
# add the following 2 statements
pod 'GoogleMaps'
pod 'Google-Maps-iOS-Utils'
target 'casualjob' do
# add the following 2 statements (if not present)
rn_maps_path = '../node_modules/react-native-maps'
pod 'react-native-google-maps', :path => rn_maps_path
....
post_install do |installer|
...
# add the following section
installer.pods_project.targets.each do |target|
if target.name == 'react-native-google-maps'
target.build_configurations.each do |config|
config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
end
end
end
...
end
Additional statements need to be added to AppDelegate.mm:
// AppDelegate.mm
...
#import "AppDelegate.h"
...
// Add the following statement (if not present)
#import <GoogleMaps/GoogleMaps.h>
...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// add the following statement (if not present)
// Replace YOUR_API_KEY below with your project's Google API Key
[GMSServices provideAPIKey:#"YOUR_API_KEY"];
...
}
...
For the configuration:
"react": "18.1.0",
"react-native": "0.70.1",
"react-native-maps": "^1.3.2",