Reputation: 741
I'm trying to integrate OneSignal SDK in Xcode 7.2.1 with CocoaPods 1.0.0.beta.2 and use_frameworks!
directive.
When I try to import the framework in AppDelegate.swift I get
No such module 'OneSignal'.
I also have other frameworks included from Cocoapods which work with no problem (ex: Fabric)
I managed to install OneSignal SDK with cocoapods in another project, but without the use_frameworks!
directive. I used the bridging header.
Upvotes: 26
Views: 31857
Reputation: 2037
I was encountering the same issue while running my project in Xcode. I managed to resolve it by modifying my project.pbxproj file. I added the following lines:
"ARCHS[sdk=iphonesimulator*]" = x86_64;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 i386";
Upvotes: 0
Reputation: 2180
If you have already pod the file before starting development OneSignal, you need to add new target for OneSignalNotificationServiceExtension.
target 'OneSignalNotificationServiceExtension' do
# Comment the next line if you're not using Swift
use_frameworks!
# Pods for OneSignalNotificationServiceExtension
pod 'OneSignal', '>= 2.5.2', '< 3.0'
end
After the adding above code to the podfile. You must "pod install" one again.
Upvotes: 7
Reputation: 61
target 'OneSignalNotificationServiceExtension' do
use_frameworks!
pod 'OneSignalXCFramework', '>= 2.5.2', '< 6.0'
end
while adding your code into the podfile make sure to check the compatibility with your dependency in the pubspec.yaml file.
Upvotes: 0
Reputation: 21345
With OneSignal 5.0.0
(on Flutter) I had to use:
import OneSignalFramework
instead of
import OneSignal
Upvotes: 20
Reputation: 656
try this out: Go to Product > Schemes > New Scheme... Select the name of your Cocoapod then click OK. After you do this, build the project.
Upvotes: 0
Reputation: 8767
You need to type these commands. It has fixed it for me:
$ pod deintegrate
$ pod install
My Podfile:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'Your_Project_Name' do
# Comment the next line if you don't want to use dynamic frameworks
# Pods for Das Gedenken
pod 'OneSignal'
end
target 'OneSignalNotificationServiceExtension' do
#only copy below line
pod 'OneSignal'
end
Upvotes: 12
Reputation: 57
BUILDING(CMD+B) the project immediately after installing the pods before start using the pod helps. And also we have to clear all the error before start using the pods.
Upvotes: -1
Reputation: 48522
EDIT
Is OneSignal cocoapod written in Swift or not? Do I need use_frameworks!
or bridging header? What works in Xcode 8.2.1, Swift 3 and OneSignal (1.11.3) ?
import OneSignal
to AppDelegate.swift
actually didn't work for meuse_frameworks!
is of no help in this specific situationUse this bridging header (†):
#import "OneSignal/OneSignal.h"
In the App Delegate:
func application(_ application: UIApplication, didFinishLaunchingWithOptions
launchOptions: [UIApplicationLaunchOptionsKey: Any]?)
-> Bool {
_ = OneSignal.init(launchOptions: launchOptions,
appId: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
...
}
Upvotes: 1
Reputation: 48185
Another thing to mention is that Getting error "No such module" using Xcode, but the framework is there
If the framework header is already included in the bridging header file then you don't have to import it in the Swift source file.
Upvotes: 1
Reputation: 1946
Pods written in Swift can be imported with the use_frameworks!
, and CocoaPods will complain if you don't do this and try to import the pods in Swift code.
Although any pods not written in Swift, will require the use of a bridging header.
Referencing to the OneSignal pod, the getting-started guide instructs applications using Swift to include a bridging header in order to use the pod. OneSignal: Getting Started Guide
Upvotes: 14