2016-09-23

How to fix Cocoapod command: pod update --verbose failed?

[Problem]

StevenCs-MacBook-Pro:src StevenC$ pod update --verbose
Update all pods
  Preparing

Re-creating CocoaPods due to major version update.

Updating local specs repositories

Updating spec repo `master`
[!] Failed to connect to GitHub to update the CocoaPods/Specs specs repo - Please check if you are offline, or that GitHub is down

/Users/StevenC/.rvm/gems/ruby-2.2.1/gems/cocoapods-core-1.0.1/lib/cocoapods-core/github.rb:105:in `rescue in modified_since_commit'
/Users/StevenC/.rvm/gems/ruby-2.2.1/gems/cocoapods-core-1.0.1/lib/cocoapods-core/github.rb:100:in `modified_since_commit'
/Users/StevenC/.rvm/gems/ruby-2.2.1/gems/cocoapods-core-1.0.1/lib/cocoapods-core/master_source.rb:32:in `requires_update?'
/Users/StevenC/.rvm/gems/ruby-2.2.1/gems/cocoapods-core-1.0.1/lib/cocoapods-core/master_source.rb:14:in `update'
/Users/StevenC/.rvm/gems/ruby-2.2.1/gems/cocoapods-1.0.1/lib/cocoapods/sources_manager.rb:88:in `block (2 levels) in update'
/Users/StevenC/.rvm/gems/ruby-2.2.1/gems/cocoapods-1.0.1/lib/cocoapods/user_interface.rb:63:in `section'
/Users/StevenC/.rvm/gems/ruby-2.2.1/gems/cocoapods-1.0.1/lib/cocoapods/sources_manager.rb:87:in `block in update'
/Users/StevenC/.rvm/gems/ruby-2.2.1/gems/cocoapods-1.0.1/lib/cocoapods/sources_manager.rb:86:in `each'
/Users/StevenC/.rvm/gems/ruby-2.2.1/gems/cocoapods-1.0.1/lib/cocoapods/sources_manager.rb:86:in `update'
/Users/StevenC/.rvm/gems/ruby-2.2.1/gems/cocoapods-1.0.1/lib/cocoapods/installer/analyzer.rb:220:in `block in update_repositories'
/Users/StevenC/.rvm/gems/ruby-2.2.1/gems/cocoapods-1.0.1/lib/cocoapods/installer/analyzer.rb:218:in `each'
/Users/StevenC/.rvm/gems/ruby-2.2.1/gems/cocoapods-1.0.1/lib/cocoapods/installer/analyzer.rb:218:in `update_repositories'
/Users/StevenC/.rvm/gems/ruby-2.2.1/gems/cocoapods-1.0.1/lib/cocoapods/installer.rb:147:in `block in resolve_dependencies'
/Users/StevenC/.rvm/gems/ruby-2.2.1/gems/cocoapods-1.0.1/lib/cocoapods/user_interface.rb:63:in `section'
/Users/StevenC/.rvm/gems/ruby-2.2.1/gems/cocoapods-1.0.1/lib/cocoapods/installer.rb:146:in `resolve_dependencies'
/Users/StevenC/.rvm/gems/ruby-2.2.1/gems/cocoapods-1.0.1/lib/cocoapods/installer.rb:114:in `install!'
/Users/StevenC/.rvm/gems/ruby-2.2.1/gems/cocoapods-1.0.1/lib/cocoapods/command/update.rb:60:in `run'
/Users/StevenC/.rvm/gems/ruby-2.2.1/gems/claide-1.0.0/lib/claide/command.rb:334:in `run'
/Users/StevenC/.rvm/gems/ruby-2.2.1/gems/cocoapods-1.0.1/lib/cocoapods/command.rb:50:in `run'
/Users/StevenC/.rvm/gems/ruby-2.2.1/gems/cocoapods-1.0.1/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'
/Users/StevenC/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval'

/Users/StevenC/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>'

[soluton]:

add the following command parameter
--no-repo-update

so you should use:    pod update --verbose --no-repo-update

2016-09-22

Apple Officially Disable the Settings URL Scheme Only Allow in Custom Keyboard Extension



Since iOS 10, iOS developer can not use URL Scheme to open Settings in their own iOS apps.


The reason is URL schemes for iPhone/iPad Settings are considered Private API which against the Apple Developer Guide.

iOS 10,  here is the only way to open settings in Apple iOS Developer's app:

Use the const string to open App's own setting:

In Swift:
UIApplication.sharedApplication().openURL(NSURL(string:UIApplicationOpenSettingsURLString)!)
In Objective-C
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
So don't waste time to search the solution for the "jump" or "redirect" users to specific settings with traditional way.


But one more interesting things: on  iOS 10 simulator, you can still working the "redirect" users to settings with the following method.




For more details: Apple Developer Technical Q&A QA1924

Reference Doc: Full List Of Settings URL schemes


FYI:

I am developing a Today Widget to open user's WiFi & Mobile Usage Settings, it really working fine on iOS 9 or earlier version and partially tested in iOS 10 beta Simulator with XCode 8.

When I prepare to publish this app on Apple Store, iOS 10 released, I tested my widget on my iPhone 5 16G real device, my nightmare coming. You can imaging how dark is it to me!!!

I searched on Google & stackoverflow one week try to find a solution. Until now, I wrote this article for those who want to do the same thing as me.

Don't Waste Time on Settings URL Scheme Solution!

Thank You Apple, you ruined my first app on Apple Store!

I quit my job to start a studio and try to make small system level app to improve user's experience.

Now it seem I should do another thing. how bad it is!

and my bad luck is not stopped, I purchased iPhone 6S for my mum, but the phone is broken, can not connect to WiFi and Bluetooth, I had to wait for returned from the apple repair factory.

2016-09-19

FBAudienceNetwork Facebook Audience Network Crash 4.15.0 SDK Fatal Crash on iOS 10

Crash Happened on 

FBAdPlacementDefinition.m line 110
__47-[FBAdPlacementDefinition ingestPlacementData:]_block_invoke.103


Error:

2016-09-20 09:51:39.826 XXXAPP[40863:1427254] -[__NSMallocBlock__ countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x61000005e810
2016-09-20 09:51:39.829 XXXAPP[40863:1427254] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSMallocBlock__ countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x61000005e810'
*** First throw call stack:
(
0   CoreFoundation                      0x000000011425134b __exceptionPreprocess + 171
1   libobjc.A.dylib                     0x0000000113cb221e objc_exception_throw + 48
2   CoreFoundation                      0x00000001142c0f34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3   CoreFoundation                      0x00000001141d6c15 ___forwarding___ + 1013
4   CoreFoundation                      0x00000001141d6798 _CF_forwarding_prep_0 + 120
5   XXXAPP                         0x000000010e6b88c8 __47-[FBAdPlacementDefinition ingestPlacementData:]_block_invoke.103 + 207
6   libdispatch.dylib                   0x000000011495d980 _dispatch_call_block_and_release + 12
7   libdispatch.dylib                   0x00000001149870cd _dispatch_client_callout + 8
8   libdispatch.dylib                   0x00000001149678d6 _dispatch_main_queue_callback_4CF + 406
9   CoreFoundation                      0x00000001142154f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
10  CoreFoundation                      0x00000001141daf8d __CFRunLoopRun + 2205
11  CoreFoundation                      0x00000001141da494 CFRunLoopRunSpecific + 420
12  GraphicsServices                    0x0000000116148a6f GSEventRunModal + 161
13  UIKit                               0x0000000111895f34 UIApplicationMain + 159
14  XXXAPP                         0x000000010e5f202f main + 111
15  libdyld.dylib                       0x00000001149d368d start + 1
16  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException


Solution:
The reason is FBAudienceNetwork Issues.
Try to update to  FAN  4.15.1 

Google Firebase Admob GADBannerView Fail to receive Ad





@property(nonatomic,strong)GADBannerView  *bannerView;
@end

@implementation ViewController

- (void)viewDidLoad {
   ....
    [GADMobileAds configureWithApplicationID:@"ca-app-pub-YYYYYYY~YYYYYYY"];
    _bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
    _bannerView.center = CGPointMake(self.view.center.x, _adSize.size.height/2.f + 44/2.f + 50/2.f);
    _bannerView.adUnitID = @"ca-app-pub-XXXXXXXXXX/XXXXXXXX";
    _bannerView.rootViewController = self;
    _bannerView.delegate = self;
    
    GADRequest * request = [GADRequest request];
    request.testDevices = @[kGADSimulatorID];
    [_bannerView loadRequest:request];
    [self.view addSubview: _bannerView];
}


#pragma mark - 
- (void)adViewDidReceiveAd:(GADBannerView *)bannerView {
    NSLog(@"Admob Ad was loaded and ready to be displayed");
}

- (void)adView:(GADBannerView *)bannerView didFailToReceiveAdWithError:(GADRequestError *)error {
    NSLog(@"Admob Ad failed to load");
}

Error:

Error Domain=com.google.ads Code=13 "Request Error: Received invalid response." UserInfo={NSLocalizedDescription=Request Error: Received invalid response., NSLocalizedFailureReason=Request Error: Received invalid response.}

Solution:

1. Make Sure your  adUnitID and ApplicationID are correct.
2. Add  request.testDevices = @[kGADSimulatorID]; 
3. iOS 9 or iOS 10 app please in Info.plist  add "App Transport Security Settings" - "Allow Arbitrary Loads" set to "Yes"

You will get the test ads





2016-09-18

iOS 10 Today Extension(Today Widget) can not jump to WiFi settings.

Even if you can run the following code on iPhone simulator.

#pragma mark - Action
-(IBAction)actionSetting:(id)sender {
    NSURL * urlWiFiSetting = [NSURL URLWithString://@"prefs:root=WIFI"
                              @"prefs:root=MOBILE_DATA_SETTINGS_ID"
                              ];
    if (urlWiFiSetting) {
        [self.extensionContext openURL:urlWiFiSetting completionHandler:^(BOOL success) {
        }];
    } else {
        NSAssert(true, @"Not Support UIApplicationOpenSettingsURLString");
    }}

But when you run it on real device, you may get the following error:

2016-09-19 02:49:59.564568 Today Extension[4633:766201] __55-[_NCWidgetExtensionContext openURL:completionHandler:]_block_invoke failed: Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"

(lldb) 


iOS 10 Apple disable the shortcut for app to jump into.

No way to fix this issue, unless you can report a bug to Apple Bug Report system.



2015-06-14

How to get facebook like button objectID?

open the following link, put your url for like after = sign.

https://graph.facebook.com/?ids=http://appcofe.blogspot.com

you will get the following JSON data:

{
   "http://appcofe.blogspot.com": {
      "id": "http://appcofe.blogspot.com"
   }
}