I am new to the Kitura and Xcode and facing some issues when adding test files.
It seems to be related to the #testing directive.
I have setup the same as shown on Kitura website.
When I invoke in the console swift build then swift test I get following error:
Compile Swift Module 'testTests' (1 sources)
Linking ./.build/debug/testPackageTests.xctest/Contents/MacOS/testPackageTests
Undefined symbols for architecture x86_64:
"__TFC4test3OkoCfT_S0_", referenced from:
__TFC9testTests8OkoTests8test_addfT_T_ in OkoTests.swift.o
"__TMaC4test3Oko", referenced from:
__TFC9testTests8OkoTests8test_addfT_T_ in OkoTests.swift.o
ld: symbol(s) not found for architecture x86_64
<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: build had 1 command failures
error: exit(1): /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Users/*user*/Projects/Kitura/test/.build/debug.yaml test
However when I comment out line #testable import test and type swift build then swift test then I get following error:
Compile Swift Module 'testTests' (1 sources)
/Users/*user*/Projects/Kitura/test/Tests/testTests/OkoTests.swift:6:17: error: use of unresolved identifier 'Oko'
let o = Oko()
^~~
<unknown>:0: warning: 'cacheParamsComputed' is deprecated
<unknown>:0: warning: 'cacheAlphaComputed' is deprecated
<unknown>:0: warning: 'keepCacheWindow' is deprecated
<unknown>:0: error: 'memoryless' is unavailable
Metal.MTLCommandBufferError:19:14: note: 'memoryless' has been explicitly marked unavailable here
case memoryless
^
<unknown>:0: error: build had 1 command failures
error: exit(1): /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Users/*user*/Projects/Kitura/test/.build/debug.yaml test
When I try to test it from Xcode generated project instead (swift package generate-xcodeproj) then I get compile error:
Without Testing files, everything works properly.
Below I present project structure:
I believe the issue is that Swift is not able to compile unit tests for modules that contain a main.swift file (i.e., modules that are meant to be compiled into executables as opposed to libraries for use in other projects). I cloned your repo and was able to compile and run unit tests after 1) removing main.swift and 2) uncommenting the testable import statement.
Related
I installed swift toolchain using instructions from swift.org. While compiling helloworld code I am getting below error.
warning: 'helloworld': failed loading cached manifest for 'helloworld': disk I/O error
error: 'helloworld': Invalid manifest
<unknown>:0: error: unable to open output file '/usr2/xyz/.cache/clang/ModuleCache/IJ5GUC7XMAO5/SwiftShims-1TLN9ZL6HKTHR.pcm': 'No such file or directory'
<unknown>:0: error: could not build C module 'SwiftShims'
I tried removing '/usr2/xyz/.cache/clang/ModuleCache', but did not work. Please help in resolving this issue.
I'm trying to run the 'example-package-dealer' from the Swift Package Manager repo but it's failing to build resulting with this error:
/usr/local/include/string.h:26:10: error: 'dpkg/macros.h' file not found
#include <dpkg/macros.h>
<unknown>:0: error: could not build Objective-C module 'Darwin'
Im trying to use an older xcode toolchain (3.1) with my latest xcode version (10).
Starting with a blank project and trying to build I get the following error.
<unknown>:0: error: unknown argument: '-enable-batch-mode'
<unknown>:0: error: unknown argument: '-enforce-exclusivity=checked'
<unknown>:0: error: unknown argument: '-index-store-path'
Command CompileSwiftSources failed with a nonzero exit code
When I look at the compiler output I can clearly see these parameters being passed (cropped for brevity).
/Library/Developer/Toolchains/swift-3.1-RELEASE.xctoolchain/usr/bin/swiftc **-incremental -module-name MyTestApp -Onone -enable-batch-mode -enforce-exclusivity=checked** -DDEBUG -sdk
Is it possible to tell the compiler to ignore these parameters or remove them somehow?
I had considered building with CLI and cobbling the buuild command together but I need the source to be running in xcode so I can debug an issue with a legacy project.
In the end I just downloaded an older version of xcode and also downloaded device support for my new ios device..... which the older xcode didnt support.
I'm currently trying to add support for the Swift Package Manager to a side-project I've been working on and am running into trouble when trying to run the unit tests I have for the project.
When running them within XCode, I have no problem building and running all of my unit tests; however, when I try to run my tests with the package manager using swift test, I get the following linker error:
ld: symbol(s) not found for architecture x86_64
<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)
I ended up figuring out a solution that I'm happy with. I've added a link to the PR here that fixed things, but the general solution was to create a new shared framework target that both my executable and test targets linked to!
With Swift DEVELOPMENT-SNAPSHOT-2016-02-08-a, I'm trying to build a project using swift build but as soon as I add the line import Foundation I get the error:
[I] ~/Dropbox/Projects/test
↪ swift build --clean; and swift build
Compiling Swift Module 'test' (1 sources)
<unknown>:0: error: cannot load underlying module for 'CoreGraphics'
<unknown>:0: note: did you forget to set an SDK using -sdk or SDKROOT?
<unknown>:0: note: use "xcrun -sdk macosx swiftc" to select the default OS X SDK installed with Xcode
<unknown>:0: error: build had 1 command failures
error: exit(1): ["/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-02-08-a.xctoolchain/usr/bin/swift-build-tool", "-f", "/Users/me/Dropbox/Projects/test/.build/debug/test.o/llbuild.yaml"]
Running xcrun -sdk macosx results in "no such SDK: 'machos'" error:
↪ xcrun -sdk macosx swift build 0#10:34:03
<unknown>:0: warning: no such SDK: 'macosx'
<unknown>:0: warning: no such sysroot directory: 'macosx'
<unknown>:0: error: cannot load underlying module for 'Darwin'
error: exit(1): ["/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-02-08-a.xctoolchain/usr/bin/swiftc", "--driver-mode=swift", "-I", "/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-02-08-a.xctoolchain/usr/lib/swift/pm", "-L", "/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-02-08-a.xctoolchain/usr/lib/swift/pm", "-lPackageDescription", "-target", "x86_64-apple-macosx10.10", "/Users/me/Dropbox/Projects/test/Package.swift"]
This is with only main.swift, whose contents are:
import Foundation
print("Hello, world!")
No dependencies are defined in Packages.swift.
Really don't know what's going on here. This compiles fine on my Ubuntu 14.04 DigitalOcean VPS as well as within Xcode 7.3 Beta 5.
OS X 10.11.3
↪ swift --version 0#10:21:16
Apple Swift version 3.0-dev (LLVM a7663bb722, Clang 4ca3c7fa28, Swift 1c2f40e246)
Target: x86_64-apple-macosx10.9
Do you have the stable release of Xcode.app in your [/Applications] directory? If you just have Xcode-beta.app, that's likely what's causing this error. Try creating a symlink of Xcode-beta.app to Xcode.app:
$ ln -s /Applications/Xcode-beta.app /Applications/Xcode.app
(Kudos to anton for the answer).