Using a Notification Extension causes issue with Cocoapods - ios

I have a Notification Extension in my app. However, when I build my app it conflicts with the pod FBSDKLoginKit. It gives me the following error in the FBSDKCoreKit:
'sharedApplication' is unavailable: not available on iOS (App Extension) - Use view controller based solutions where appropriate instead.
My Podfile looks like this (I've missed out irrelevant pods):
workspace 'MyApp'
platform :ios, '10.0'
target 'MyApp' do
use_frameworks!
project 'MyApp.xcodeproj'
pod 'FBSDKLoginKit'
pod 'OneSignal', '>= 2.6.2', '< 3.0'
target 'OneSignalNotificationServiceExtension' do
pod 'OneSignal', '>= 2.6.2', '< 3.0'
end
end
How do I fix this?

Move your OneSignalNotificationServiceExtension target out of your main target in your Podfile. Don't forget to also define use_frameworks! in it!
workspace 'MyApp'
platform :ios, '10.0'
target 'MyApp' do
use_frameworks!
project 'MyApp.xcodeproj'
pod 'FBSDKLoginKit'
pod 'OneSignal', '>= 2.6.2', '< 3.0'
end
target 'OneSignalNotificationServiceExtension' do
use_frameworks!
pod 'OneSignal', '>= 2.6.2', '< 3.0'
end
pod install, Clean and Build and that should do the trick 👍

Related

library not found for -lPods- Error while running iOS Code

I am running .xcworkspace file on xcode and I am getting the following error:-
library not found for -lPods-
This is my Podfile:-
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target '' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
# use_frameworks!
# Pods for
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/DynamicLinks'
pod 'GoogleSignIn', '~> 5.0'
pod 'OneSignal', '>= 2.6.2', '< 3.0'
pod 'TPKeyboardAvoiding'
pod 'FBSDKCoreKit', '~> 5.5.0'
pod 'FBSDKLoginKit', '~> 5.5.0'
pod 'Phone-Country-Code-and-Flags'
pod 'ListPlaceholder'
pod 'Shimmer'
end
target '' do
pod 'OneSignal', '>= 2.6.2', '< 3.0'
end
Any help would be highly appreciated! Thanks:)
Try Build Active Architecture Only" = YES and run the pod install

Too many errors after updating to Cocoapods 1.0

Good afternoon,
After updating to the latest version of Cocoapods (1.0) my iOS application shows a lot of errors. I'm not sure why is this happening because during the update everything was correct, but when I "Run" my app, it shows the following errors:
And that's my Podfile:
# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
# Uncomment this line if you're using Swift
use_frameworks!
target 'myApp' do
pod 'HanekeSwift', '~> 0.10'
pod 'Alamofire', '~> 3.3'
pod 'SwiftyJSON', '~> 2.3'
pod 'Batch', '~> 1.5'
end
target 'myAppTests' do
end
target 'myAppUITests' do
end
What can I do in order to solve those problems?
Much appreciated,
Regards.
If you ran pod install and its still not working.
Try pod deintegrate and then pod install. It should fix the issue.
If someone has the same problem, I have deleted the old Podfile and create a new one. And now that's how it looks like:
# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
target 'myApp' do
# Comment this line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for myApp
pod 'Alamofire', '~> 3.4'
pod 'SwiftyJSON', '~> 2.3'
pod 'HanekeSwift', '~> 0.10'
pod 'Batch', '~> 1.5'
target 'myAppTests' do
inherit! :search_paths
# Pods for testing
end
target 'myAppUITests' do
inherit! :search_paths
# Pods for testing
end
end

cocoapds ld: framework not found Pods_Target

I can compile the target with debug configuration, but when change to release configuration, it failed with error:
ld: framework not found Pods_MyTarget
this is the pod file:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'Alamofire', '~> 3.0'
pod 'SnapKit', '~> 0.15.0'
pod 'ObjectMapper', '~> 0.19'
pod 'Nuke'
pod 'Nuke-Alamofire-Plugin'
pod 'RESideMenu', '~> 4.0.7'
pod 'XCGLogger', '~> 3.0'
pod 'MBProgressHUD', '~> 0.9.1'
pod 'TTTAttributedLabel'
pod 'UIColor_Hex_Swift', '~> 1.4'
pod 'RxSwift', '~> 2.0.0-beta'
pod 'RxCocoa', '~> 2.0.0-beta'
pod 'RxBlocking', '~> 2.0.0-beta'
I have seen this bug many a times. I do the below workaround, this may not be the right fix.
Go to Project settings and change "Build Active Architecture Only" to "NO".
I found that I have to change the pod file to something like this:
link_with 'xxx'
target xxx do
pod xxxxxx
end
and then delete some files generated by pod manually, seems pod cannot delete them, such as the xcconfig, framework, .etc
then run 'pod install'
it works.

