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!
Related
This is my first WatchKit App.
I am working on an app that gets an API call to an iCal file and displays the time remaining in two events.
I am working on Xcode 13.4.1 and created an iOS app with watchOS app using swift and storyboard. I set the target deployment for the iOS app to 15.5, which is the highest version of iOS that my current version of Xcode will let me set. The target deployment for the watchOS app is set to version 6.2 because I have an Apple Watch series 2, and the latest version of watchOS is 6.3. I want the app to at least work for my watch. The code for the iOS app and watch app are pretty much the same. The app works as expected on the watch and phone simulators and on my physical iPhone 8 plus. The problem is that the app does not work on my physical watch.
I created a custom class called API_Manager that handles the API call. I handle my API call as a giant string because I am getting an iCal file and parse it later on in the class. url is defined above. Here is my API call for both the phone and watch app:
public func getData() throws{
//api call
do{
// real url is defined above
let url:String = ""
savedData = try String(contentsOf: URL(string: url)!)
} catch{
print("there was an error with the api call")
throw API_Error.apiCallError
}
// parsing data
}
getData() is called in the init function of the API_Manager class.
init() throws {
// checking internet connection
if (!NetworkMonitor.shared.isConnected){
throw API_Error.noInternet
}
do{
try getData()
} catch{
throw API_Error.apiCallError
}
}
I believe the root of the problem is an Internet connection. I check for an Internet connection before the API call, and if there is no Internet connection, then I throw a custom error. I used this video to create a Network_Monitor class. This is the startMonitoring() function which is called in the applicationDidFinishLaunching() in extensionDelegate of the watch app and application didFinishLaunchingWithOptions in the appDelegate.
public func startMonitoring(){
monitor.start(queue: queue)
monitor.pathUpdateHandler = { [weak self] path in
self?.isConnected = path.status == .satisfied
// getting connection type
self?.getConnectionType(path)
}
}
I created a custom error that is thrown throughout the API_Manager if things don't work as expected. Here is how I created the custom errors:
enum API_Error: Error{
case noInternet
case apiCallError
}
extension API_Error: CustomStringConvertible{
public var description:String {
switch self{
case .noInternet:
return "Error: No internet connection"
case .apiCallError:
return "There was an error with the api call"
}
}
}
I created another enum that is used to display text on a label in the Interface Controller if a specific error is thrown.
enum API_Manager_Status{
case active
case noInternet
case apiCallError
case null // if the api manager is nill
}
Here is how I used the two enums in InterfaceController:
main() is called in the awake() function.
func main(){
do{
apiManager = try API_Manager()
apiManagerStatus = .active
} catch API_Error.noInternet{
apiManagerStatus = .noInternet
} catch API_Error.apiCallError{
apiManagerStatus = .apiCallError
} catch{
apiManagerStatus = .null
}
if (apiManagerStatus == .noInternet){
periodLabel.setText("Error")
timeRemaining.setText("No Internet")
print(API_Error.noInternet)
} else if (apiManagerStatus == .apiCallError){
periodLabel.setText("Error")
timeRemaining.setText("API Call")
print(API_Error.apiCallError)
} else if (apiManagerStatus == .null){
periodLabel.setText("Error")
timeRemaining.setText("Other Error")
print("Cought all errors")
} else{
// main code to display time remaining
}
So I guess my questions are:
Why is my Apple Watch not getting an Internet connection?
How can I fix my app if it worked on the simulators and iPhone, but not watch?
Can the Apple Watch do an API call?
Do I need to configure my app to connect with the iPhone, given that my watchOS verison is 6.2?
Sorry if this is a long question. This is my first time posting a question on Stack Overflow. I would appreciate any help. Let me know if I need to add any more information to help clear things up.
I have tried many potential solutions to fix the problem, but none have worked:
I distributed the app on Test Flight and had my dad download it. He has an Apple Watch Series 4 running on watchOS 9.2, and the app still does not work on his watch.
I have restarted my phone and watch multiple times and even tried to run the app with my phone off, so the watch could connect to wifi.
I tried to install a watchOS 9 beta profile on my watch, knowing it would not work, but I still wanted to see what would happen.
I tried setting the build target to watchOS 8.5, which is the highest my version of Xcode would allow, to see if the problem was watchOS 6.2, and if it would work on my dad's watch.
Lastly, I tried adding privacy messages in the Info.plist for both the phone and the watch app. The messages did not display when I re-downloaded the app, but it still did not fix the issue.
(the messages I used were: "Privacy - Nearby Interaction Usage Description" which does not work on watchOS 6.2, but I still kept in the info.plist, and "Privacy - Bluetooth Always Usage Description")
I know Apple Watches are supposed to use the connected phone for Internet and then wifi if a phone is not connected. My watch shows that my phone is connected, and I have tried it with just wifi. I believe my watch can still get an Internet connection because I can still use Siri and even go to the App Store on my watch, which needs an Internet connection. I would appreciate any help. Let me know if I need to add any more information to help clear things up.
I am using the example xcode project for sharing media between my app and Snapchat directly. I have successfully authenticated my app by this point (it loads bitmoji + user info and I can print the access token). The code that causes the error is invoked after the UIPicker has selected an image:
from line 38 of MediaPickerViewController.swift
fileprivate func shareImage(image: UIImage) {
let snapPhoto = SCSDKSnapPhoto(image: image)
let snapContent = SCSDKPhotoSnapContent(snapPhoto: snapPhoto)
// Send it over to Snapchat. This produced the error below
snapAPI.startSending(snapContent)
}
Then when you pick an image from the gallery:
2020-03-23 17:49:54.487603-0700 CreativeKitSample[20966:5903027]
[AXRuntimeCommon] AX Lookup problem - errorCode:1100 error:
Permission denied portName:'com.apple.iphone.axserver' PID:20969
This is running on my iPhone, debugging over USB. I'm new to Swift development, and my best guess is that my app is developer certificate signed, perhaps it is sandboxed on iOS 13 from communication with prod apps? Or is the AXServer more of a Core UI thing or Accessibility? This project uses Interface Builder/Storyboards. I tried disabling accessibility checkbox on UI elements. I'm at a loss here, searching for AXServer permission errors has not been useful.
some AX errors:
https://github.com/TimOliver/TOCropViewController/issues/402
https://forums.developer.apple.com/thread/120696 (clue that it may be inter-app permission)
https://bugs.webkit.org/show_bug.cgi?id=203618 (sandbox extension?)
I'm an idiot. When I created my Apple Developer Cert and Provisioning Profile, I had a collision with the package identifier, so I changed it in the provisioning settings but neglected to update the snapchat portal's bundle ID. Leaving the question here for anyone else with the same problem.
They could make their error a bit more descriptive...
I got maybe a solution... I'm dismissing before the current View Controller, then present the SFSafariViewController.
Using following Code does help me out! (Xcode 11.3.1, macOS 10.14.6, iOS 13.3)
DispatchQueue.main.async(execute: {
// code goes here
})
// my solution...
DispatchQueue.main.async {
self.present(safariVC, animated: true, completion: nil)
}
I have made an app that tracks 2D body motion data using the back camera. I have followed Apple's example to create an ARView from the storyboard, and have added this code in my viewDidAppear:
arView.session.delegate = self
// If the iOS device doesn't support body tracking, raise a developer error for
// this unhandled case.
guard ARBodyTrackingConfiguration.isSupported else {
fatalError("This feature is only supported on devices with an A12 chip")
}
// Run a body tracking configration.
let configuration = ARBodyTrackingConfiguration()
arView.session.run(configuration)
When I open the app everything works perfectly when installing from Xcode, but the app crashes when installing from TestFligth. Crash log shows me the last backtrace log at arView.session.delegate = self
I've found a workaround in case someone faces the same problem. According to Apple this is a known issue in XCode 11. To solve it, you need to manually add RealityKit to your target’s Link Binary with Libraries build phase. Hope this helps
I have developed application in Swift. Application is enterprise application so it will never go live on App Store.
I need to update the application within app if update is available for the application.
Right now I have done with backend and iOS side code. I have created .plist file which contains my uploaded .ipa file url and other things. ref
I have successfully implemented code of how can I download and update the app within app itself.
But the issue is when app start to download it stops at 60% and when I try to retry download it's shows error Unable to Downlaod App.
Is there any way I can implement the same idea ?
Swift code
func getTheData() {
let appversion = NSBundle.mainBundle().infoDictionary!["CFBundleShortVersionString"] as! String
var query = PFQuery(className:"AppVersion")
query.getObjectInBackgroundWithId("Parse unique key") {
(version: PFObject?, error: NSError?) -> Void in
if error == nil && version != nil {
let oldVersion = version?.valueForKey("version") as! String
println(version?.valueForKey("version"))
if appversion == oldVersion {
println("Same Version")
}
else {
println(version)
println("Different version")
let url = version?.valueForKey("ipaURL") as! String
UIApplication.sharedApplication().openURL(NSURL(string:url)!)
}
} else {
println(error)
}
}
}
ANSWER:
I have found the issue.The issue is with iOS 9.0 and above only. From XCode 7 and above, you have to generate(Not manually) manifest.plist file with organizer only. When you are creating ipa file using export option in organizer you will get two options 1)Bitcode 2)generate manifest for OTA update. You have to crete Manifest.plist file with XCode's organizer only.
Seeing as the app is open, I would recommend showing the user a message to update. The AlertView button action should take the user to the webpage to download the new version.
This is not ideal from what you are trying to achieve, but is a way I have done it in the past and works fine.
The issue is the provision profile when you create Archive that time you need to correct device which is listed into provision profile.
Before few days same issue I face and connected same device along with provision profile UDID container.
So I created R&D over that and solve the same problem.
I have read in the Apple developer forum that unlike watchOS 1, watchOS 2 does not share its keychain with the phone app so bam!! keychain sharing is not enabled by default we got to do a workaround for that.
Ok coming to my issue, I was trying to run a very basic keychain access program on the actual watch device running the latest beta (beta4) using a git library https://github.com/jrendel/SwiftKeychainWrapper
let saveSuccessful: Bool = KeychainWrapper.setString("keychainData", forKey: "ImportantKeychainData")
if saveSuccessful{
let retrievedString: String? = KeychainWrapper.stringForKey("ImportantKeychainData")
print(retrievedString)
}
else
{
print("unable to write keychain data")
}
On the simulator it works like a charm but when I try to run the same on the actual watch it gives me an status code of -34018
There was no public documentation about this error code but I did a little digging to find out it turned out to be
errSecMissingEntitlement = -34018, /* Internal error when a required entitlement isn't present. */
source: http://opensource.apple.com/source/Security/Security-55471/sec/Security/SecBasePriv.h
I did a lot of research actually a full day on this and people pointed me to various directions, like memory issues, entitlements, profile issue, bug in keychain etc.
The catch here is that most of the dev's who reported this issue did not have it continuously like I got it on every run of the app, they had it at certain places only like when app was in background etc. To summarise,
1. I tried the same piece of code on iOS 9 beta 4 and it worked well on the phone.
2. The same code works well on the watch simulator.
3. The same code does not work on watchOS beta 4 returns -34018 continuously on the device but works well on the simulator.
4. All this testing is done using free provisioning introduced from Xcode 7, entitlements were added to the phone app and the watch extension, keychain sharing was enabled, app groups was enabled.
My questions are
1. Am I missing something here that I have to do with the device keychain that I am supposedly doing it wrong?
2. Is there an issue with free provisioning?
3. Is there an issue with the keychain perhaps??
Any help is appreciated.
FYI I also tried Apple's KeychainItemWrapper, customs code directly talking to SecItem methods nothing turned out to be fruitful.
Update, I tried this as well it fails as usual
let storableString:NSString = "keychain in watchos is working with simple code"
let query : [NSString : AnyObject] = [
kSecClass : kSecClassGenericPassword,
kSecAttrService : "WatchService",
kSecAttrLabel : "KeychainData",
kSecAttrAccount : "SecureData",
kSecValueData : storableString.dataUsingEncoding(NSUTF8StringEncoding)!
]
let result = SecItemAdd(query, nil)
print(result)
Update 2: Issue has been fixed in watchOS2 beta 5.
Issue has been fixed by Apple in the recent watchOS 2 beta 5.