I need to use some images in my WatchOS app and its complications. If I put them in the assets catalog inside the watchkit app target group I can't access them from my WatchOS app, but in the extention assets catalog I can.
This is the test image:
This is how I tested the accessibility:
I dropped a png file into watchkit app assets. XCode created an image set ad put the image in the 2x slot.
I copied the name CircularSmallRingImage42mm from Attribute Inspector.
I added the following code in the awakeWithContext() method in my initial InterfaceController:
if let image = UIImage(named: "CircularSmallRingImage42mm") {
NSLog("works")
} else {
NSLog("doesn't work")
}
I reset content and settings on the Apple Watch Simulator.
I cleaned and ran the watchkit app scheme on iPhone 6s Plus + Apple Watch 42mm simulator. Doesn't work.
I deleted the image set and repeated the procedure, except for this time I dropped the image in app extension's asset catalog. Works.
The assets catalog in my watchkit app group is targeted only on watchkit app. The assets catalog in my watchkit app extension group is targeted only on watchkit app extension. Everywhere I look people seem to recommend putting static content into an asset catalog bundled with the Watch App target so it gets stored on the watch itself.
Why can't I access the image? Am I doing something wrong? Is the watchkit app bundle not the recommended place for storing static files?
Based on the name of the image, it sounds like it's related to a complication.
Complication images belong in the WatchKit Extension Asset Catalog, since the complication is an "extension" of your app. Your app doesn't have to be loaded or running for the complication to function.
You also need to refer to complication images by their group name if they're stored in the Complication group. E.g.,
UIImage(named: "Complication/Circular")
For more details, see this thread at the Apple Developer forum.
The Assets for iphone app and for watch app is totally different you can't access the images into app asset folder to watch extension. You have to add new images which compatible with the watch kit
Related
Could not find any answers to this specific problem anywhere online.
I've had to factor a Xamarin forms project as there was a requirement to have multiple android/iOS apps that use the same code. Current set up is:
Standard Library
Android App 1
Android App 2
iOS App 1
iOS App 2
Android Class Library
iOS Class Library
For android, the images are in the resources folder in the android class library and the images display fine in the app.
For iOS I have put the images in a Asset Catalog in the iOS class library. These however, do not show in the app. I created an asset catalog in one of the iOS app projects and tested that an image would load from there - and it did. Is it not possible for images to load from an asset catalog in a iOS class library? I have other items in the iOS class library (such as custom renderers, which work fine). If the latter is not possible, is there a different way I keep the images in one place for iOS, without having to change my xaml? This is an existing project, with loads of images already being referenced by name in xaml (e.g. Source="image.png") that are used for both iOS and android. If possible, I don't want to have to maintain an asset catalog per app, although I do know of a way it could be automated, but I want to avoid having to do that if possible.
Using .NET Standard 2.1 and Xamarin Forms 5.0.0.2401
Thanks in advance.
In my project I have multiple asset catalogs, one of which is named images.xcassets.
I am able to access all the images inside said asset catalog using either UIImage(named: "image.png") or #imageLiteral(resourceName: "image.png") (with and without the file extension .png).
Issue
Now, trying to access resource image2.png works just fine with the iOS 11.2 iPad 10.5" simulator. However, the exact same build crashes when using the iOS 11.2 iPad 12.9" (2nd gen.) simulator with the following "message":
Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
This issue has just emerged, I was always able to access the image before today. I have not touched a thing...
What I've tried
target membership set to project's target
removed the asset catalog from Copy Bundle Resources in Build Phases
cleaned and rebuilt the project
deleted image2.png from the catalog and added it back
deleted the whole asset catalog and added it back
deleted the app from the 12.9" simulator and re-installed it
quit & re-opened Xcode and the simulator
Any idea why this specific resource can't be accessed anymore?
Notes:
so far, I didn't run into this error using real devices (tested with iPad Air 2 & iPad Pro 1st Gen.)
Has to do with the color space apparently.
I was able to "save for web" in Photoshop and convert the image to sRGB for an image file that doesn't crash in the iPad Pro 12.9" 2nd generation simulator.
Every time I upload my app, I get these messages but I have all the assets in the AppIcon assets and removed the CFBundleIconFiles from my info.plist
I am using CocoaPods for GooglePlayGames, Google Ads and Google Signin
I think maybe the sizes you are putting in the asset spots are off. I use this site for icons its great. https://applypixels.com
For some reason my icon of app has never appeared in companion app for Apple Watch.
Icon is appearing in iPhone and Apple Watch Dashboard.
I have provided 58*58(29*29#2x) and 76*76(29*29#3x) which are required for Companion Settings.
From Target Watch, i have selected my asset for Apple Watch.
After doing all that still the icon is not appearing in Companion Settings. What i need to do to make it appear?
The WatchKit does not share the Images.xcassets file from the main target app.
When adding a WatchKit to your project, it will create 2 folders <projectname> WatchKit Extension & <projectname> WatchKit App.
You will need to add the Icons for the watch in the Images.xcassets file in the WatchKit App folder.
This should solve your problem.
I didn't find anything regarding this issue elsewhere. Resetting the iPhone and Watch 1-2 times solved this problem.
I found my project show watch companion app icon right on iOS9.2, but doesn't show the icon on iOS9.1. you can update you IOS version to 9.2,then check if the icon show.
I want to remove Apple Watchkit from my App until the new version of IOS is released. This is so I can upload releases of the App until we can upload Watchkit based Apps.
I deleted the 2 Folders:
Twoater WatchKit Extension
Twoater Watchkit App
I then deleted the two Targets of the same name.
I built the App successfully.
I then tried to run the simulator and got a LaunchError = 0.
So something somewhere is not correct.
Did I remove the Watchkit in the correct way or is there a better way of doing it to ensure that all config files are properly adjusted ?
What you're doing is quite a bit overboard.
You should just create two separate schemes: one which includes the WatchKit App Extension and App (for testing for iOS 8.2) and one that doesn't include it (for testing with iOS 8.1 and submitting to the store).
You'll need to provide more details on your error running in the sim. See An error was encountered while running (Domain = LaunchServicesError, Code = 0)