RevMob Integration for Swift - swift

**I have read the RevMob instructions for Swift and I have read an answer to an Swift-RevMob question on here, but it didn't resolve my particular issue. **
I am currently trying to get a fullscreen ad to show.
This is my GameViewController.swift:
verride func viewDidLoad() {
super.viewDidLoad()
//Start RevMob code
let completionBlock: () -> Void = {
// do something when it successfully starts the session
RevMobAds.session().showFullscreen();
}
let errorBlock: (NSError!) -> Void = {error in
// check the error
println(error);
}
RevMobAds.startSessionWithAppID("55770fcc17dd7840727aa5e8",
withSuccessHandler: completionBlock, andFailHandler: errorBlock);
//End of RevMob Code
I have defined the modules in my package as "Yes":
This is my Bridge-Header:
// Use this file to import your target's public headers that you would like to expose to Swift.
#import <RevMobAds/RevMobAds.h>
Lastly, this is the error that I am currently getting when I try to build my code:
Thanks if you can help!

CLBeaconRegion is part of Core Location from iOS 7 on, so you need to make sure the framework is linked in your project.
Note: in my experience, CLBeaconRegion is picked up by Apple as part of app review and they often want to know how you're using beacons – even if the code is just sitting there and you're not planning to use it.
Twice now I have been asked by app review to provide a video of my app detecting a beacon so they can see how it works, so either be prepared to explain your usage or see if there's a library version without it built in.

In addition to the required frameworks, you have to add CoreLocation.framework

I had the same issue. With CoreLocation.framework, also add AVFoundation.framework. Hope that helps

Related

NSSpeechSynthesizer get Siri voices on macOS

Is there a way to get the Siri voices for NSSpeechSynthesizer? NSSpeechSynthesizer.availableVoices() does not list them, but maybe there is an undocumented trick or something?
I've also tried to use AVSpeech​Synthesizer, even tough it should be available on macOS 10.14+, I couldn't get it to read out loud …
I've used a Playground to test this with the following code from NSHipster:
import Cocoa
import AVFoundation
let string = "Hello, World!"
let utterance = AVSpeechUtterance(string: string)
let synthesizer = AVSpeechSynthesizer()
synthesizer.speak(utterance)
Siri voice
I'm not aware of any trick to make the Siri voice available and I'm afraid it's impossible to make it working via public API.
Both NSSpeechSynthesizer and AVSpeechSynthesizer do utilize SpeechSynthesis.framework (included in the ApplicationServices.framework).
Quickly checked it and the function BuildDefaultVoiceList(bool) checks bundle identifier (via PermitAllVoices which compares it with com.apple.VoiceOverUtility, com.apple.VoiceOver, com.apple.VoiceOverUtilityCacheBuilder).
There're other checks probably.
All the voices are stored in the /System/Library/Speech/Voices folder. Tried to copy the voice, change Info.plist values to make it look like another voice, but still not available/working.
How far do you want to go? Do you want to disable SIP, modify framework, preload your stuff, ... Is it worth it?
AVSpeech​Synthesizer on macOS
It works, but it's buggy and you have to kill the service from time to time.
List of available voices
AVSpeechSynthesisVoice.speechVoices().forEach { voice in
print("Name: \(voice.name) Language: \(voice.language) Identifier: \(voice.identifier)")
}
Speak
let utterance = AVSpeechUtterance(string: "Ahoj, jak se máš?")
utterance.voice = AVSpeechSynthesisVoice(identifier: "com.apple.speech.synthesis.voice.zuzana.premium")
let synthesizer = AVSpeechSynthesizer()
synthesizer.speak(utterance)
Doesn't speak?
All the following methods (delegate) are called when you call speak(utterance) and it works as it should:
speechSynthesizer(_:didStart:)
speechSynthesizer(_:willSpeakRangeOfSpeechString:utterance:)
speechSynthesizer(_:didFinish:)
Something's wrong if you get just the speechSynthesizer(_:didCancel:) method call and you have to kill the speechsynthesisd process:
kill `pgrep speechsynthesisd`
Then try again, it fixes the issue for me.
Additional voices installation
System Preferences - Accessibility - Speech
System Voice - click & scroll down & select Customize...
Select additional voice to install

Tapping system alert using EarlGrey 2.0 & Swift

I'm trying to create UI tests for my app using EarlGrey 2.0 framework while using Swift language for those tests. However, I can't find a solution for tapping on a system alert, although EG 2.0 should support them. To be more specific, it is the native location iOS permission dialog when the app launches. Has anyone done this already? Any ideas? Thank you.
Here's the full code of a test accepting native system alert in Swift
func testExample() {
let app = XCUIApplication()
app.launch()
XCTAssertTrue(grey_wait(forAlertVisibility: true, withTimeout: 2))
XCTAssertTrue(grey_acceptSystemDialogWithError(nil))
XCTAssertTrue(grey_wait(forAlertVisibility: false, withTimeout: 1))
}

CloudKit CKShare userDidAcceptCloudKitShareWith Never Fires on Mac App

I am working on accepting a CKShare in a macOS app in Swift 4. I've already done all the following:
Create the CKShare and save it with its rootRecord to CloudKit
Add a participant (CKShare.Participant)
I've confirmed that the CKShare is on the CloudKit server and that the person I invited has access to it. Here's a screenshot: https://d.pr/i/0sMFQq
When I click the share link associated with the CKShare, it opens my app, but nothing happens and userDidAcceptCloudKitShareWith doesn't fire.
func application(_ application: NSApplication, userDidAcceptCloudKitShareWith metadata: CKShareMetadata) {
print("Made it!") //<-- This never gets logged :(
let shareOperation = CKAcceptSharesOperation(shareMetadatas: [metadata])
shareOperation.qualityOfService = .userInteractive
shareOperation.perShareCompletionBlock = {meta, share, error in
print("meta \(meta)\nshare \(share)\nerror \(error)")
}
shareOperation.acceptSharesCompletionBlock = { error in
if let error = error{
print("error in accept share completion \(error)")
}else{
//Send your user to where they need to go in your app
print("successful share:\n\(metadata)")
}
}
CKContainer.default().add(shareOperation)
}
Is there some kind of URL scheme I have to include in my info.plist? Or perhaps a protocol I need to conform to in my NSApplicationDelegate delegate? I can't, for the life of me, figure out what to do. Thanks in advance!
Update
I've tried a few more things on this. When I open the share link in a web browser, I see this:
Clicking OK makes the screen fade away to this:
Not particularly helpful. :) After doing this, the participant's status in CloudKit is still Invited, so the share still hasn't been accepted.
When I click on a share link within Messages, I am shown a popup like this:
After I click open, a new copy of my app shows up in the dock, then the app suddenly closes. The crash log states:
Terminating app due to uncaught exception 'CKException', reason: 'The application is missing required entitlement com.apple.developer.icloud-services'
I've tried turning iCloud off and on again in the Capabilities section of Xcode, but nothing changes. I know this exception can't be right because I can start my app normally and use CloudKit all day long. Only the CKShare causes this crash.
This is a mess. Save me, Obi-wan Kenobi, you're my only hope.
Yes,
You need to add this to your info.plist.
<key>CKSharingSupported</key>
<true/>
** EDITED ANSWER **
I use this code to share, I don't do it manually... not sure if this is an option under OS X I must confess. I am using iOS.
let share = CKShare(rootRecord: record2S!)
share[CKShareTitleKey] = "My Next Share" as CKRecordValue
share.publicPermission = .none
let sharingController = UICloudSharingController(preparationHandler: {(UICloudSharingController, handler:
#escaping (CKShare?, CKContainer?, Error?) -> Void) in
let modifyOp = CKModifyRecordsOperation(recordsToSave:
[record2S!, share], recordIDsToDelete: nil)
modifyOp.savePolicy = .allKeys
modifyOp.modifyRecordsCompletionBlock = { (record, recordID,
error) in
handler(share, CKContainer.default(), error)
}
CKContainer.default().privateCloudDatabase.add(modifyOp)
})
sharingController.availablePermissions = [.allowReadWrite,
.allowPrivate]
sharingController.delegate = self
sharingController.popoverPresentationController?.sourceView = self.view
DispatchQueue.main.async {
self.present(sharingController, animated:true, completion:nil)
}
This presents an activity controller in which you can choose say email and then send a link. You might also want to watch this video, focus on cloudKit JS right at the beginning.
Watch this WWDC video too https://developer.apple.com/videos/play/wwdc2015/710/
It talks about the cloudkit JSON API, using it you can query what has and what hasn't been shared in a terminal window/simple script perhaps. I did the same when using dropbox API a few years back. Hey you can even use the cloudkit JSON API within your code in place of the native calls.
I finally got it to work! I did all of the following:
Deleted my app from ~/Library/Developer/Excode/DerivedData
Made sure I had no other copies of my app archived anywhere on my machine.
Said a prayer.
Rebooted.
Sheesh, that was rough. :)
If your app is a Mac Catalyst app running on any version of macOS Catalina at least up to and including 10.15.4 Beta 1, a UIApplicationDelegate userDidAcceptCloudKitShareWith method will never be invoked.
After some significant debugging, we discovered that the MacCatalyst UIKit doesn’t even have an implementation for userDidAcceptCloudKitShareWithMetadata in its UIApplication delegate. It’s not broken, it’s just not there. So, at least temporarily, our workaround is the following, which seems to work, even if it’s very inelegant:
// Add CloudKit sharing acceptance handling to UINSApplicationDelegate, which is missing it.
#if targetEnvironment(macCatalyst)
extension NSObject {
#objc func application(_ application: NSObject, userDidAcceptCloudKitShareWithMetadata cloudKitShareMetadata: CKShare.Metadata) {
YourClass.acceptCloudKitShare(cloudKitShareMetadata: cloudKitShareMetadata)
}
}
#endif
If you are using a SceneDelegate, implement the delegate callback there, instead of on AppDelegate.
func windowScene(_ windowScene: UIWindowScene, userDidAcceptCloudKitShareWith cloudKitShareMetadata: CKShare.Metadata) {
// ...
}
You need to create the app delegate for your SwiftUI app using #NSApplicationDelegateAdaptor:
#main
struct Sharing_ServiceApp: App
{
#NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene
{
WindowGroup
{
ContentView()
.environment(\.managedObjectContext, persistenceController.container.viewContext)
}
}
}
I put that line in and my code instantly started receiving the share requests.

