Build target MyNotificationService: Framework not found - ios

I have a React Native app "MyApp" that has a "MyNotificationService" attached (i.e. NotificationService.appex embedded under the Frameworks, Libraries and Embedded Content in Xcode in target "MyApp").
Up until this point everything fine.
Now I want to add another pod to "MyApp" naming pod 'Google-Mobile-Ads-SDK', which does not have anything to do with MyNotificationService. I just want to install it, so I can access the Google-Mobile-Ads-SDK in "MyApp".
My Podfile looks like this
target 'MyApp' do
use_unimodules!
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
:hermes_enabled => false
)
# Additional Dependencies
...
pod 'Google-Mobile-Ads-SDK'
target 'MyNotificationService' do
use_native_modules!
inherit! :complete
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO'
# deletes each pods deployment target definition and instead uses the definition of the main project
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
end
end
However, after I ran pod install, I tried to build the debug version of MyApp using XCode, but XCode complains:
Build Target MyNotificationService
Link MyNotificationService (arm64)
Directory not found for option '-F/Users/.../Library/Developer/Xcode/DerivedData/MyApp-abcabcabcabcabc/Build/Products/Debug-iphoneos/XCFrameworkIntermediates/GoogleAppMeasurement'
Directory not found for option '-F/Users/.../Library/Developer/Xcode/DerivedData/MyApp-abcabcabcabcabc/Build/Products/Debug-iphoneos/XCFrameworkIntermediates/GoogleMobileAds'
Directory not found for option '-F/Users/.../Library/Developer/Xcode/DerivedData/MyApp-abcabcabcabcabc/Build/Products/Debug-iphoneos/XCFrameworkIntermediates/UserMessagingPlatform'
But MyNotificationService has nothing to do with these Frameworks GoogleAppMeasurement, GoogleMobileAds and UserMessagingPlatform - those belong to the Google-Mobile-Ads-SDK and only the main target MyApp should need them.
How can I tell MyNotificationService that it should not care about these frameworks?

Did solve the problem with an abstract target, that has both "MyApp" and "MyNotificationService" as subtargets defined in it. The abstract target is not an actual Xcode target but rather a placeholder or a folder that defines the pods that both the "MyApp" and "MyNotificationService" should both have shared. To get "MyNotificationService" ignore everything related to the 'Google-Mobile-Ads-SDK', the pod 'Google-Mobile-Ads-SDK' is only defined in the subtarget "MyApp".
abstract_target 'Shared' do
use_unimodules!
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
)
# Additional Dependencies
...
target 'MyApp' do
# no inherit statement means that target MyApp has all pods from the parent "Shared" accessible
pod 'Google-Mobile-Ads-SDK'
end
target 'MyNotificationService' do
# no inherit statement means that target MyNotificationService has all pods from the parent "Shared" accessible
use_native_modules!
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO'
# deletes each pods deployment target definition and instead uses the definition of the main project
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
end
end

Related

CocoaPods ignoring minimum deployment target (IPHONEOS_DEPLOYMENT_TARGET) in post_install hook

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.

No such module FirebaseStorage

