ios10 UIImagePickerController crashes randomly. What is the easiest fast fix can be? - uikit

When I used UIImagePickerController on ios <= 9, I didn't see any issues.
On ios 10 I got strange message. I noticed this massage appear after using any code from Photos.framework. (for example checking PHPhotoLibrary status )
Class PLBuildVersion is implemented in both
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices
(0x12049a910) and
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices
(0x1202c4210). One of the two will be used. Which one is undefined.
I found similar issue on stackoverflow
Class PLBuildVersion is implemented in both frameworks
I didn't pay attention about it to some moments while I begin get randomly such crash
(about 1 crash on 15-20 using of UIImagePickerController):
I'm not sure but I think it depend on log message(i.e message above).
It's sdk bug and issue have opened on Apple Radar.
Here my code for invoking UIImagePickerController:
self.imagePicker = [[UIImagePickerController alloc] init];
self.imagePicker.delegate = self;
self.imagePicker.allowsEditing = allowEditing;
self.imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[vc presentViewController: self.imagePicker animated: YES completion: nil];
My main question is: How can I resolve this issue right now? (Seems like Apple didn't hurry up to resolve it).
I wouldn't like creating custom image picker (without 100% working guarantee)
Are somebody faced with such issue?
Thanks in advance.

I decided try open source alternative for UIImagePickerController.
I go through list in this post How to select Multiple images from UIImagePickerController and integrated this one CTAssetsPickerController.
Log message still appear, but I'm testing it, there are no any issues for now.

Related

Custom URL Scheme for Settings on iOS 10?

Any Idea what happened to the Setting's Custom URL Scheme on iOS 10?
Is Apple still giving acess to third-pary apps to launch iOS Settings from the app via URL Scheme on iOS10? The Old URL scheme are not working anymore!
None of the previous methods for launching the root "Settings" app on iOS 8+ were officially supported by Apple, so unfortunately we can't rely on them. It's also possible that apps that relied on the undocumented behaviors could be rejected during App Store review, even if others have been approved--even if the same app had been previously approved!
I've been unable to discover any workaround either, so it seems your choices are:
Open the app-specific URL (as detailed in many places, including #alvin-varghese 's answer above), and then ask the user to navigate backwards. (A terrible user experience, since it involves the user knowing to scroll up from the app list into the main settings sections.)
Use an instructional screen or alert in your app to educate users on how to find it themselves. (Not much better, but at least aren't dropped into an unfamiliar context with no waypoints.)
There doesn't seem to be an officially supported way of making this happen in iOS 10, and as you pointed out, it seems like the old ways (adding prefs scheme to your Info.plist file and using openURL(_:)) do not work any more.
From iOS 10 some of the things are changed,
So, for something like bluetooth you need to write below lines of code,
Swift 3.0 :
func openBluetoothSettings(){
let urlBTSet = URL(string: "App-Prefs:root=Bluetooth")
let objApp = UIApplication.shared
objApp.openURL(urlBTSet!)
}
Objective-c
-(void) openBluetoothSettings{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"App-Prefs:root=Bluetooth"]];
}
So, In above code what they have changed is string need to add "App-Prefs:root=Bluetooth" (This the example of opening bluetooth settings)
Don't forgot : 'Goto taget -> info -> URL Types -> Add "prefs" in URL Schemes'
Use this one, it works.
if let url = URL(string: UIApplicationOpenSettingsURLString) {
UIApplication.shared().open(url, options: [:], completionHandler: nil)
}

Xcode keeps pausing my music

First of all i know this is a programming forums, but my problem concerns Xcode and the problem happens with me while CODING.
When i use Xcode, when it is stopped in breakpoints while debugging the sound of the music played ( in my Mac music player ) is gone !!! i know this is awkward but it happens. Does any one has a solution or at least a reason for this?
After googling this problem i just found one case talking about the same problem here in this Link
I'm not using Spotify like the case in the link i'm using another music player called Vox
I have changed Vox and changed it with Deezer and it has the same problem
Update 1
As mentioned in the Accepted Answer, This problem only happened while using Cocos2dx in Xcode, When i returned back to the use Xcode with just iOS sdk without the Cocos2dx this problem doesn't exist any more.
This is happening when your capture audio session in your application and debug something.
The case to reproduce this using Xcode + simulator (on device you will have phone's audio session, so it can not be reproduced with the following snippet). Sometimes it stops just after breakpoint occurs, sometimes - after about a minute (i think, session expires after that time, or something like that)
Create empty project and override didFinishLaunchingWithOptions
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSError *setCategoryError = nil;
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &setCategoryError];
if (setCategoryError) // set breakpoint here
NSLog(#"Error setting category! %#", setCategoryError);
return YES;
}
I think, on breakpoint session somehow stops music playing. so - check your project for the code, which manipulates with audio session (AVAudioSession).
Hope, this helps.
I had the same issue and I figured it had something to do with CocosDenshion. Do you use it? If so, try to not create a CDSoundEngine. Does it fix the issue? You could create it only in your release build.
Had the same problem, super annoying.
Fixed it by routing sound through soundflower.
https://github.com/mLupine/SoundflowerBed/releases
Then install soundflower bed:
https://github.com/mattingalls/Soundflower/releases/tag/2.0b2
Look for the soundflower icon in your menu bar on the right, select your output device of choice, then go to your sound options and select soundflower as the output.
Hope that helps!
The Simulator is the iOS/watchOS/tvOS user space running on the host mac kernel, so it shares its audio subsystem with the mac. When stopped in the debugger none of the audio callbacks can be serviced. I suspect this happens when you have an active audio session with active callbacks.
Please file a bug at https://bugreport.apple.com and provide a sample project if you can.

The app references non-public selectors in Payload/TabletJournal.app/TabletJournal: setImageName:

I am updating my app to iOS7 due to some code rot... add subview for AlertView mainly.
That is all fixed, as well as a few other things.
The issue... I am getting this warning message when I attempt to validate the update:
What? I have searched through my code and there is nothing that matches this. The only thing close is "imageName" or "imageNamed", which is standard for a UIView.
I cannot believe that those are now part of a private API.
I have even commented out some code that is a part of some custom built security controller, that I thought might be offending... no difference. This same controller is also used in another app, that validated just fine.
So... I am at a loss to know what this is.
I have no 3rd-party Frameworks in the app. And, it has been on the store since 2010, without any changes since the last update in April of this year.
What the __ is going on???
Would appreciate any help.
Thanks...
I'm guessing that it is your UIAlertView issue.
Apple made some changes in the alertView, they have simplified it to be flat. So you can't add any subview to it. if you did somehow maybe thats the reason.
I was subclassing the UIAlertView and now I can't. Try to put the regular UIAlertView

Programmatically launch Mac Calendar.app (and choose specific date) from my app?

I'd like to include a button in my Mac app which, when pressed, will launch the user's default calendar app. Preferably, I'd like to have the calendar open to a certain date.
This is for OS X Mountain Lion.
Is there a general way to do this?
Edit:
FWIW, this is what I'm doing now:
- (IBAction)launchCalendarApp:(id)sender
{
[[NSWorkspace sharedWorkspace] launchApplication:#"/Applications/Calendar.app"];
}
I know hardcoding the path like this is a bad idea which is why I'm asking the question.
Update:
This is what I ended up doing:
- (IBAction)launchCalendarApp:(id)sender
{
NSWorkspace *sharedWorkspace = [NSWorkspace sharedWorkspace];
NSString *iCalPath = [sharedWorkspace absolutePathForAppBundleWithIdentifier:#"com.apple.iCal"];
BOOL didLaunch = [sharedWorkspace launchApplication:iCalPath];
if (didLaunch == NO) {
NSString *message = NSLocalizedString(#"The Calendar application could not be found.", #"Alert box message when we fail to launch the Calendar application");
NSAlert *alert = [NSAlert alertWithMessageText:message defaultButton:nil alternateButton:nil otherButton:nil informativeTextWithFormat:#""];
[alert setAlertStyle:NSCriticalAlertStyle];
[alert runModal];
}
}
It sounds like all of the possible ways of doing this are workarounds until a better API is developed. My solution is similar to Jay's suggestion. I'm using the bundle identifier to get the path because I think it is a little less brittle. Apple is unlikely to change the bundle ID in the future even if they (or the user) decides to rename the app. Unfortunately, this method doesn't get me to a specific date. I will investigate further some of the other suggestions (using ical:// etc.) when I have more time.
Update 2:
NSGod has a terrific answer below that also opens the Calendar to a specific date provided your app is not sandboxed.
Note: I was still researching this while you updated with what you used, but I'll add this FWIW.
Using the bundle identifier of the application is generally a more robust way to refer to an app then using the name alone, as a user could move or rename the app in OS X, but they can't easily change the bundle identifier. Moreover, even while Apple renamed iCal.app to Calendar.app, the CFBundleIdentifier is still com.apple.iCal.
if (![[NSWorkspace sharedWorkspace]
launchAppWithBundleIdentifier:#"com.apple.iCal"
options:NSWorkspaceLaunchDefault
additionalEventParamDescriptor:nil
launchIdentifier:NULL]) {
NSLog(#"launching Calendar.app failed!");
}
The above code will work even if your app is sandboxed. You could potentially try to create a custom NSAppleEventDescriptor that would specify the equivalent of something like the following AppleScript code, but it will likely be denied because of the sandbox:
view calendar at date "Sunday, April 8, 2012 4:28:43 PM"
If your app doesn't have to be sandboxed, it's much easier if you use the Scripting Bridge, and with that method it's possible to select a specific NSDate.
Sample project using ScriptingBridge: OpenCalendar.zip
In that project, I use the following code:
SBCalendarApplication *calendarApp = [SBApplication
applicationWithBundleIdentifier:#"com.apple.iCal"];
[calendarApp viewCalendarAt:[self.datePicker dateValue]];
That will launch Calendar.app/iCal.app and change the calendar to the specified date.
So it sounds like for now you'd either have to resort to a hard wired approach, e.g.
// Launches Calendar.app on 10.7+
[[NSWorkspace sharedWorkspace] launchApplication:#"Calendar"];
Or use the URL scheme using what's supported by Calendar/iCal on OS X (pointed out by NSGod in comments below) similar to URL Scheme for opening the iCal app at a date or event?
:
// Launches iCal (works at least with 10.6+)
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:#"ical://"]];
You might try using EventKit to create a EKCalendarItem instance of the desired date and time, open the event, then remove it immediately thereafter. If it's well-timed, it may not even visibly blink on/off the user's calendar.
It's another kludge, but until NSWorkspace has an -openDate: method, kludges are the only recourse.
As discussed on this thread, it seems there's no url scheme to launch iCal
URL Scheme for opening the iCal app at a date or event?

How do I send SMS without launching Text application?

I am developing a simple application which has to send an SMS message from the app itself instead of launching the native Text app.
Here's my action now. What should I change to achieve my desired functionality?
-(IBAction)startButtonPressed
{
NSString *phoneNumber = #"13136296693";
NSString *url = [NSString stringWithFormat: #"sms:%#",phoneNumber];
NSLog(#"Send SMS to: %# ", url);
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}
Thanks!
Thomas
If I'm not mistaken I think sending text messages via your own application is only available in the iPhone 4.0 SDK.
Can't be done with the current SDK. I believe Apple announced that applications in iPhone OS 4.0 will be able to do this, using a similar interface to the existing MFMailComposeViewController malarkey.
Here's what apple says:
https://web.archive.org/web/20140604143837/http://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/SystemMessaging_TopicsForIOS/Articles/SendinganSMSMessage.html
Here's a tutorial fon another forum.
http://iosdevelopertips.com/core-services/how-to-send-an-sms-progammatically.html
It's still not entirely automated. The user has to tap the send button. I haven't gotten it working yet. Tell me if you have better luck. If you can think of a way for me to program my app to "tap" the send button instead of the user, let me know.

Resources