Sunday, March 11, 2018

ERROR ITMS-90717 while uploading app

While I was uploading my app to Apple App Store using Xcode 9, the following error appear:

ERROR ITMS-90717: "Invalid App Store Icon. The App Store Icon in the asset catalog in "xx.app" can't be transparent nor contain an alpha channel".

To resolve this error, you need to

1. Remove the alpha (i.e., the transparency attribute) in the image file. This can be done easily.

1.1. Double click on your app icon and the image will appear Preview app.
1.2. Choose File \ Export.
1.3. Untick "Alpha" (as shown below).



1.4. Click Save.

So, you have done the first step.

2. Regenerate all the icon file in various dimension.

3. Replace all the icon files in your project.

4. Last step, update the Images.xcassts file by dragging all appropriate
 icon file.

To check if all icon files have been updated, open the following directory in Finder. Ensure that all icon files' date/time matches the date/time that was done in step 2.

    [your app] \ Images.xcassets \  AppIcon.appiconset

5. Build and upload your app.

ERROR ITMS-90029 while uploading using Xcode 9

While I was uploading my app and encountered this error:

ERROR ITMS-90029: "Storyboard file 'Main~iphone.storyboardc' was not found. Please ensure that the specified file is included in the bundle with any required device modifiers appended to the filename".

What happened..? My app supports iPad only and how come it prompted an error on missing iPhone storyboard..?

I guess, there is some problem caused by upgrading the project. Why "Main~iphone.storyboardc"? I opened the .plist file and found this:

    Main storyboard file base name: "Main" <=== this value shown in the error message.
    Main storyboard file base name: "StoryboardV2" <== this is correct value.

Anyway, the problem can be rectify by

1. Opening the Target > your app. Look for "Devices" in the Deployment Info section. For my case, my value is "iPad".

2. Changing the "iPad" value to "Universal".

3. Set the Main Interface to any value.

4. Click on any source code file to force the new values to be saved to .plist.

5. Open the Devices in the Deployment Info section again.

6. Change the values back to "iPad" and the correct Main Interface value.

7. Archive and upload my app to App Store and the error has gone.







Sunday, July 30, 2017

Local or remote user notification

To use the local or remote user notification, first you need to add the reference to the UserNotifications framework.

   @import UserNotifications;

The most important is this code before using the user notification framework - you must get the user consent

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
    center.delegate = self;

    [center requestAuthorizationWithOptions:UNAuthorizationOptionAlert | UNAuthorizationOptionBadge | UNAuthorizationOptionSound
                         completionHandler:^(BOOL granted, NSError* err) {
                             if (granted) {
                                 NSLog(@"granted notif");
                             }
                             
                         }];
    
    return YES;

}

For the "center.delegate = self" to work, you need to implement this protocol in the AppDelegate class:

    UNUserNotificationCenterDelegate

To schedule a local user notification, please use the following sample code which I found in the Internet:

- (IBAction)schedule_click:(id)sender {
    
    UNMutableNotificationContent *localNotification = [UNMutableNotificationContent new];
    localNotification.userInfo = [NSDictionary dictionaryWithObjectsAndKeys:@"User1",@"Username", nil];
    localNotification.badge = [NSNumber numberWithInt:1];
    
    localNotification.sound = [UNNotificationSound defaultSound];
    
    // load the pre-defined mp3
    //localNotification.sound = [UNNotificationSound soundNamed:@"my.mp3"];
    
    localNotification.categoryIdentifier = @"myReminder";
    localNotification.body = @"Reminder to test";
    
    NSDate *date = [[NSDate date] dateByAddingTimeInterval:60];
    
    NSCalendar *gregorian = [[NSCalendar alloc]initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
    
    /*NSCalendarUnitDay – Will set the repeatInterval to daily */
    NSDateComponents *dateComponents = [gregorian components:NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitTimeZone fromDate:date];
    
    UNCalendarNotificationTrigger *datetrigger = [UNCalendarNotificationTrigger triggerWithDateMatchingComponents:dateComponents repeats:YES];
    UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:@"Some Unique Value"
                                                                          content:localNotification
                                                                          trigger:datetrigger];
    
    UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
    [center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
        NSLog(@"added notif. Error= %@",error);
    }];

}


Say something... text to speech in iOS

In iOS, there is a text to speech framework which is able to say the text that you have typed.

The reference that you need in order to use the text to speech classes:

    @import AVFoundation;

Sample code:

    AVSpeechSynthesizer* speaker = [[AVSpeechSynthesizer alloc] init];
    AVSpeechUtterance* u = [[AVSpeechUtterance alloc] initWithString:@"Good morning. Boss."];

    u.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"en-US"];
    

    [speaker speakUtterance:u];


To get the list of the supported languages.

    NSArray<AVSpeechSynthesisVoice *> * v  = [AVSpeechSynthesisVoice speechVoices];
    
    AVSpeechSynthesisVoice* v2;
    for (int i = 0; i < v.count; i++) {
        v2 = [v objectAtIndex:i];
        NSLog(@"voice lang id=%@, code=%@", v2.identifier, v2.language);
    }

Please take note that there is duplicate entry for the same language code. This is because it has male and female voices and the identifier to the voice is different (i.e., unique). You need to call voiceWithIentifier method instead of voiceWithLanguage.

Tuesday, April 29, 2014

Creating multiple apps from one project

If you are planning to publishing multiple apps from one project (for example, light version and premium version), this will be the article that can help you out.

1. Click Manage Scheme.

2. Untick the "autocreate schemes" option. By unchecking this option, you can assign a proper scheme name.

3. Click on the project Targets. Two finger click on the "taget item" that you want to duplicate.

4. A new plist file will be added to the project. Rename the plist file to whatever you want. In our case, we use "premium version". Do the same for the "Bundle display name" and also "Bundle identifier".

  Note: you need two app ID. One for the light version and another for premium version.

5. Goto the project targets again. Rename the target to "premium". In Build Settings, search for "Product name" and update it as well.

6. Search "plist" in Build Settings and change it to the appropriate plist file name.

7. Click on the "scheme" and choose New Scheme.

8. Choose the "premium" from the target and then key in "premium" as the scheme name.

9. The final step will be setup the preprocessor macros. You need to edit both Debug and the Release.

  • For premium version, add "IS_PREMIUM_VERSION".
  • For light version, add "IS_LIGHT_VERSION".

10. In the coding, you have to do this:

 
     #ifdef IS_PREMIUM_VERSION
         lbl.text = @"this is premium Verison";
     #else
         lbl.text = @"this is Light version";
     #endif

Saturday, April 26, 2014

Find the user document directory in Simulator

One day, I want to backup my Sqlite database created inside the Simulator to my MacBook data directory and I was wondering if this is possible. Yes, it is possible. The files that was created in Simulator is physically located in your MacBook.

You can find the physical directory with the codes below:

  NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  NSString *documentsDirectory = [paths objectAtIndex:0];

Sample output:

  /Users/{your Macbook user name}/Library/Application Support/iPhone Simulator/7.1/Applications/{random number}/Documents

Monday, September 2, 2013

Submitting your app to iTunes Connect

The following article contains the information on how to submit your app to iTunes Connect. The most important for the first time submission in the app statuses and also how to resolve the test case done by the QA.

https://developer.apple.com/library/ios/documentation/LanguagesUtilities/Conceptual/iTunesConnect_Guide/10_ManagingYourApplications/ManagingYourApplications.html