Uploaded image for project: 'Swift'
  1. Swift
  2. SR-5986

`swift test` induces an error "undefined reference to 'objc_retainAutoreleasedReturnValue'" when calls `CFStringConvertEncodingToIANACharSetName(_: )` on Linux

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Done
    • Component/s: Compiler, XCTest
    • Labels:
    • Environment:
      • OS: Ubuntu 16.04
      • Swift 4.0

      Description

      [How to reproduce the error] (shell on Linux)

      $ mkdir cf-swift
      $ cd cf-swift
      $ swift package init --type library
      $ cat <<EOF >> Sources/cf-swift/cf_swift.swift
      > import CoreFoundation
      > import Foundation
      > struct Dummy {
      >   static let string: String? = {
      >     let cfEncoding : CFStringEncoding = CFStringConvertNSStringEncodingToEncoding(String.Encoding.utf8.rawValue)
      >     guard let _ = CFStringConvertEncodingToIANACharSetName(cfEncoding) else { return nil }
      >     return nil
      >   }()
      > }
      > EOF
      $ swift build
      $ swift test
      

      [Result]
      `swift build` ends without any trouble.
      `swift test` views error messages below:

      Compile Swift Module 'cf_swiftTests' (1 sources)
      Compile Swift Module 'cf_swiftPackageTests' (1 sources)
      Linking ./.build/x86_64-unknown-linux/debug/cf-swiftPackageTests.xctest
      /*/*/cf-swift/Sources/cf-swift/cf_swift.swift:9: error: undefined reference to 'objc_retainAutoreleasedReturnValue'
      clang: error: linker command failed with exit code 1 (use -v to see invocation)
      <unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)
      error: terminated(1): /opt/Swift-4.0/bin/swift-build-tool -f /*/*/cf-swift/.build/debug.yaml test
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                YOCKOW Knock YOCKOW
              • Votes:
                1 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: