Running iOS8 extension on simulator offers no suitable host app - xcode

When I run my ios8 action extension on the iPhone simulator it gives me a list of apps to act as host, but it only offers 'today' and my own app even though I have specified the following in NSExtensionActivationRule in the plist:
NSExtensionActivationSupportsImageWithMaxCount:1
NSExtensionActivationSupportsWebURLWithMaxCount:1
so I would have expected safari, photos etc.

You may want to forego launching the extension directly from the simulator.
I've been debugging extensions all week and what I'd suggest is this (not too long) process:
Launch the app so that your latest version of the extension is
loaded onto the simulator.
Then stop the app so the simulator is not in use.
Attach to the extension via this Xcode menu Item: Debug->Attach to Process->By Process Identifier (PID) or Name
Xcode will now say "Waiting for 'EXTENSION NAME HERE' to start" and may prompt you to "take the appropriate action"
(On the simulator) Launch Safari (or the appropriate app) and interact like you would if Xcode had launched it on your device.
Once your extension is run, Xcode will attach and you can debug
I would recommend binding that menu item to a keyboard shortcut (I used Opt-Shift-Cmd-A because I hate my carpal tunnel) because it's two items down and the stupid attach menu loads all the active process AFTER it opens so the item you want jumps to the top of the screen.
Once you load the extension you can keep re-attaching to it if it crashes without having to relaunch the containing app.
This has sped up my debugging process quite a bit.

Create action extension involves the following three steps
1) Create a Target with "Action extension" template
2) Goto iPhone "Photos" app and choose a photo and click Share icon. It will show "Share" activities(FB, Twitter, etc) and "Action" activities(Copy, Slideshow, etc). Goto end of "Action" activities and click "More" button
3) In the "Activities" page, you have to enable your "Action" extension

Related

How to view crash reports in XCode

I've seen several (e.g. question1, question2, question3) questions about viewing crash reports that don't help me. Since I'm new to Apple development, my questions sort of translates to "is this how I'm supposed to open crash reports?"
Here's what I'm doing:
Open project in Xcode (version 12.4)
Navigate to Window->Organizer and click "Crashes"
Select the release build (1.2) for which I'm trying to view crash reports
Because Xcode shows no crash reports for that particular release (I do see some for older releases), I did this:
Login to App Store Connect
Navigate to App Analytics->MyApp->Crashes
Click "Add Filter" then App Version -> 1.2
This page shows that there have been over 100 crashes for this build in the last month (and they pretty well span the whole month). I am expecting to be able to view a report for each one of these. Is that not necessarily possible?
In response to some of the SO questions I've seen, I've done this:
Navigate to TestFlight->Build 1.2-> Build Metadata to verify I have included Symbols
Navigate to Users and Access->MyAccount to verify I have admin permission and Access to Reports
Restarted Xcode
What else should I be doing?
Under the Window menu, choose "Devices and Simulators". Plug in an iPhone or iPad. Even if the logs are for Mac apps.
Click on the device you plugged in in the left column. To the right find the button "View Device Logs".
In the new window click on "All Logs". You can drag any .ips fils onto the left window to view them. You can right click on any file to symbolicate them.
All this makes me think that someone at Apple has lost their mind.
In my case the symbolicate doesn't work and the logs don't display correctly

Invalid Bundle Error - "requires launch storyboard"

I keep getting this error when I try to submit my app to the store using Xcode:
ERROR ITMS-90475: "Invalid Bundle. iPad Multitasking support requires launch storyboard in bundle 'com.companyname.appname.'"
Anyone know what this error really means?
This is because you need to specify how your app is supposed to handle multitasking on iPad.
If you don't want to handle multitasking right now, you can simply disable it by going to the "General" tab of your target:
I solved the problem in this way, see here:
If you must opt out of Slide Over and Split View, do so explicitly by adding the UIRequiresFullScreen key to your Xcode project’s Info.plist file and apply the Boolean value YES.
You need to add a Launch Screen (Xcode > File > New).
Under iOS > User Interface you select "Launch Screen" to add it to the project.
For the iPad you need to support all 4 orientations.
Select in Xcode your target file, and under the General Tab, go to the "App icons and Launch Images".
Here you select the Launch Screen file you created.
When you launch the app you'll see the launch (bitmap) images are not used, but the Launch Screen Storyboard.
You can either do it as André showed or directly add:
<key>UIRequiresFullScreen</key>
<true/>
On your .plist file.
If you are using Cordova, you might want to use the cordova-ios-requires-fullscreen plugin (see How to disable iOS9 multitasking through Ionic/Cordova?)
Update: you can also use the cordova-plugin-ipad-multitasking, which seems to also prevent another issue (ITMS-90474)
Update: this should now be fixed using Cordova tools 5.4 without the need for these plugins.
In Xcode 14.2, setting the launch storyboard should be as simple as selecting the required storyboard as Launch Screen File in the "General" settings for the target. This not only avoids spelling mistakes, it also ensures that the storyboard is included in the bundle. However, I found that uploading to the App Store failed as per the OP if support for multiple windows is included (that is, if requires full screen is not checked).
If the storyboard has been configured in this way then the problem may be because the name of the storyboard includes a .storyboard extension, which it's not supposed to (see also post by Muhammad Ibrahim). This can be fixed without checking the box for requires full screen:
In Xcode, go to your build target and select the General tab.
In the section "App Icons and Launch Screen", check if a Storyboard file is selected and if it has a .storyboard extension.
If so -> tap the name of the storyboard to edit it, take off the .storyboard extension and press return.
That's it! The name of the storyboard will no longer show, but the problem will be fixed.
IF you ONLY want to set RequiresFullScreen For iPhone, and support iPad Multitasking, try this:
<key>UILaunchStoryboardName~ipad</key>
<string>LaunchScreenIPad.storyboard</string>
<key>UIRequiresFullScreen</key>
<true/>
<key>UIRequiresFullScreen~ipad</key>
<false/>
LaunchScreenIPad.storyboard is the name of LaunchScreen for iPad.
iPhone will still use Launch Images Source pictures.
Apple Document Ref: Creating Platform- and Device-Specific Keys
If you want to support split views in iPad, in your info.plist file, set just "LaunchScreen" as the value for key "UILaunchStoryboardName", instead of "LaunchScreen.Storyboard" and you need to support all 4 orientations for iPad.

