Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-11524] XCTest fails to import for iOS after generate-xcodeproj #4659

Closed
swift-ci opened this issue Sep 26, 2019 · 2 comments
Closed

[SR-11524] XCTest fails to import for iOS after generate-xcodeproj #4659

swift-ci opened this issue Sep 26, 2019 · 2 comments
Labels

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-11524
Radar None
Original Reporter SDGGiesbrecht (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Swift 5.1, Xcode 11, Mojave

Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels Bug
Assignee None
Priority Medium

md5: 0e27e1549b37839f4dd2835a07ce14ed

Issue Description:

If a package uses XCTest in a normal target (not a test target), it fails to build in the generated Xcode project for iOS and tvOS. Here is an example such target:

import XCTest
open class SpecializedTestCase : XCTestCase {
    open override func setUp() {
        print("Doing specialized set‐up...")
    }
}
  • Opening in Xcode by double‐clicking Package.swift and building for iOS will succeed, both the device and simulator.

  • generate-xcodeproj and then building for iOS or tvOS succeeds for the simulator.

But:

  • generate-xcodeproj and then building for iOS or tvOS fails for the device.

The exact error is:

ld: warning: Could not find or use auto-linked framework 'XCTest'
Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_XCTestCase", referenced from:
      type metadata for MyTarget.SpecializedTestCase in SpecializedTestCase.o
  "_OBJC_METACLASS_$_XCTestCase", referenced from:
      _OBJC_METACLASS_$__TtC18MyTarget8SpecializedTestCase in SpecializedTestCase.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Additional notes:

  • #if canImport(XCTest) does not help.

  • macOS works fine, but it has no device‐simulator distinction.

  • watchOS does not work in this situation at all, but that is a separate bug.

@swift-ci
Copy link
Contributor Author

Comment by Jeremy David Giesbrecht (JIRA)

Originated from this forum thread:

https://forums.swift.org/t/distinguish-package-vs-xcode-project-with-if/29190

@swift-ci
Copy link
Contributor Author

swift-ci commented May 4, 2021

Comment by Jeremy David Giesbrecht (JIRA)

generate-xcodeproj is deprecated now anyway.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant