I am trying to implement Stripe Payment Gateway in my iOS application. Which is on Xcode 8.2 with 10.2 simulator.
My application Build getting successful. But after building it, It says.
dyld: Library not loaded: #rpath/Stripe.framework/Stripe
Referenced from:
/Users/user/Library/Developer/CoreSimulator/Devices/D27A4EC3-3B8A-4BBC-AB30-E9313AD95E1E/data/Containers/Bundle/Application/225274C8-EB99-476A-88A3-6F9981948220/Test App.app/Test App
Reason: image not found
Here is Bit of Code
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
registerForPushNotifications(application)
spinnerInitialization();
//STRIPE CONFIGURATION
Stripe.setDefaultPublishableKey("pk_test_YdACg6uENGmWrSWwAy00gWUx")
return true
}
Go to project select General and add your framework to Embedded Binaries section
Related
I am developing an App that uses Firestore. The app runs fine on the Xcode simulator, but crashes when I try to run it on my phone. I get the following error message:
*** Terminating app due to uncaught exception 'FIRIllegalStateException', reason: 'Failed to get FirebaseApp
instance. Please call FirebaseApp.configure() before using Firestore'
I do call FirebaseApp.configure() in the didFinishLaunchingWithOptions:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FirebaseApp.configure()
return true
}
I don't understand why it would run in the simulator and not on my phone. Any help would be appreciated.
Check your podfile for how you add the firebase cocoapods, It should be like this,
pod 'FirebaseCore'
pod 'Firebase/Messaging'
If your podfile different ,please remove old firebase related pods,insert this and install.
I discovered, on a Japanese code forum, what to do. I added the following code to the AppDelegate.swift file:
var window: UIWindow?
override init() { //初期化メソッドを追記
FirebaseApp.configure()
}
The app now runs both in the simulator and on my iPhone.
When iOS 13 released, I opted out of using the new SceneDelegate through the normal procedures.
- SceneDelegate.swift does no longer exist
- There are no Scene related methods in AppDelegate
- Application Scene Manifest is removed from .plist
This worked great, and is how I've been running since (iOS 11.0 target, Xcode 11.2.1).
Last week I ran a build with deployment target as 13.0, then swapped back to 11.0.
Since then, the application delegate methods are no longer being called, such as.
func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any])
The only thing that happens, that I can see is a log in console
Can't end BackgroundTask: no background task exists with identifier 15 (0xf), or it may have already been ended
I've triple checked all the settings above, but I can't get it to work like it used to.
The only thing that might be different is that the storyboards now defaults to 'automatic' (iOS 13.0, *) presentation mode, but I'm not sure how it was before.
Since automatic is only available from iOS 13+, it seems like something is messed up.
Does anyone have a clue?
Following up on the response in this thread:
applicationDidBecomeActive
applicationWillEnterForeground
etc are actually called.
I've tried cleaning the build, restarting Xcode, the mac, the device, clearing derived data etc.
So, I finally found the answer.
Turns out it's a good old
Instance Method Nearly Matches
func application(_ application: UIApplication, continue userActivity: NSUserActivity,
restorationHandler: #escaping ([UIUserActivityRestoring]?) -> Void) -> Bool
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool
That Xcode completely ignored to report, and somehow managed to break in between building for iOS 11 > iOS 13 > iOS 11.
It's also strange because I verified them a couple of days ago with the documentation, both Apples & Firebase, and there was no difference between them.
In the end, it works now, yay.
If you don't need want to use the SceneDelegate then add below property in the AppDelegate file.
var window: UIWindow?
Add this line above didFinishLaunchingWithOptions function
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
{
// Override point for customization after application launch.
return true
}
when I start my application from Xcode, the application works properly, but if I close and then open the app again, it goes into the background automatically without control. How can I fix this bug ?
There are some crash types those will not be happening when running the app via Xcode.
For example:
If the app launch takes too long, that app will be crashed. Basically it’s not a crash, but app needs to be launched quickly without delay which is expected by operating system.
So You need to make sure that you are not doing any heavy operations on Main Thread during app launch especially on below methods in AppDelegate
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
// Avoid heavy loads on main thread here
return true
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Avoid heavy loads on main thread here
return true
}
Also I received a crash a few years back when I tried to add an objective c struct to my NSObject class without allocating memory of struct variable. But this crash was unable to reproduce when I was running my app via Xcode and only happened when I launch the app without Xcode. So I made that struct variable as a pointer and did memory allocation as like (BoothStructure*)malloc(sizeof(BoothStructure) * count), after that there was no crash.
So please analyze your crash using crash logs as well and check if it meets any one of above scenario.
To check crash log of development build:
Open Xcode -> Connect your iOS device which has/had the crashed app -> Window -> Devices and Simulators -> View Device Logs
To check crash log of production build(you should add your developer account in Xcode that is used to publish your app):
Open Xcode -> Window -> Organizer -> Select your app from the list of apps -> Select crashes tab in segmented controller at top -> Select your build version.
I followed all the steps correctly to install Firebase to my iOS App and it still doesn't work. In the application method, I added FIRApp.configure() like so:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
FIRApp.configure()
return true
}
And I keep receiving NSException errors. Firebase seems to work on my Android Project, what's the deal with iOS?
I believe this is some sort of Swift 3 issue, because I encountered a similar problem. After looking over the internet, I believe that Firebase 3 hasn't updated to recent Swift Syntax located in Swift 3. Many other developers are having trouble with it as well. As an alternative, you could switch back from Xcode 8 and into 7, which would allow you to create your application which will work with current IOS, and when Firebase updates, it will be easy for you to migrate to Swift 3.
Hope this helps,
Morgan Gallant
I tried with CocoaPods and wound up with this issue after trying for hours and figured it was CocoaPods. Uninstalled CocoaPods and installed the SDK manually and wound up with the same issue.
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
{
GAI.sharedInstance().trackerWithTrackingId("UA-XXXX-Y");
return true
}
This results in the error Use of unresolved identifier "GAI". I have a bridging header that imports the appropriate header files and all the required libraries included in my Build Phases. Please help!
Apparently I just needed to clear my derived data and restart Xcode. Xcode sucks sometimes. Ha. Thank you Björn Ro.