[Runtime crash] running test swift project
See original GitHub issueI have a full swift app, with some unit tests. Here my BUCK file. It works fine for building and running the app on the simulator. But I got a runtime crash when I want to run the tests.
buck test :chatApp
apple_library(
name = 'SnapKit',
visibility = ['PUBLIC'],
srcs = glob([
'Pods/SnapKit/**/*.swift',
]),
frameworks = [
'$SDKROOT/System/Library/Frameworks/UIKit.framework',
'$SDKROOT/System/Library/Frameworks/Foundation.framework'
],
)
apple_asset_catalog(
name = 'GRPCAssets',
app_icon = 'AppIcon',
dirs = ['grpc-go-chat/Assets.xcassets'],
)
apple_resource(
name = 'grpc-go-chatAppResources',
files = glob(['grpc-go-chat/*.png', 'grpc-go-chat/**/*.storyboard']),
)
apple_bundle(
name = 'chatApp',
binary = ':grpc-go-chatAppBinary',
extension = 'app',
info_plist = 'grpc-go-chat/Info.plist',
tests = [':appTests'],
deps = [':SnapKit'],
)
apple_binary(
name = 'grpc-go-chatAppBinary',
deps = [':grpc-go-chatAppResources', ':SnapKit'],
srcs = glob([
'grpc-go-chat/**/*.swift'
]),
frameworks = [
'$SDKROOT/System/Library/Frameworks/UIKit.framework',
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
]
)
apple_package(
name = 'grpc-go-chatAppPackage',
bundle = ':chatApp',
)
apple_test(
name = 'appTests',
test_host_app = ':chatApp',
info_plist = 'grpc-go-chatTests/Info.plist',
srcs = [
'grpc-go-chatTests/grpc_go_chatTests.swift'
],
frameworks = [
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
'$SDKROOT/System/Library/Frameworks/UIKit.framework',
'$PLATFORM_DIR/Developer/Library/Frameworks/XCTest.framework',
],
)
Here the error I got :
Building... 0.4 sec
[2017-12-18 16:21:26.111][error][command:null][tid:465][com.facebook.buck.cli.Main] Uncaught exception at top level
java.lang.NullPointerException
at java.util.Objects.requireNonNull(Objects.java:203)
at java.util.Optional.<init>(Optional.java:96)
at java.util.Optional.of(Optional.java:108)
at com.facebook.buck.apple.AppleTestDescription.createTestHostInfo(AppleTestDescription.java:496)
at com.facebook.buck.apple.AppleTestDescription.createBuildRule(AppleTestDescription.java:233)
at com.facebook.buck.apple.AppleTestDescription.createBuildRule(AppleTestDescription.java:84)
at com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer.transform(DefaultTargetNodeToBuildRuleTransformer.java:88)
at com.facebook.buck.rules.SingleThreadedBuildRuleResolver.lambda$requireRule$0(SingleThreadedBuildRuleResolver.java:111)
at com.facebook.buck.rules.SingleThreadedBuildRuleResolver.computeIfAbsent(SingleThreadedBuildRuleResolver.java:84)
at com.facebook.buck.rules.SingleThreadedBuildRuleResolver.requireRule(SingleThreadedBuildRuleResolver.java:107)
at com.facebook.buck.swift.SwiftLibraryDescription.createCompanionBuildRule(SwiftLibraryDescription.java:391)
at com.facebook.buck.apple.AppleLibraryDescription.lambda$requireSingleArchUnstrippedBuildRule$8(AppleLibraryDescription.java:587)
at java.util.Optional.flatMap(Optional.java:241)
at com.facebook.buck.apple.AppleLibraryDescription.requireSingleArchUnstrippedBuildRule(AppleLibraryDescription.java:585)
at com.facebook.buck.apple.AppleLibraryDescription.requireUnstrippedBuildRule(AppleLibraryDescription.java:546)
at com.facebook.buck.apple.AppleLibraryDescription.createLibraryBuildRule(AppleLibraryDescription.java:441)
at com.facebook.buck.apple.AppleTestDescription.createTestLibraryRule(AppleTestDescription.java:411)
at com.facebook.buck.apple.AppleTestDescription.createBuildRule(AppleTestDescription.java:251)
at com.facebook.buck.apple.AppleTestDescription.createBuildRule(AppleTestDescription.java:84)
at com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer.transform(DefaultTargetNodeToBuildRuleTransformer.java:88)
at com.facebook.buck.rules.SingleThreadedBuildRuleResolver.lambda$requireRule$0(SingleThreadedBuildRuleResolver.java:111)
at com.facebook.buck.rules.SingleThreadedBuildRuleResolver.computeIfAbsent(SingleThreadedBuildRuleResolver.java:84)
at com.facebook.buck.rules.SingleThreadedBuildRuleResolver.requireRule(SingleThreadedBuildRuleResolver.java:107)
at com.facebook.buck.rules.ActionGraphCache$2.visit(ActionGraphCache.java:330)
at com.facebook.buck.rules.ActionGraphCache$2.visit(ActionGraphCache.java:327)
at com.facebook.buck.graph.AbstractBottomUpTraversal.traverse(AbstractBottomUpTraversal.java:36)
at com.facebook.buck.rules.ActionGraphCache.createActionGraphSerially(ActionGraphCache.java:332)
at com.facebook.buck.rules.ActionGraphCache.createActionGraph(ActionGraphCache.java:264)
at com.facebook.buck.rules.ActionGraphCache.getActionGraph(ActionGraphCache.java:167)
at com.facebook.buck.rules.ActionGraphCache.getActionGraph(ActionGraphCache.java:68)
at com.facebook.buck.cli.TestCommand.runWithoutHelp(TestCommand.java:549)
at com.facebook.buck.cli.AbstractCommand.run(AbstractCommand.java:232)
at com.facebook.buck.cli.AbstractContainerCommand.run(AbstractContainerCommand.java:79)
at com.facebook.buck.cli.BuckCommand.run(BuckCommand.java:82)
at com.facebook.buck.cli.Main.runMainWithExitCode(Main.java:1101)
at com.facebook.buck.cli.Main.runMainThenExit(Main.java:395)
at com.facebook.buck.cli.Main.nailMain(Main.java:1855)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.martiansoftware.nailgun.NGSession.run(NGSession.java:329)
In my tests I need to import my app to test the API like this:
@testable import grpc_go_chat
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Addressing crashes from Swift runtime errors - Apple Developer
Identify the signs of a Swift runtime error, and address the crashes runtime errors cause. Overview. Swift uses memory safety techniques to catch...
Read more >Runtime crash "outlined init with take of any ..." #61403 - GitHub
Describe the bug Crash in Release mode or if Optimization Level of Swift Compiler - Code Generation is Optimize for Speed [-O].
Read more >Weird runtime crash using protocol primary associated types
It runs fine in Debug mode but crashes in Release mode (or if optimization level is Optimise for Speed [-O] ). The crash...
Read more >Tests in Xcode won't execute with a run-time error
Every time I try to run tests, on any project, I get a strange run-time error. I added this function to a totally...
Read more >Local unit tests with Xcode - Marcin Krzyżanowski
Put unit tests next to tested Swift code, and run tests from the same Xcode target.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am facing the same right now and really upset about it… 😦
@v-jizhang, that would be great!