Using images in the main Xcode project for Watch app - ios

I have a watch application and I will display images in it. Those images are already included in IOS application so I don't want to copy them into watch app as well. How to use images in IOS side (not in asset catalog) in watch app?

With the introduction of watchOS2, WatckKit apps became native apps and not just extensions of their iOS counterpart. Due to this, the iOS and watchOS apps can no longer share a common AppGroup.
The only way to share data between apps is using the WatchConnectivity framework. However, for static images, you shouldn't use the WatchConnectivity framework. If you don't want to add the pictures to the asset catalog, you don't actually need to copy them. All you need to do is add them to your WatckKit app or app extension target, depending on whether you want to use them from Storyboard or code.
Keep in mind that the system will actually copy those images to your Watch target as well, since storage is not shared between the iOS and watchOS apps so you don't actually gain any storage advantages by not adding those images to both apps' asset catalogs.

Related

Role of framework in between Extension and App in ios

I'm bit confused about the concepts of Extension in ios. After going through some tutorials I still have doubt how an app and an extension in ios communicate each other, does this has to do anything with Framework. If Yes, why we are adding Frameworks...
Hoping for a response, Thanks
App extensions are not stand alone apps. They are providing extended functionality of the app (which can be accessed from main app, called the host app) that is meant to be efficient and focused towards a single task.
For example, Today widget in iPhone is an extension. We can create a today widget for an iOS app which is an extension of the existing iOS app. For example, let us consider an app which shows current weather in detail. Then you can create an extension for this app, to show only current temperature without much detail in a widget.
The extension uses the data which is shared between both the main app and the extension. Embedded framework is a technique to share same code between two targets. You can share data using NSUserdefaults and app group concept.

How to pass objects/data between my iOS applications

I have an existing iOS application on the app store, and I am building a new companion app to work with this existing app.
I need to pass objects/data from this new app to my existing app when a certain action is taken. The behaviour I'm looking for is very similar to AirDrop but the data is passed to another app on the same device.
The objects I want to pass locally between apps are simply NSObject's.
As per your comment you wants to share NSObjects between your iOS apps. The best approach would be "Custom URL Schemes". But in this approach you may need to add or re write some parts in your old iOS App as well.
checkout this SO Answer for more info on implementing custom url scheme and history of sharing data between ios apps.
Apple documentation for sharing data is also available.
If your app supports greater than iOS 8 you can also use the new feature called "App Group Functionality"

Unable to get values from settings bundle in watchOS 2

I have a settings bundles that I use with my watch app. I am migrating my app to watchOS 2. Does anyone know how setting bundles are supposed to work? Does the iPhone transfer the values to a the standard user defaults or to a user defaults with a suite name for a shared app group? I can't get either to work and I can't find any documentation on how setting bundles are supposed to work with watchOS 2.
The accepted answer is wrong. You can use Shared App Groups for the Settings bundle on WatchOS 2 and access the values via NSUserDefaults. No Watch Connectivity required. It is just tricky to set up and the official documentation is missing crucial info.
Recently discovered how to do it in my question here.
The 2 important points are:
You need to enable Shared App Groups on all 3 targets (iOS app, Watchkit app, WatchKit extension)
It only works on the real device, not simulator. You might need to remove the app from both devices and reinstall to have it start working.
In Watch OS 2.0 since the Watch App extension is in the Apple Watch (not in the iOS App as in Watch 1.0) you can't transfer data through user defaults, so you should use instead WatchConnectivity.
If you have a settings bundle or a framework and you want to use it in the AW App extension and in the iOS APP, you should import it in every target of your project.

Large app size in AppStore. Is it allowed to download external assets?

I've developed a game, it's total file-size with all assets is about 220Mb.
The game is developed in Haxe language with a framework called openFL - that allows to compile iOS and Android versions from a single source.
Because Android's Google Play doesn't allow apps larger than 50Mb in one go, I've separated the graphics assets and sounds from the code, leaving the app at about 1.5 Mb. I don't want to make a separate branch for iOS, so I'd like to use the same logic for App Store as well.
My question is - is it allowed to download the external assets for iOS similar to how Google play does it? Will App Store host these files for me?

Confusion on universal app/iPad target

There are many similar questions, but I haven't really found the answer for this.
I'm making an iPad version of a large iPhone app. Which is the best way to go when distributing? I understand that when turning the app into a "Universal" app, all resources (images etc) for the iPad version are also downloaded to iPhones.
This is probably not desired, so to me it sounds better to use the built-in XCode function to duplicate the target into an iPad target. (This is nice since it will generate iPad-specific versions of all the NIB-files)
However, I'm afraid that this will split the app into two versions on the app store. I want to make it look like a universal app on app store, with the little "+"-sign. Is it possible to make it look like a universal app, when it's actually two different targets?
In a Universal app there is only one binary.
If you create to targets you can compile for either iPhone or iPad, but then you'll have two different apps.
So, no it is not possible to make two apps look and behave like an universal app.
I don't think that the images etc being present in both versions are such a serious problem.
They get compressed and can mostly be used for both versions.
I would prefer having a universal app that syncs via iCloud on all my devices than having to download two versions of the app... Apple does it too, e.g. in iBooks.

Resources