I am working on an iOS project in swift 5 in Xcode 11.6 using cocoapods. Whenever I try to build it fails with the error message 'No Such Module FirebaseStorage'. I have tried deintegrating and installing several times. Below is the pod file I'm using. If I looking in the pods directory in the project folder, I can see a firebasestorage folder. I have also attached my header search path under the build settings for the workspace. header search path
Uncomment the next line to define a global platform for your project
platform :ios, '13.6'
#install! 'cocoapods', :disable_input_output_paths => true
target 'project' do
# use_modular_headers!
# Comment the next line if you don't want to use dynamic frameworks
# use_frameworks!
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'MessageKit'
pod 'Firebase/Firestore'
pod 'Firebase/Storage'
pod 'SDWebImage'
end
# Pods for project
target 'projectTests' do
inherit! :search_paths
# Pods for testing
end
target 'projectUITests' do
# Pods for testing
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if Gem::Version.new('8.0') >
Gem::Version.new(config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'])
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '8.0'
end
end
end
end
I was wondering what might be causing this issue?

Change target ios version when installing new pod

Whenever I install a new pod project, and for example I install firebase libraries I always get installed libraries to be targeted for projects 8.0 or and I start changing them manually to be 9.0 or 14.0 because of the warning that I'm Getting.
Here it is the Podfile content:
platform :ios, '14.0'
target 'TestProject' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
# Pods for TestProject
pod 'SDWebImageSwiftUI'
pod 'lottie-ios'
pod 'Firebase/Auth'
pod 'Firebase/Firestore'
end
How it is possible to update target iOS all at once, so I won't be updating all the libraries one by one?
Add this to your Podfile and then pod install.
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
end
end
end
This will update all the Pod targets at once to your desired version.
Depending on your Podfile, Warren's answer might not be enough to set all targets to the new deployment target. I recommend using this post-install handler:
deployment_target = '14.0'
post_install do |installer|
installer.generated_projects.each do |project|
project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = deployment_target
end
end
project.build_configurations.each do |bc|
bc.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = deployment_target
end
end
end
This addition becomes important when you use options like install! 'cocoapods', :generate_multiple_pod_projects => true

CocoaPod 1.9.3: How to resolve the APPLICATION_EXTENSION_API_ONLY warning?

I'm stuck with this and hope someone can help. How can I remove/resolve these warnings, please?
def shared_pods
pod 'SSZipArchive'
pod 'KeychainAccess'
pod 'SwiftyBeaver'
end
target 'myApp' do
platform :ios, '11.0'
use_frameworks!
shared_pods
pod 'IQKeyboardManagerSwift'
pod 'Firebase/Analytics'
pod 'Firebase/Crashlytics'
pod 'FacebookSDK/CoreKit'
pod 'FacebookSDK/ShareKit'
pod 'Google-Mobile-Ads-SDK'
pod 'GoogleMobileAdsMediationAdColony'
pod 'GoogleMobileAdsMediationIronSource'
pod 'OpenVPNAdapter', :git => 'https://github.com/ss-abramchuk/OpenVPNAdapter.git', :tag => '0.7.0'
target 'myAppTests' do
inherit! :search_paths
end
target 'myAppUITests' do
end
target 'tunnel-ios' do
pod 'OpenVPNAdapter', :git => 'https://github.com/ss-abramchuk/OpenVPNAdapter.git', :tag => '0.7.0'
end
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'No'
end
end
end
I'm getting these warnings:
[!] The `myApp [Debug]` target overrides the `APPLICATION_EXTENSION_API_ONLY` build setting defined in `Pods/Target Support Files/Pods-myApp/Pods-myApp.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `myApp [Release]` target overrides the `APPLICATION_EXTENSION_API_ONLY` build setting defined in `Pods/Target Support Files/Pods-myApp/Pods-myApp.release.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `myAppTests [Debug]` target overrides the `APPLICATION_EXTENSION_API_ONLY` build setting defined in `Pods/Target Support Files/Pods-myAppTests/Pods-myAppTests.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `myAppTests [Release]` target overrides the `APPLICATION_EXTENSION_API_ONLY` build setting defined in `Pods/Target Support Files/Pods-myAppTests/Pods-myAppTests.release.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
Based on https://github.com/CocoaPods/CocoaPods/issues/9233, it looks like you can override the APPLICATION_EXTENSION_API_ONLY setting via an xcconfig file instead of a post_install script to avoid the warning.

Set deployment target for CocoaPods's pod

I use CocoaPods to manage dependencies in my project. I've written Podfile:
target 'MyApp' do
platform :ios, '8.0'
# Uncomment this line if you're using Swift or would like to use dynamic frameworks
#use_frameworks!
# Pods for MyApp
pod 'KeepLayout', :git => 'https://github.com/iMartinKiss/KeepLayout', :tag => 'v1.6.0'
pod 'EasyMapping'
target 'MyAppTests' do
inherit! :search_paths
# Pods for testing
end
target 'MyAppUITests' do
inherit! :search_paths
# Pods for testing
end
end
This file works well with CocoaPods 0.x but I can't compile project after I've updated to CocoaPods 1.0. After I've run
pod update
I can't compile my project with error:
/Users/<...>/Pods/KeepLayout/Sources/KeepAttribute.m:195:1: Cannot synthesize weak property because the current deployment target does not support weak references
I've seen that every library is builded with different deployment target. For example KeepLayout is builded with 4.3 deployment target.
How I can determine build target for every pod dependency?
While some development versions of CocoaPods (as well as pre-1.0 versions) may have propagated the deployment target of the project down to the pods, this is no longer the case in 1.0. To work around this, the current developer recommends using a post-install hook.
Here's a brute force approach to force a hard-coded deployment target for every pod in the generated Pods project. Paste this at the end of your Podfile:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.2'
end
end
end
Since the Podfile uses a directive like platform :ios, '9.0' to specify "iOS Deployment Target" (aka IPHONEOS_DEPLOYMENT_TARGET) for the Pods/Pods.xcodeproj project, you just need to remove the Deployment Target info from each build target.
Do it by adding this to your Podfile
platform :ios, '9.0' # set IPHONEOS_DEPLOYMENT_TARGET for the pods project
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
end
Inspired by the github post and Alex Nauda's answer.
While the accepted answer by Alex Nauda is good, but letting the Pods inherit the target from the app might be a much better solution. 🚀
app_ios_deployment_target = Gem::Version.new('9.2') # Change to your current deployment target
platform :ios, app_ios_deployment_target.version
# Let Pods targets inherit deployment target from the app
# This solution is suggested here: https://github.com/CocoaPods/CocoaPods/issues/4859
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |configuration|
pod_ios_deployment_target = Gem::Version.new(configuration.build_settings['IPHONEOS_DEPLOYMENT_TARGET'])
if pod_ios_deployment_target <= app_ios_deployment_target
configuration.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
end
end
Here is the way to set deployment target permanently for pod targets.
Goto -> podfile -> Add below code
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = "12.0"
end
end
end
change target to "11.0"
platform :ios, '11.0'
1) Search for IPHONEOS_DEPLOYMENT_TARGET
2) Change the iOS Deployment Target

Resources