having problems running unit tests in xcode after updating cocapods - ios

Well, I updated cocoapods, added a new unit test pod that I wanted to try out, and I am unable to run even the most simple unit test.
It doesn't seem to be an issue with the pod but probably after I updated cocoapods to the newest version then did pod update.
Here's the error I get, basically the error is when I try and pull in any class from my main target into my tests.
a full size version: http://i.stack.imgur.com/x5EQP.png
uncomment the lines that are commented out and I get the error, otherwise cmd+U will run and succeed.
#import "AppDelegateTests.h"
//#define EXP_SHORTHAND
//#import "Expecta.h"
//#import "AppDelegate.h"
#implementation AppDelegateTests {
// AppDelegate *_appDelegate;
}
- (void)setUp
{
[super setUp];
// _appDelegate = [[AppDelegate alloc] init];
}
- (void)test_rootViewController_should_be_SplitViewController {
// expect(1).to.equal(1);
}
- (void)tearDown
{
// Tear-down code here.
[super tearDown];
}
#end

Related

Getting 'PhotoEditorSDK/PhotoEditorSDK.h' file not found' error in react native

I'm trying to install this -- PhotoEditorSDK, I followed the documentation exactly but keep getting 'PhotoEditorSDK/PhotoEditorSDK.h' file not found error that causes build to be failed. Just to be clear, this is exactly how I tried to install this framework:
(1) Inside my ios folder, I run command pod init
(2) I edit my Podfile like so:
platform :ios, '9.0'
target 'nearbie' do
pod 'PhotoEditorSDK'
end
(3) Run pod install command
(4) This is what my .xcworkspace looks like after step (3), and I also created PESDKModule.h & PESDKModule.m files as well as draged ios_license license file there, as circled in the picture:
(5) The content of PESDKModule.h & PESDKModule.m are copied from demo app's .xcworkspace file like this:
PESDKModule.h:
#import <React/RCTBridgeModule.h>
#import <React/RCTEventEmitter.h>
#interface PESDKModule : RCTEventEmitter <RCTBridgeModule>
#end
PESDKModule.m:
#import "PESDKModule.h"
#import <React/RCTUtils.h>
#import <PhotoEditorSDK/PhotoEditorSDK.h>
#interface PESDKModule () <PESDKPhotoEditViewControllerDelegate>
#end
#implementation PESDKModule
RCT_EXPORT_MODULE(PESDK);
RCT_EXPORT_METHOD(present:(NSString *)path) {
PESDKPhotoEditViewController *photoEditViewController =
[[PESDKPhotoEditViewController alloc] initWithData:[NSData dataWithContentsOfFile:path] configuration:[[PESDKConfiguration alloc] init]];
photoEditViewController.delegate = self;
UIViewController *currentViewController = RCTPresentedViewController();
dispatch_async(dispatch_get_main_queue(), ^{
[currentViewController presentViewController:photoEditViewController animated:YES completion:NULL];
});
}
#pragma mark - IMGLYPhotoEditViewControllerDelegate
- (void)photoEditViewController:(PESDKPhotoEditViewController *)photoEditViewController didSaveImage:(UIImage *)image imageAsData:(NSData *)data {
[photoEditViewController.presentingViewController dismissViewControllerAnimated:YES completion:^{
[self sendEventWithName:#"PhotoEditorDidSave" body:#{ #"image": [UIImageJPEGRepresentation(image, 1.0) base64EncodedStringWithOptions: 0], #"data": [data base64EncodedStringWithOptions:0] }];
}];
}
- (void)photoEditViewControllerDidCancel:(PESDKPhotoEditViewController *)photoEditViewController {
[photoEditViewController.presentingViewController dismissViewControllerAnimated:YES completion:^{
[self sendEventWithName:#"PhotoEditorDidCancel" body:#{}];
}];
}
- (void)photoEditViewControllerDidFailToGeneratePhoto:(PESDKPhotoEditViewController *)photoEditViewController {
[self sendEventWithName:#"PhotoEditorDidFailToGeneratePhoto" body:#{}];
}
#pragma mark - RCTEventEmitter
- (NSArray<NSString *> *)supportedEvents {
return #[ #"PhotoEditorDidSave", #"PhotoEditorDidCancel", #"PhotoEditorDidFailToGeneratePhoto" ];
}
#end
But when I try to build the project, I get error like this (located inside PESDKModule.m file):
I'm not sure about the use of Cocoapods within React Native. Our demo used the manual installation steps, described in our docs. Could you try linking the PhotoEditor SDK using these steps instead of Cocoapods?

Cordova iOS : Add method call in AppDelegate.m

I am building an app with cordova/ionic for iOS
For multiple reasons we have to put code inside generated application() of AppDelegate.m.
I allready found some similar question, but no answer yet.
https://stackoverflow.com/questions/36792158/cordova-phonegap-ios-modify-generated-appdelegate
There is a way to do it properly with some overloading or extending ?
The simple answer is "I can edit the AppDelegate.m" but since it's a generated file in the project, i can not do it.
Any ideas ?
Maybe you can use runtime to add new method in AppDelegate.m
for example
#interface testViewController (){
AppDelegate *m_appDelegate;
}
#implementation testViewController
- (void)viewDidLoad {
[super viewDidLoad];
m_appDelegate = [AppDelegate new];
// add new method in AppDelegate.m
[self addMethod];
// call new method in AppDelegate.m
[m_appDelegate performSelector:#selector(join)];
}
- (void)addMethod{
BOOL addSuccess = class_addMethod([AppDelegate class], #selector(join), (IMP)happyNewYear, "v#:");
}
void happyNewYear(id self,SEL _cmd){
NSLog(#"new method");
}
-(void)join{
NSLog(#"in the join %s",__func__);
}
hope it helps.

pebbleCentral:watchDidConnect never gets called on iOS

I have an old Pebble Classic watch, upgraded to latest firmware (3.8.2) and using latest Pebble-SDK.
I have followed the few simple steps to install SDK, setup an Xcode project and adding the code to initialise and connect:
https://developer.getpebble.com/guides/mobile-apps/ios/
My problem is, that the delegate method pebbleCentral:watchDidConnect never gets called!
I am using the Pebble Time app on the iPad to install the watchApp in the watch, so I know the iPad is connected to the watch. The same iPad runs the iOS app, which apparently does not discover the watch.
I have tried to import an old test project from a colleague, who had it running a year or two ago. Same watch, same watchApp, but of course older firmware and SDK versions. Same result...
I think the documentation on the pebble site is quite simple and easy to follow. However, I feel I am missing some explanations of how and when this watchDidConnect is supposed to be triggered.
I am most likely missing some simple step somewhere, but I am quite lost in where to look!
Any ideas are welcome!
EDIT: My code looks like this:
ViewController.h:
#import <UIKit/UIKit.h>
#import PebbleKit;
#interface ViewController : UIViewController<PBPebbleCentralDelegate>
#end
ViewController.m:
#import "ViewController.h"
#interface ViewController ()
#property (weak, nonatomic) PBWatch* connectedWatch;
#end
#implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
[PBPebbleCentral defaultCentral].delegate = self;
[[PBPebbleCentral defaultCentral] run];
NSLog(#"Pebble initialised");
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)pebbleCentral:(PBPebbleCentral*)central watchDidConnect (PBWatch*)watch isNew:(BOOL)isNew {
NSLog(#"Pebble connected: %#", [watch name]);
self.connectedWatch = watch;
}
- (void)pebbleCentral:(PBPebbleCentral*)central watchDidDisconnect:(PBWatch*)watch {
NSLog(#"Pebble disconnected: %#", [watch name]);
if ([watch isEqual:self.connectedWatch]) {
self.connectedWatch = nil;
}
}
#end
Are you calling the -run method, after setting up your Pebble central? I noticed that the code snippet in the link you posted does not show the central's delegate being set.
[PBPebbleCentral defaultCentral].delegate = self; // Set your delegate
[PBPebbleCentral defaultCentral].appUUID = [[NSUUID alloc] initWithUUIDString:#"Your Pebble App UUID"]; // Set the app UUID
[[PBPebbleCentral defaultCentral] run]; // Call -run on the central

Xcode Error with youtube api (api#channel) registration conflicts with GTLDriveChannel

My ViewController code is as follows
#import "ViewController.h"
#import <GTLServiceYouTube.h>
#interface ViewController ()
#end
#implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
GTLServiceYouTube *g=[[GTLServiceYouTube alloc] init];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
For the above code i receive the following error.
GTLDriveChannel (api#channel) registration conflicts with
GTLCalendarChannel GTLPlusDomainsAcl (plus#acl) registration conflicts
with GTLPlusAcl GTLPlusDomainsActivity (plus#activity) registration
conflicts with GTLPlusActivity GTLPlusDomainsActivityFeed
(plus#activityFeed) registration conflicts with GTLPlusActivityFeed
GTLPlusDomainsComment (plus#comment) registration conflicts with
GTLPlusComment GTLPlusDomainsCommentFeed (plus#commentFeed)
registration conflicts with GTLPlusCommentFeed GTLPlusPeopleFeed
(plus#peopleFeed) registration conflicts with GTLPlusDomainsPeopleFeed
GTLPlusPerson (plus#person) registration conflicts with
GTLPlusDomainsPerson GTLPlusPlace (plus#place) registration conflicts
with GTLPlusDomainsPlace GTLStorageChannel (api#channel) registration
conflicts with GTLDriveChannel
My podfile configuration is listed below
target 'VideoApp', :exclusive => true do
pod "youtube-ios-player-helper", "~> 0.1"
pod 'Google-API-Client'
end
Nothing helpful here too. https://groups.google.com/forum/#!topic/google-api-objectivec-client/cW2TIBZ7mwA
In the developer console two apis are enabled.
I already implemented my own wrapper for YouTube Data API, you can use it if you wish, it is simple :)
https://github.com/muhammadbassio/YouTubeAPI3-Objective-C-wrapper

Xcode Unit Tests - Can't add new test, because it isn't run

I'm learning Unit testing in Xcode.
The Xcode generated the template for me, but when I added a new test method it doesn't run.
Why? I allready out of my head. I dont know why and I cant find any solution.
#import <XCTest/XCTest.h>
#interface TesttestTests : XCTestCase
#end
#implementation TesttestTests
-(void)setUp
{
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
}
-(void)tearDown
{
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
-(void)testExample
{
XCTFail(#"No implementation for \"%s\"", __PRETTY_FUNCTION__);
}
-(void)newtest{
XCTAssert(false, #"This'll be false");
}
So I added the last method, but my test class doesn't recognize it. WHY?
In order for Xcode to recognize that it is a test, you need to start the test method's name with "test". Try this:
- (void)testNew {
XCTAssert(false, #"This'll be false");
}

Resources