I am facing a strange issue, after I started running my app on iOS11 devices.
I do NOT have a 'rejection' from Apple but it simply stopped working on devices/simulators using iOS11.
For the call action to a number, I used the below code which worked well (and still works) on iOS10 simulators and devices.
let myPhoneNumber = "123456789"
if let url = URL(string: "telprompt://\(myPhoneNumber)"), UIApplication.shared.canOpenURL(url) {
UIApplication.shared.openURL(url)
}
The same code doesn't work on iOS 11 anymore. I have my project migrated to Swift 4.0.2 as well.
Did I miss something specific?
PS: I have this in my info.plist already added under the LSApplicationQueriesSchemes
I know this question is answered for many same time of title or with different title.I am trying below code.
UIApplication.sharedApplication().openURL(videoURL)
This line of code works fine in iOS simulator 8.xx/9.xx and returns true. But When I am trying to run my code in iPhone 9.Xx(unfortunately don't have iOS 8.xx device) then this line
UIApplication.sharedApplication().openURL(videoURL)
is giving false.
I thought ,since my url contain https:// so i tried changing it to http:// but still no luck.Is there any kind of entry requires in .plist file somewhere.I assume but don't know if thats how it should be done.Can you guys help me out in this.
Regards
I used this code on actual device iPhone iOS 9.3.3
let videoURL = "https://www.youtube.com/watch?v=sFY-NDAAgFo"
UIApplication.sharedApplication().openURL(NSURL(string: videoURL)!)
It just opened safari with youtube video
For http we need to add a key in Info.plist nowadays since iOS 9
Just before your last dict write these lines in Info.plist viewed as Source code.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Alternatively you can add a new key and make it as a dictionary and add a Boolean field as shown in image
remember this from iOS 9 onwards you can use SFSafariViewController
import SafariServices
private func openMYUrl(url: NSURL) {
if #available(iOS 9.0, *) {
let svc = SFSafariViewController(URL: url)
svc.delegate = self
self.presentViewController(svc, animated: true, completion: nil)
}
else {
UIApplication.sharedApplication().openURL(url)
}
}
NOTE: if you are not using this app will reject . in my case its
happen.
This is an apple bug for iOS 9.0.x which got fixed in iOS 9.3.x.I am pasting the link for someone who wants to refer this link for for more info.Thanks Rajan for your answer and suggestion
Please go through this apple release note
I am running a watchkit app which uses app groups and I can't seem to get it running at all. Anytime I try and run the app I get an alert which says "SPErrorGizmoInstallNeverFinishedErrorMessage".
The code in my glance controller is relatively short.
let sharedGroupName = NSBundle.mainBundle().objectForInfoDictionaryKey("Shared Group") as! String
var sharedDefaults:NSUserDefaults!
override func willActivate() {
super.willActivate()
sharedDefaults = NSUserDefaults(suiteName: sharedGroupName)
var timer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: Selector("update"), userInfo: nil, repeats: true)
}
func update() {
println(sharedDefaults?.valueForKey("timeMessage") as! String)
}
The code in my ViewController.swift is short as well also just setting this share defaults object:
let sharedGroupName = NSBundle.mainBundle().objectForInfoDictionaryKey("Shared Group") as! String
var sharedDefaults:NSUserDefaults!
sharedDefaults?.setObject(timeMessage.text, forKey: "timeMessage")
sharedDefaults?.synchronize()
This error is preventing me from running any watchkit app at all. Not the main app or the glance or notification.
I have one app group which is listed in the info.plist.
I have a custom build setting to the app groups name.
Any help would be greatly appreciated.
I fixed this issue by going to the simulator's watch companion app, unchecking the installation for the watch app, then turning it back on. Nothing else worked.
The only thing that worked for me was to Reset Content and Settings in the simulator. Toggling the watch app off and on in the Apple Watch settings app didn't do it for me.
From reading other Apple Developer forum messages, SPErrorGizmoInstallNeverFinishedErrorMessage seems to occur when the Watch App info.plist has an invalid setting.
I was trying different versions of WKCompanionAppBundleIdentifier and that was my error. When I deleted the copied line, that worked again.
This message started appearing when I added custom keys in the info.plist file.
After much trial and error I was able to fix this by unplugging my external display from my computer. Whether this was the real issue I don't know. All I know is that when I had the external monitor plugged in I got this error and when I unplugged it the error went away. I tested it several times.
For me, it was "Targeted Device Family" settings
For parent app, you could keep it iPhone/iPad (or iPhone, up to you);
For watchkitextension, set it to iPhone;
For watchkitapp, if you want to run in the simulator, set it to iPhone. For actually device, the value seems to be 4 (which you cannot set directly from Xcode yet as of 20150416)
I did nothing but restart Simulator & Clean-build app, then it worked again. :)
If you want to use the group to share the data with IOS app and your apple watch kit using the NSUserdefault, you can follow these steps:
1. Add the group app id in capabilities part of IOS targets app and target watch kit
2. when you want to save the data to NSUSerDefault:
var groupData = NSUserDefaults(suiteName: "group.demoShareData")
// note that suiteName is group app id
// var str = "demotest"
groupData?.setObject(newYearLabel.text, forKey: "timeRemaining")
groupData?.synchronize()
3. when you want to take the data from NSuserDefault:
var groupData = NSUserDefaults(suiteName: "group.demoShareData")
groupData?.synchronize()
if groupData?.objectForKey("timeRemaining") != nil {
var str = groupData?.objectForKey("timeRemaining") as String
println("str \(str)")
self.myLabel.setText(str)
} else {
println("error")
}
Hope this help :)
I found a solution in Xcode 8.3. Make sure that the build setting "Targeted Device Family" is set to iPhone in the WatchKit extension.
I Deleted the App from the simulator, and reinstalled. Seemed to work.
I tried a couple of the other option.
CMD SHIFT K - clean
CMD RUN - run
the error dissapears!
I am trying to play short system sound with swift in my project , but can't make it work. I searched for the answer , unfortunately non of them were worked for me even if they worked for others . Here is my code .
//System Keyboard Tock Sound
func playInputClick() {
let filePath = NSBundle.mainBundle().pathForResource("Tock", ofType: "caf")
let fileURL = NSURL(fileURLWithPath: filePath!)
var soundID:SystemSoundID = 0
AudioServicesCreateSystemSoundID(fileURL, &soundID)
AudioServicesPlaySystemSound(soundID)
}
The objective-c version of this code was working fine , and now the swift version not working for me , when try to play the sound nothing is happening in the simulator , when I tap the button to play on the device it slows down the tapping action and makes no sound.
I can't figure out what causes the problem , is it the betas ? But exact the same code worked on the device for some people in this forum . maybe this is more about a question of calling C methods in swift.
This is from System log:
[MPUSystemMediaControls] Updating supported commands for now playing application.
Failed to inherit CoreMedia permissions from 2743: (null)
Reinstalling X-Code solved my issue , I have no idea what was wrong. The above code only works on real-devices not on simulator, if somebody need to use the code .
I'm trying to get my app to play a video that has been downloaded to the Documents Directory.
My code works when tested on the iOS 7.1 simulator but not on iOS 8.0 devices or the iOS 8.0 simulator. There isn't any error, AVPlayer does not play the video and shows a Black View.
I also checked the Document's folder of my device with XCode's Organizer and the file appears to be successfully downloaded.
Here is a simplified version of my code.
// file_path is a string that stores the path to the video file a println of it shows
// "/var/mobile/Containers/Data/Application/83C7837C-59B5-4767-A579-7CE758A93C6F/Documents/og4gr.mp4"
var path:NSURL = NSURL.fileURLWithPath(file_path, isDirectory: false);
_player = AVPlayer(URL: path);
Has anyone else encountered this? Thank you for your time!
So the problem was that the Application Documents Folder Path changes every time you launch the app and I was storing the absolute path of the video file.
According to this article here:
http://pinkstone.co.uk/where-is-the-documents-directory-for-the-ios-8-simulator/, this is how it is now in iOS 8, which is why while my method worked in iOS7 it was failing on iOS8 devices and Simulators. Thank you #RoboticCat for pointing me in the right direction!