Multiple projects using the simulator

I am comparing the run of multiple projects using the Xcode simulator. Each time I go to build in one project after having run one of the other projects Xcode tells me that it cannot perform the build and run because the simulator is in use. I then have to find the other project window, stop the run in the simulator (Cmd-.) and then switch back to the previous window and rebuild. Can I make a single keyboard shortcut to stop the current run in the simulator, build and run the current project in the simulator?
There is a little bit of doing involved in making this happen but overall it's pretty easy.
The first thing you'll want to do is open Automator. Incase you've never used it before, it is included on your mac so just search it. When Automator launches, you will be prompted to create a new project, select "Service."
Then adjust the service receives section as follows
On the left side of Automator, you'll see a search pane, search for "Run Applescript" and then drag the instance of "Run Applescript" under your service receives section.
Now you're going to want to change the applescript to suite your needs. In this case you'll replace "(* Your script goes here *)" with "tell application "iPhone Simulator" to quit"
Once you're done altering the Applescript, save the automation as whatever you'd like, it will show up in Services under this name.
Now you're going to head over to "System Preferences" and search "services"
As you can see, I named my Service "Quit Simulator" select yours and define whatever shortcut you want for it. (Try not to conflict with existing shortcuts!)
And now if you encounter the "Simulator in use" error you can quit the simulator, ending any current process with a simple keystroke.
Hope this helps!
Each run is dependent to their project window (as far as I know). So you'll have to go to the project window and stop the build, or simply quit the Simulator (cmd+q) and build again in your new project.

Browse the files created on a device by the iOS application I'm developing, on workstation?

I'm developing an IOS app that creates files on the device, e.g. with NSKeyedArchiver.
During Android development it's possible to browse a device filesystem when it's connected to your workstation via USB, for instance to help with troubleshooting your app.
However for IOS I don't see anything similar under the Organizer in Xcode, to help me browse files my app creates from the workstation. Googling "iOO browse device files", "iPhone view files" etc. reveals solutions for jailbroken devices but not for regular devices provisioned for development.
How can I browse files on a device created by an iOS app I'm developing?
In Xcode's Organiser, go to your device's Summary tab. Find your application in the list, and click the disclosure triangle. Under it, you should see an icon saying "Application Data". Click the down pointing arrow to download the data, and it'll prompt you for somewhere to save it.
In Xcode 5, listed under your device in Organizer, click on "Applications" and you can see "Data files in Sandbox" in the bottom half of the window.
In Xcode 6, go to Window -> Devices, select the device, select the app name under Installed Apps, click the settings gearbox, then select Download container.... In finder, double finger tap the package and select Show package contents.
In Xcode 6, open the Devices window:
Then, select the app (in Installed Apps) and then click the gear icon and select Download Container.
Pls note, that you can view contents of downloaded .xcappdata container by right click on it and select "Show Package Contents"
iExplorer works like a charm! Just used it to export some app files! http://www.macroplant.com/iexplorer/download-ie3-mac.php
In Xcode9: / Window / Devices and Simulators
Select the desired installed app, click the gear at the bottom and Download container...
In Finder, "right-click" the downloaded file and Show Package Contents to open it in a new Finder window.
I hope it's useful. Peace.
XCode version : 10.2.1
goto window -> Devices and Simulators
and after that choose your device from the left list, choose the app from the installed app, so you can press show container for show app's contains on the new page on xcode, press download container to download it to your OSX, also you can replace an old container to the moment state with Replace container...

How do you debug your application if they got started using a custom URL scheme?

I'm developing an app for the iPhone, but I guess the question is the same on the Mac.
What is your approach to debug the state of your application after it has been launched by its URL scheme?
There is a way to debug your application when it is launched from an external URL:
Set a breakpoint where you want it in application:handleOpenURL: or application:didFinishLaunchingWithOptions:
In Xcode, edit the Active Executable's settings. On the Debugging tab, select the "Wait for next launch/push notification" checkbox.
Build and Debug. The Console will give you an alert saying "Waiting for [AppName] to launch... The debugger will attach to [AppName] the next time it is launched."
Open your app by invoking a custom URL or sending it a push notification. The debugger will stop at your breakpoint.
I'm on Xcode 8.2.1 and the fastest way is to simply go to Product -> Edit Scheme and select “Wait for executable to be launched” like the image below. When debugging started, it will not launch the app but "waiting for "THE APP" to launch..". When an action (click on the push notification), the breakpoint will kick in.
Actually, I think it would be quite different on the Mac than on the iPhone as you can have the application open already on the Mac and call the URL scheme, whereas on the iPhone you need to quit the application to open another to call the URL scheme.
What you could try is adding a debug button to your UI which allows you to call the URL scheme from inside the running application (calling -openURL: on NSWorkspace). This should in theory work the same whether your app is open or closed when the URL scheme is sent.

Resources