UI Testing xCode 7.3 - Cannot print variables (i.e 'po app') in the console: (could not build Objective-C module 'Bolts') - ui-testing

I have UI testing project set up and was working perfectly in xCode 7.2. Since I upgraded to xCode 7.3 I cannot print any variables in the console. I set breakpoints in both Application (main project) and UI Test, 'po' command works in the main project but as soon as it reaches UI testing the 'po' command stop working. I have tried almost all the solutions I could find on the internet but still no luck. It complains about the Objective-C module 'Bolts' that I am not using at all in UI testing. Below is how the error message looks like:
(lldb) po app
error: Error in auto-import:
failed to get module 'MyUITestProject' from AST context:
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "Headers/Bolts-umbrella.h"
^
/Users/../Pods/Target Support Files/Bolts/Bolts-umbrella.h:7:9: note: in file included from /Users/../Pods/Target Support Files/Bolts/Bolts- umbrella.h:7:
#import "BFAppLinkReturnToRefererController.h"
^
/Users/../Pods/Bolts/Bolts/iOS/BFAppLinkReturnToRefererController.h:14:9: error: include of non-modular header inside framework module 'Bolts.BFAppLinkReturnToRefererController'
#import <Bolts/BFAppLinkReturnToRefererView.h>
...
...
Is there anyone run into the same issue? Does anyone knows what cause this failure and any advice?

Delete:
/Users/{User}/Library/Developer/Xcode/DerivedData
and then restart your Xcode.

Related

Xcode 11 debugger crashes on breakpoint, can't find Foundation.h

My macOS app compiles and runs fine, but since switching to Xcode 11, I can no longer debug from breakpoints. The debugger always crashes with a bunch of messages like this:
warning: Swift error in scratch context: /foobar/Foo-Bridging-Header.h:14:9: note: in file included from /foobar/Foo-Bridging-Header.h:14:
#import "TPPreciseTimer.h"
^
error: /foobar/Timer/TPPreciseTimer.h:9:9: error: 'Foundation/Foundation.h' file not found
#import <Foundation/Foundation.h>
^
/foobar/Timer/TPPreciseTimer.h:9:9: note: did not find header 'Foundation.h' in framework 'Foundation' (loaded from '/System/Library/Frameworks')
#import <Foundation/Foundation.h>
^
error: failed to import bridging header '/foobar/Foo-Bridging-Header.h'
.
Shared Swift state for Foo has developed fatal errors and is being discarded.
REPL definitions and persistent names/types will be lost.
Message from debugger: The LLDB RPC server has crashed. The crash log is located in ~/Library/Logs/DiagnosticReports and has a prefix 'lldb-rpc-server'. Please file a bug and attach the most recent crash log.
Anyone know a workaround for something like this?
My coworkers still on Xcode 10.3 are not having this issue with the same codebase.
Same here. Removing /Users/{user}/Library/Developer/Xcode/DerivedData directory helped.

Use leveldb-library.framework from firebase for iOS with Xcode9

I would like to be able to use the leveldb-library.framework that google is shipping with their firebase iOS SDK. I don't seem to be able to import the framework.
What I did:
1: copy leveldb-library.framework to project dir
2: in Xcode > Target > Linked Frameworks and Libraries [+] add the framework
3: make sure the header search path it set correctly
4: add a Objective-C++ wrapper class and import the leveldb headers
Getting a linker error:
/Users/ronny/projects/clients/internal/TestCD/TestCD/LevelDB.mm:11:9: fatal error: 'leveldb/db.h' file not found
#import "leveldb/db.h"
^~~~~~~~~~~~~~
1 error generated.
The Headers directory in the framework provides all the headers: db.h, options.h but without the "leveldb" parent directory.
Changing the imports to the following throws the same error:
#import <leveldb/db.h>
#import <leveldb/options.h>
Once I change the imports to this:
#import <leveldb-library/db.h>
#import <leveldb-library/options.h>
the linker is able to find the includes but throws another error:
In file included from /Users/ronny/projects/clients/internal/TestCD/TestCD/LevelDB.mm:11:
/Users/ronny/projects/clients/internal/TestCD/leveldb-library.framework/Headers/db.h:10:10: fatal error: 'leveldb/iterator.h' file not found
#include "leveldb/iterator.h"
^~~~~~~~~~~~~~~~~~~~
1 error generated.
At this point I am no longer sure what can be done in order to resolve this. Adding the import path doesn't help either. Xcode completes the import as such:
Any pointers towards solving this would be greatly appreciated. The project can be found here: https://github.com/ronnyf/TestCD
The framework expects to be called leveldb, but your example calls it leveldb-library.
mv leveldb-library.framework leveldb.framework
mv leveldb.framework/leveldb-library leveldb.framework/leveldb
Update the Xcode project with the renamed framework and it successfully builds.

Cocoapod fails to build on Travis-CI - "expected a type"

