Why does Xcode create two targets for watch app? - xcode

I'm new to WatchKit and I want to develop a Watch extension for my existing iOS app. I did develop a Share Extension before in the same project, so I know a bit about how extension targets are embedded into the app.
However, when I added a Watch app target using default settings, it created two targets, Watch and Watch Extension. I have trouble understanding the purpose of having both. Watch appears to have non-model content (e.g. assets, storyboard) by default and Watch Extension appears to have my actual code (e.g. interface controllers). Why aren't they together by default? What is the purpose of splitting them, as they will both run together on the Watch?

When the Apple Watch first came out, the "Extension", ran on the phone and the "App", which contained the UI, ran on the watch. With the release of Watch OS 2, both run natively on the watch, but the targets continue to be separated. Hopefully soon we'll be able to have one target

While I can't say that they'd always need to be separate targets in terms of build dependencies, they do need to be distinct in terms of packaging, because the app and extension aren't always run together.
Similar to iOS, the .watchkitapp.watchkitextension bundle is a distinct component of the .watchkitapp package. Although the watch app does require the app extension, it's possible for an app extension to run in the background without its app having been launched. The watch might even be showing a completely different app in the foreground.
As an example, if an app extension included a complication which was shown on the watch face, that extension would receive a request from ClockKit to wake up. Its complication controller gets instantiated (based on information in the extension's property list) to update the complication server. This would all happen independent of the watch app. The watch app itself wouldn't be launched, unless the user happened to tap on that particular watch face complication.

Related

Appcelerator App Conversion iOS to Android.

One of our developer developed an app in appcelerator using alloy framework for iOS which works fine. Now we want to run the same app in Android, since the appcelerator is a cross platform tool, we wish to make the Android version of the App. I tried searching about it and explored the applcelerator ide for options but couldn't find it. Can some one please guide me into the right direction?
First of all have a look at this link : http://docs.appcelerator.com/platform/latest/#!/guide/Supporting_Multiple_Platforms_in_a_Single_Codebase this will guide you to update the application for multiple platforms.
Their are basically two different ways to port any application from android to iOS or vise-versa, but before that just let me clear one more thing to you about tiapp.xml.
In the tiapp.xml of your project you need to updated the Development Target by checking for which platform you are developing the application for (iPhone, iPad, android, Mobile Web).
Option 1 :
Cross Platform is build to make code re-usable (i.e. re-use same code for all the platforms), but we have exceptions with many things. Their are lot of components that work fine in iOS but when you use them in android then you will face errors. So in that case you just need to apply conditions for android and iOS like below :
if(OS_ANDROID)
// do something
else if(OS_IOS)
// do something
What you need to do is that you need run the application in android simulator and test the application for these changes and then apply the changes accordingly.
Basically a developer has to target the UI for both the platforms, as their will not be any logical differences between the two. Also their will be UI changes between the same components, like for example a picker in iOS will not look the same as it will when you look it in an android application.
Option 2 :
Now in the project you have assets folder with the platform that you have selected in the tiapp.xml (i.e. iPhone, android etc).
You can create similar structure in the style and view folder, create two folders iOS and android in both the directory (i.e. style and view).
First, move .tss of style folder (except app.tss and index.tss) in the iOS folder, then copy the files in the android folder also.
Repeat the similar process with the View folder also.
Now you have two different structures (i.e. view and styles) according to their platform. Now you can run the application in android simulators and resolve the error that you face.
Hope this small information helps the cause, you can also have look at the documentation of all the components from below link :
http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.TableView

iOS9 Share Extension can not debug on Xcode

When I build share extension from Xcode for the real device, Xcode arbitrarily stop debug. But when I launch for simulator, the problem does not occur.
Environment
Xcode 7.1.1
iOS 9.1
Details
When I build share extension, Xcode shows "Finished running MobileSafari.app on iPhone", but Safari does not run. And, The square stop button is arbitrarily gray. So, I launch Safari by myself and choose my extension and post. The debug section does not show anything. Also, URL request is not sent Rails server.
This is the picture when I build the share extension for the real device.
I do not know why the real device can not launch share extension at Xcode.
If anyone know the answer about this problem, please tell me.
Typically you can debug a share extension by going to Debug -> Attach to process or PID and entering the name of your share extension. From there you can open the share extension on your device or simulator and Xcode's debugger should attach and hit breakpoints correctly. However, I've noticed that log messages do not show up when doing this, nor do values populate for variables in the debugger view.
Here's how I got the debugging to work correctly. Run the share extension scheme. When it asks you what app to run, chose 'Photos' (because that's the app your extension will operate in). The Photos app will then launch on your device and you may proceed to use your extension. The debugger in Xcode should then work as expected.
I encountered this issue as well, though unfortunately I don't know the exact solution, maybe I can offer some information that might be helpful.
I (like you, judging by your screenshot) was using Cocoapods, and Cocoapods was copying resources from the pods into the bundle of the app extension after it was code signed. If memory serves, this was interfering with the code signing in some way, and therefore preventing the app from running under the debugger.
I believe that one of the symptoms of this was that logs appeared in the mac's console (or the device's console, can't remember which) saying something about "blasting onto the device using the old skool[sic] method."
You could confirm that this is the case by removing Cocoapods from your project, or any pods that require resources to be copied after compilation. I believe that the solution was to add some kind of special build phase to the extension project to copy the bundle resources, and disabling whatever Cocoapods uses by default.
As a temporary solution, I believe that deleting your app from the device should allow you to attach the debugger once, on the run where the app is installed for the first time. You might also try deleting derived data for your project.