Archive build with split pods across app and watchkit extension

I have been unable to get Cocoapods to build a deployable iOS app that requires different pods for the app and the watchkit extension. I have tried a format suggested in another thread: Include pods in main target and not in WatchKit extension
but it has numerous failures, including not finding headers. Here's the closest I can get:
source 'https://github.com/CocoaPods/Specs.git'
link_with 'RailTime-WatchKit-Extension'
pod 'Reachability'
pod 'IGInterfaceDataTable'
target :'RailTime', :exclusive=>true do
pod 'ASIHTTPRequest', '~> 1.8.2'
pod 'BPXLUUIDHandler', '~> 0.0.1'
pod 'MBProgressHUD', '~> 0.9'
pod 'Appirater', '~> 2.0.4'
end
This works fine for the simulator, but fails when trying to install on a device. The first error is:
ld: library not found for -lPods-RailTime-WatchKit-Extension
I'm using the latest Cocoapods right now .37. No errors are generated when performing a pod install.
Any help would be greatly appreciated!
Ken
Here's the general format that I use for my WatchKit app. See if this helps:
source 'https://github.com/CocoaPods/Specs.git'
target 'RailTime-WatchKit-Extension' do
link_with 'RailTime-WatchKit-Extension'
pod 'Reachability'
pod 'IGInterfaceDataTable'
end
target :'RailTime' do
link_with 'RailTime'
pod 'ASIHTTPRequest', '~> 1.8.2'
pod 'BPXLUUIDHandler', '~> 0.0.1'
pod 'MBProgressHUD', '~> 0.9'
pod 'Appirater', '~> 2.0.4'
end
OK, the solution was quite simple, even though I'm not sure why it worked. As suggested in another thread, I did a 'pod init', which now creates a template that is knowledgable about the multiple targets. I then just filled it in! Here's what I have now:
platform :ios, '8.2'
source 'https://github.com/CocoaPods/Specs.git'
target 'RailTime' do
pod 'Reachability'
pod 'ASIHTTPRequest', '~> 1.8.2'
pod 'BPXLUUIDHandler', '~> 0.0.1'
pod 'MBProgressHUD', '~> 0.9'
pod 'Appirater', '~> 2.0.4'
end
target 'RailTime-WatchKit-Extension' do
pod 'Reachability'
pod 'IGInterfaceDataTable'
end
target 'RailTime-WatchKit-App' do
end

Building errors after updating CocoaPods libraries

I'm working on a legacy iOS project as a newbie. After I updated the CocoaPods and libraries, I've got these weird errors after building the project which never happen before.
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: can't locate file for: -lPods-Model
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: file: -lPods-Model is not an object file (not allowed in a library)
And here is my Podfile:
platform :ios, '7.0'
link_with ['DianaViewModels']
pod 'AVOSCloud', '~> 3.0'
pod 'PixateFreestyle'
target :Model do
link_with ['DianaModels']
pod 'ReactiveCocoa', '~> 2.2'
pod 'TMCache', '~> 1.2'
pod 'SSKeychain', '~> 1.2'
pod 'Mantle', '~> 1.3'
pod 'AFNetworking', '~> 1.0'
end
target :Test do
link_with ['DianaTests']
pod 'Kiwi', '~> 2.2'
end
target :View do
link_with ['Diana']
pod 'SVPullToRefresh', '~> 0.4'
pod 'MBProgressHUD', '~> 0.7'
pod 'SWTableViewCell', '~> 0.1'
pod 'MTMigration'
pod 'Masonry'
pod 'TTTAttributedLabel'
pod 'NJKWebViewProgress'
target :ViewDebug do
link_with [
'DianaDev',
'DianaViews'
]
pod 'Reveal-iOS-SDK'
end
end
By the way, I'm using the CocoaPods plugin in the Xcode. But a lot error are output when I check the Install Docs during integration:
Error opening xar archive: /var/folders/3x/mgl299js6k13tlrspqv21n340000gn/T/Model-ReactiveCocoa.xar
Are there some wrong configurations in my CocoaPods or Build Setting in Xcode6.3? Thanks for your help!
ADDED:
Here's my Link Binary With Libraries in the Build Phases. Does the red item mean something is wrong? It looks like this is the cause.

Resources