Objective: Build a cocoapod with CI support through travis-ci and coveralls.
Sub Objective: Keep git repo cleared of Pods/, while still including Podfile and Podfile.lock
Referenced repo: SRRandomUser
note: while indeed there exists a simple workaround solution (just removing Pod/ from my .gitignore, I ask this question because it will likely be helpful to understand this issue for future work.
Here is the situation I find myself in:
Using FSNetworking for network requests.
One of its classes, FSNData, has a class method withImage:jpegQuality:fileName: that accepts a UIImage and CGFloat as parameters.
Building this file without adding #import for UIKit and CoreGraphics results in a compiler error of expected a type with reference to the UIImage and CGFloat parameters
Locally, this is not a problem because I can add the module #imports, however since I am not committing the entirety of the Pods/ directory, these changes don't get pushed
Travis received the build and attempts to build, but since the FSNData doesn't have CoreGraphics or UIKit imported, when Travis goes to build the project, it throws the error in SRRandomUserGenerator since that class is #importing the affected FSNData class:
✗ Compile SRRandomUserGenerator.m (73 ms)
In file included from /Users/travis/build/spacedrabbit/SRRandomUser/Random Strangers/SRRandomUser/SRRandomUser/SRRandomUserAPIManager.h:10:
In file included from /Users/travis/build/spacedrabbit/SRRandomUser/Random Strangers/SRRandomUser/../../Pods/Headers/Public/FSNetworking/FSNConnection.h:36:
/Users/travis/build/spacedrabbit/SRRandomUser/Random Strangers/SRRandomUser/../../Pods/Headers/Public/FSNetworking/FSNData.h:42:18: error: expected a type
+ (id)withImage:(UIImage*)image jpegQuality:(CGFloat)quality fileName:(NSString*)fileName;
^
/Users/travis/build/spacedrabbit/SRRandomUser/Random Strangers/SRRandomUser/../../Pods/Headers/Public/FSNetworking/FSNData.h:42:46: error: expected a type
+ (id)withImage:(UIImage*)image jpegQuality:(CGFloat)quality fileName: (NSString*)fileName;
^
2 errors generated.
So, my questions are:
How do I either silence that warning so that the build runs anyhow or
How do I get that Pod to include the correct frameworks for building?
Many thanks in advance, SO.
I would recommend trying to search for the framework you need via Cocoapods.org. If you're using Cocoapods it usually means that it's been linked to your project (so there's really no way to silence the error, especially in this case where it seems that the framework you're using depends on other frameworks)

XCode 5 unit testing: starts my app

When I run my tests in XCode 5, the main window of my OS X app appears on the screen for a couple of seconds while running the tests. Why? Even if I uncomment all my tests it still opens my main window.
You are running application test, not logic test. This means an instance of your app will be started and then run the unit tests. This allow you to perform some integration test that require your app is running.
Here is the guide to setup application test and logic test.
If you want to change it to logic test (so it run faster and don't need to start your app first):
go to build settings for your unit test target
search Bundle
remove Bundle Loader and Test Host
Thats right, you have to delete the "Bundle Loader" and "Test Host" from your build settings.
But you have to add the necessary implementation files to your unit test target. The necessary files are what you want to use in your unit test cases. You need to do this because in logic tests XCode wont compile the whole application. So some of your files will be missing.
This is en error message if you have left out a file:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_Module", referenced from:
objc-class-ref in Lobic Network.o
objc-class-ref in Logic_Unit.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
You can add the missing files by selecting the implementation file and bringing up the file inspector. There will be a section named "Target Membership" and there you can set the files target membership to your unit test also.
With XCTest, application files DO NOT need to be included within XCTest targets. The XCTest bundle is linked against the application which makes those files available during runtime.
To make this work, ensure the compiler option "Symbols hidden by default" is set to NO Within the Application target.
Here is a blog post with screenshots for clarity:
http://zmcartor.github.io/code/2014/02/24/slim-xctest-targets
The advantage of this approach is test target builds much much faster.
In XCode 7, removing Host Application does not work for me. Indeed I use the following to avoid app runs.
Setup Test Scheme Arguments
in main.m
static bool isRunningTests()
{
NSDictionary* environment = [[NSProcessInfo processInfo] environment];
NSString* testEnabled = environment[#"TEST_ENABLED"];
return [testEnabled isEqualToString:#"YES"];
}
modify main()
int main(int argc, char * argv[]) {
#autoreleasepool {
if (isRunningTests()) {
return UIApplicationMain(argc, argv, nil, nil);
} else {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
}
If the tests are for code that can run on desktop and mobile, you can run them without a simulator or hosting them within your app.
The trouble is that you cannot use the scheme chooser for your normal target (desktop or iOS) to run the test.
The following worked for me in Xcode6.
File > New Target...
Select Cocoa Testing Bundle from the OS X category.
Take care to select None from the target drop-down.
Click Finish. Add the relevant files to the new target as described above.
Now create a scheme to run the test.
Click the schemes chooser top-right and choose New Scheme..., click the drop-down and navigate down the list to the new target. Now you can choose the scheme from the schemes chooser, and use ⌘U to run the tests.
I just wasted a morning on this.
Project was created in XCode 4 and used SenTesting.
Tried migrating tests on XCode 5/XCTTest
Had same issue - app ran in simulator and test never started
after trying everything (change from app to logic tests, change to XCTest, remove SenTesting)
gave up created a clean XCode 5 project.
Added all my files in and tests ran ok.
May still have issues with Storyboard as these were built with XCode 4.
Drastic but it works so keep it as last resort.
On XCode5, the app does start. This answer shows how to change its delegate when running unit tests so that it exits right away: https://stackoverflow.com/a/20588035/239408

getting error while programming star tsp650 in objective c

When I add the starIO.framework and try to run my application it says that #include <starmicronics/Platform.h could not be found. I checked the framework to confirm that the file was there and it was dont know why I am getting this error. I even tried to download the framework again and install it again. However it is still coming out to could not be found .
The starmicronics/Platform.h is inside the StarIO.framework..
You have to use #import