Running the app on a real Apple Watch and infinite spinner

I wanted to make a clickable prototype of an app on (storyboard only). I have just added two interface controllers and some images and buttons. I filled xcassets with several images (overall less than 150kB) and tried to run the app. When there was a single interface controller with 3 buttons (images in background) + 1 imageView (around 100kB all) it took some time but the app lauched. I added 1 more interface controller and a few images to it (the biggest are around 9kB) and this time Xcode displayed me a message that it lost a connection with an iPhone but the watch is still running or the watch app timed out error. At the same time I have the app name on the watch screen and a spinner. And it's spinning for ages without any result... I've tried to delete the app from both devices, restarting, cleaning folders etc. and no success. Is there a limit of images one can put in the watch's xcassets? So frustrating...
I was also facing same issue where spinner on real devices was never ending.
This was because watch extension and watch app were missing arm64 architecture, make sure you select Standard Architectures(armv7 and arm64)in build setting.
Here is what you could do/check:
You should use the xcassets that is located in your WatchKit app, not the one in your WatchKit extension.
Build and run your main iPhone app as the primary target once.
Yeah, i've been struggling with this too...
the only way i found : i click on digital crownd of the AppleWath, then re-tap on my app and magically the app launching (and the debugger work.)
if this is not working the hard way : Reboot xcode, Clean, if still not working same as you clean, restart devices... this is so annoying.
first solution take less time, and work 7/10 times
if someone knows a beter solution i'll take it !! ;-)

Submitting the Apple Watch app

I am trying to submit an iOS App + Apple watch extension to the App Store.
I selected the app as my target, created an archive (Product > Archive).
I clicked on the archive in Window > Organizer and clicked Export (I am using the Application loader to submit the app).
I selected "Save for iOS App Store Deployment"
In the next window (in Binary and Entitlements), I expected to see the the app and the watchkit extension. But I see only the app. Why is this ? Is it expected ? Or did I miss some setting change somewhere ?
Because this is a very special piece of application, and you can not just simply submit the application like the way you used to do.
The differences are the total number of provisioning profile. Without WatchKitExtension, a provisioning profile is enough. However, you have to apply for three different application identifiers and three different provisioning profile in order to let the Xcode to detect you actually have your phone app, watch app and watch extension.
So, what you need to do is really simple. Just create two more app identifiers based on the bundle identifier you saw from the WatchApp target and WatchExtension target. Then, create two more provisioning profile. Last step, import them into your Xcode. And you are good to go.

OSX Today Extension without containing app

I'm not understanding if a containing app is needed alongside a Today Extension for OSX. I have a very simple and straightforward widget, it does not need nor rely on a main or containing app. With that said, how can I create an Today Extension without a containing app.
What I have so far is that I have a blank app with a today extension.
You cannot create a today extension without having an app. They don't work that way. All iOS app extensions are just that-- extensions to an app. There must be an app, and it must do something to be accepted into the app store (Apple rejects apps for "minimal functionality"). Extensions cannot exist on iOS outside of an app bundle, until or unless Apple decides to change things in the future.
A container app is not needed. Read up the Apple documentation on it. It says:
To deliver an OS X app extension, it’s recommended that you submit your containing app to the App Store, but it’s not required.

Resources