How can I test the text that SVProgressHud displays?

I'm doing UI testing in Swift and the app I'm testing shows many update/progress messages using the pod SVProgressHud. I want to be able to verify whether the correct message is being displayed. How can I capture the SVProgress HUD and get its text?
SVProgressHud is accessibility-ready (at least the version 1.1.3 that I'm using), so it's as simple as:
let message = app.otherElements["Your update/progress message"]
If you're also looking for string localization in UI tests target, please refer to this answer:
https://stackoverflow.com/a/44014704/1104337
Hide SVProgressHUD in Swift 4
func stopLoader(){
DispatchQueue.main.async {
SVProgressHUD.dismiss()
}
}
Thanks!
Show SVProgressHUD with text and setting ring thickness in Swift 4
func startLoader(){
DispatchQueue.main.async {
SVProgressHUD.show(withStatus: "Loading...")
SVProgressHUD.setDefaultStyle(SVProgressHUDStyle.dark)
SVProgressHUD.setRingThickness(3.0)
SVProgressHUD.setMinimumDismissTimeInterval(2.0)
}
}
Thanks!

Why dont my facebook interstitial ads show in my app?

Im in Swift and every-time I call them the delegate func didFailWithError gets called. Im using the same code I use for the facebook intersitial ads in all my apps and it works perfectly except for this new app I created. No ads pop up and I get a message in my console saying:
DiskCookieStorage changing policy from 2 to 0, cookie file:
file:///private/var/mobile/Containers/Data/Application/4E5FA239-208C-4B08-87C6-E4DB1CC3CC76/Library/Cookies/Cookies.binarycookies
This is how I setup the code in my GameViewController:
import UIKit
import SpriteKit
let interstitialFBAD: FBInterstitialAd = FBInterstitialAd(placementID: "2320559454634478_1321860725967683")
class GameViewController: UIViewController, FBInterstitialAdDelegate {
override func viewDidLoad() {
super.viewDidLoad()
if let scene = GameScene(fileNamed:"GameScene") {
loadFBInterstitialAd()
}
}
//fbAds--------------------------------------------------------------------------------------------------------
func loadFBInterstitialAd() {
interstitialFBAD.delegate = self
interstitialFBAD.load()
print("what")
}
func interstitialAdDidLoad(_ interstitialAd: FBInterstitialAd) {
interstitialFBAD.show(fromRootViewController: self)
print("popup")
}
func interstitialAd(_ interstitialAd: FBInterstitialAd, didFailWithError error: Error) {
print("failed")
}
//fbAds--------------------------------------------------------------------------------------------------------
So from
Im in Swift and every-time I call them the delegate func didFailWithError gets called. Im using the same code I use for the facebook intersitial ads in all my apps and it works perfectly except for this new app I created. No ads pop up and I get a message in my console saying:
This seems like my first solution is not the answer, but it's so obvious I need to point it out nonetheless: from the Facebook docs it seems like there's a couple steps to creating an app that can use the SDK properly (namely creating an app in Facebook and using the proper Info.plist keys, etc).
If that's not what is happening, though, which I imagine it's not, then this could still be due to the application not being properly set up but for a reason other than Facebook SDK.
Without seeing how you are initializing the SDK in your AppDelegate and without confirmation it's not Info.plist keys that are missing for the ads you are attempting to show, it's hard to say what the issue could be here. Have you contacted Facebook support? They'd definitely be able to help here as well. Somewhere off this page I'm sure you can find proper live support as a paying ads customer.