I want to build my Xcode project (react native & swift) for the simulator and on a real device.
The simulator worked great. Today I tried to build it for my device, I selected my device in the Xcode bar and added the scheme to release (I had to do this because I'm using react native and otherwise the bundle is not packed)
Then an error during the build occurs (in this case for the dependency RNPurchases, but this is completely random. sometimes it's Expo-Keep-Awake or Facebook)
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_RCPurchases", referenced from:
objc-class-ref in RNPurchases.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Even switching the back to Build Configuration Debug in my scheme has no effect anymore.
I already tried several things:
clear Xcode build
delete pod folder
remove pod cache
remove Xcode/DerivedData
reboot
nothing works.
This problem is pretty new to me, it already occurred twice within the last 2 months. Somehow I got the build for the simulator running again, but never for a device. I didn't have the problems like this half a year ago ...
My Setup
Xcode 12.4
MacBook Pro (Big Sur 11.2.3)
Build Settings for App-Target: Build Active Architectures Only: Debug YES, Release NO)
Build Settings for Pod-Target: Build Active Architectures Only: Debug YES, Release NO)
Podfile:
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/#react-native-community/cli-platform-ios/native_modules'
require_relative '../node_modules/react-native-unimodules/cocoapods.rb' # expo uni modules
use_frameworks!
install! 'cocoapods', :deterministic_uuids => false, :warn_for_unused_master_specs_repo => false
target 'TrainUrTeam' do
platform :ios, '12.0'
# ... pods xyz
use_unimodules!
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])
end
post_install do |installer| # src: https://stackoverflow.com/a/64139830/6003494
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings["ONLY_ACTIVE_ARCH"] = "YES"
end
end
end
After 2 weeks of googling I could finally find a working solution according to this Post adding this to the Podfile:
use_frameworks! :linkage => :static
If use_frameworks! :linkage => :static is not an option for you, you may try to use:
pre_install do |installer|
installer.pod_targets.each do |pod|
if pod.name.eql?('RNPurchases')
def pod.build_type;
Pod::BuildType.static_library # pods version >= 1.9
# Pod::Target::BuildType.static_library # pods version < 1.9
end
end
end
end
I got these errors and just restarted my macbook, clean, then build and they disappeared. Magic.
Go to xcode project -> Build setting -> Architecture -> Excluded
architecture -> (arm64)set
Try to build & run
Related
Currently I'm working on integrating the firebase cloud messaging service to a react native mobile application. I followed their documentation on firebase integration and edited the pod file to use frameworks.
When using the frameworks. I got an error about transitive dependencies. that's why I had to add pre install do and $static_framework.
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/#react-native-community/cli-platform-ios/native_modules'
platform :ios, '11.0'
$RNFirebaseAsStaticFramework = true
target 'P2PMobileApp' do
use_frameworks!
$static_framework = ['FlipperKit', 'Flipper', 'Flipper-Folly', 'CocoaAsyncSocket', 'ComponentKit', 'DoubleConversion', 'glog', 'Flipper-PeerTalk', 'Flipper-RSocket', 'Yoga', 'YogaKit', 'CocoaLibEvent', 'OpenSSL-Universal', 'boost-for-react-native']
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
end
end
end
end
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => false
)
pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
target 'P2PMobileAppTests' 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)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
end
Now I'm having following error when I try to run app with react-native run-ios
Undefined symbols for architecture x84_64:
"google::LogMessage::LogMessage(char const*, int, int)", referenced from:
__react_native_log_default in react_native_log.o
"google::LogMessageFatal::LogMessageFatal()", referenced from:
__react_native_log_default in react_native_log.o
...
Note: I have done my pod installation with arch -x86_64 pod install because I'm working on a mac mini with an M1 chip.
I tried to resolve that issue with the following solutions. But none of them worked out
Link binaries with xcode
Changing the architecture
Change the architecture for pod installation (Then I get the same issue related to arm64)
Removing glog from $static_framwork variable (Then the same Undefined symbols for architecture x84_64: issue arises for double conversion module)
Still I,m stuck with build fails. Any help on this will be highly appreciated.
If you are using M1 chip then it can be resolved with below steps:
Go to application > right click on Xcode > Get info > select Open using Rosetta
Restart the system
The other solution can be adding library
You can add it by:
Clicking on your project in the upper left of the left pane (the blue
icon).
In the middle pane, click on the Build Phases tab.
Under "Link Binary With Libraries", click on the plus button.
Find YOUR_FRAMEFOERK.framework from the list and hit Add.
I keep getting the following error from multiple pods when building my react native project in xcode. Some example pods include RNKeychain and RNSVG. Here’s an example from react-native-blur:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_RCTViewManager", referenced from:
_OBJC_CLASS_$_BlurViewManager in BlurViewManager.o
_OBJC_CLASS_$_VibrancyViewManager in VibrancyViewManager.o
I noticed some warnings about iOS versions such as 'UIBlurEffectStyleSystemChromeMaterial' is only available on iOS 13.0 or newer.
Digging into xcode, for some reason the "General -> Deployment Info" for each pod is set to iOS 11.0 but in my Podfile I have explicitly set the deployment target to platform :ios, '13.0'. It's widely accepted as the solution to add a post_install script to overwrite the deployment target of each individual pod, which I've done. See my Podfile below.
$RNFirebaseAsStaticFramework = true
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'
target 'Foo' do
use_frameworks!
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => false
)
target 'FooTests' do
inherit! :complete
# Pods for testing
end
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
react_native_post_install(installer)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
end
end
I can fix the issue by manually adjusting the deployment target in xcode for each offending pod which complains with the error Undefined symbols for architecture x86_64:
What else could be overwriting the deployment info to ios 11.0? In case it's relevant using "react-native": "0.66.1",
The most infuriating thing is that every time I do pod install I have to manually tweak deployment info for each affected pod.
I'm trying to build an IOS project on Xcode 12.5.
There is no problem when the real device is connected or when I try to build with the simulator. But I get this error when Any IOS Device is selected. Any IOS Device is selected to archive my project and I get an error message while archiving.
I have changed the'Build Active Arch. Only' and 'Excluded Architecture' settings many times, but the problem has not been resolved.
please help me with this problem..
Problem solved when I changed it to IOS Deployment Target 12.0
Build Active Architecture Only selected as yes.
Looking at this screenshot -
The issue is Undefined symbols for architecture armv7.
Can you go to Build Settings of your
project
app target
all of the pod targets if you use pods
search for armv7 and delete it if it exists?
After this, do a Product > Clean Build Folder & now try running/building the app.
In my case i use this solution and it's worked for me.
Add this given below code into your podfile at the bottom and run "pod install" command. And Good to go.
At this point '12.0' You can change accordingly. Based upon your project. For exmp: '11.0' or '10.0' like this. It should be match with the platform: ios, '12.0' this line in your podfile at the Second position.
In my case
Exmp: platform: ios, '12.0' so config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'. So 12.0 matched in both.
post_install do |installer|
installer.pods_project.targets.each do |target|
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
end
I had the same error in my project. I use Xcode 13.3.1.
So I updated my Podfile with next way(was added excluded arch and deployment target):
$iOSVersion = '13.1'
platform :ios, $iOSVersion
use_frameworks!
def general_pods
pod 'Some_pods_here'
end
target 'Some_target1' do
general_pods
pod 'Some_pod_here'
end
target 'Some_target2' do
general_pods
pod 'some_pod_here'
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings["ONLY_ACTIVE_ARCH"] = "YES"
config.build_settings["EXCLUDED_ARCHS[sdk=*]"] = "armv7"
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = $iOSVersion
end
end
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if Gem::Version.new($iOSVersion) > Gem::Version.new(config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'])
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = $iOSVersion
end
end
end
end
I am getting this error when I run my flutter project in iOS simulator:
warning: [CP] Unable to find matching .xcframework slice in myProject/ios/Pods/FirebaseFirestore/FirebaseFirestore/abseil.xcframework abseil framework ios-i386_x86_64-simulator ios-x86_64-maccatalyst ios-armv7_arm64' for the current build architectures (arm64 x86_64 i386).
In android emulator and iOS device it's working fine.
Worked for me:
rm ios/Podfile
Then upgrade your packages:
flutter pub upgrade
And update your podfile:
cd ios && pod update
Then clean and run:
flutter clean && flutter run
In order to fix that issue I was needed to set "Build Active Architecture Only (ONLY_ACTIVE_ARCH)" to Yes for the library. You can do that manually but changes will be lost once you re-run pod install.
In order to set that automatically you can make necessary changes in your ios/Podfile, here's code example:
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
config.build_settings["ONLY_ACTIVE_ARCH"] = "YES"
end
end
end
This was inspired by another answer, you can find more info if you need by following that link https://stackoverflow.com/a/64139830/1078641
My team recently started to employ CocoaPods to manage dependency in our iOS app project.
Here's the podfile:
platform :ios, '6.0'
pod "UI7Kit"
pod "AFNetworking", "~> 2.0"
pod "TMCache"
pod "SVProgressHUD"
pod "SVPullToRefresh"
However, after using CocoaPods, building targets for iPhone 5 always fails, but succeeds for simulator.
Here's the error log:
ld: warning: ignoring file [DerivedData directory]/libPods.a, file was built for archive which is not the architecture being linked (armv7): [DerivedData directory]/libPods.a
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_SVProgressHUD", referenced from:
objc-class-ref in ....o
"_OBJC_CLASS_$_TMCache", referenced from:
objc-class-ref in ....o
"_OBJC_CLASS_$_UI7Kit", referenced from:
objc-class-ref in ....o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've tried solutions mentioned in CocoaPods Troubleshooting, including adding the Pods static library on top of the list, but it still fails.
Later we found that in "Pods Project Settings" > "Build Settings" > "Architectures", "Base SDK" is set as "No SDK (Latest OS X)", "Build Active Architecture Only" > "Debug" set as "Yes" and "Supported Platforms" set as "OS X". After changing them to "Latest iOS (iOS 7.0)", "No", "iOS" respectively, building for iPhone 5 and simulator both work fine.
However, each time we do Pod update, all of the three settings are reverted to their previous states, which is annoying.
My questions are:
Is this case by design or something is wrong with my project/workspace setting?
How to prevent these settings from being reverted to the wrong states?
Any help will be appreciated.
As mentioned in CocoaPods issues, you can append this to your Podfile:
post_install do |installer_representation|
installer_representation.project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
end
end
end
This will make all pods build for all arch.
I used to follow that procedure... now with cocoapods and more hours into the matter I opted for :
# fixes required for xcode project
post_install do |installer_representation|
puts ""
puts "Updating VALID_ARCHS, SUPPORTED_PLATFORMS, SDKROOT for the project..."
installer_representation.pods_project.build_configurations.each do |config|
# config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
config.build_settings['VALID_ARCHS'] = 'arm64 armv7 armv7s'
config.build_settings['SUPPORTED_PLATFORMS'] = 'iphonesimulator iphoneos'
# setting the base SDK of the project to match that of the project,
# otherwise it defaults to No SDK (Latest OS X)"
config.build_settings['SDKROOT'] = 'iphoneos'
# it sets 'Valid Architectures' to '$(ARCHS_STANDARD)' to all pods
# config.build_settings['SDKROOT'] = projectSDK
end
puts ""
puts "Updating all of the watch POD targets with specific..."
installer_representation.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if (config.build_settings['SDKROOT'] == 'watchos')
puts "fixing SUPPORTED_PLATFORMS & VALID_ARCHS for #{target.name} #{config.name}"
config.build_settings['SUPPORTED_PLATFORMS'] = 'watchsimulator watchos'
config.build_settings['VALID_ARCHS'] = 'arm64 armv7 armv7s armv7k i386'
end
# to not default to ONLY_ACTIVE_ARCH for debug"
# config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
# config.build_settings['ENABLE_STRICT_OBJC_MSGSEND'] = "NO"
end
end
puts ""
end
I found myself running into this situation as well, using Cocoapods 0.36.3 and Xcode 6.2. I highly doubt that this is the best solution, but I wrote a hook to go at the bottom of my Podfile that resets the "BaseSDK", "Platform", and "Build Active Architecture Only" settings in the Pods project. I also set "Build Active Architecture Only" to "NO" for each of the targets, for good measure (as mentioned in the above post).
post_install do |installer_representation|
projectSDK = nil
puts"Updating all of the POD targets to not default to ONLY_ACTIVE_ARCH for debug"
installer_representation.project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
if projectSDK.nil?
projectSDK = config.build_settings['SDKROOT']
end
end
end
puts "Updating ONLY_ACTIVE_ARCH for the project, as well. While the project settings aren't supposed to matter, I've not found that to be the case."
puts "Also setting the base SDK of the project to match that of the targets (doesn't matter which one); otherwise it defaults to No SDK (Latest OS X)"
installer_representation.project.build_configurations.each do |config|
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
config.build_settings['SDKROOT'] = projectSDK
end
end
For anyone using latest Cocoa pods
post_install do |installer_representation|
installer_representation.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
end
end
end
The Pods Project settings don't matter, what is important are the Target settings for the Pod static lib. But you shouldn't have to touch them.
Can you post your build settings from your project/target?
The Troubleshooting guide suggests some build settings in case of failed build, do they help? Be sure to enable to show all build settings and check if some settings override those specified in the xcconfig file that CocoaPods generated.
Also check that your project is based on the xcconfig file in in the project's Info tab.
I hope something of this helps.