Cocoapods: [bug] v1.9.0 - lint failing for podspec that depends on XCTest framework

Created on 28 Feb 2020  路  14Comments  路  Source: CocoaPods/CocoaPods

馃寛

Report

With the latest version (1.9.0) of CocoaPods, running pod lib lint on a podspec that includes XCTest as a framework dependency results in the error:

ld: warning: Could not find or use auto-linked library 'XCTestSwiftSupport'

I have a CocoaPod with two podspecs: one for the framework, and another for unit testing utilities. The framework is here: https://github.com/ww-tech/lasso .

The primary podspec (Lasso.podspec) contains the library files. There's another podspec (LassoTestUtilities.podspec) that depends on the first pod as well as the XCTest framework.

Running pod lib lint on the primary podspec works as expected.
Running pod lib lint on the test utilities podspec results in the error.

This only happens with CodoaPods v1.9.0: v1.8.4 works great.

This also happens for other libraries with similar setups - for example RxSwift (note: I tried linting RxTest.podspec in v5.0.1 of RxSwift).

What did you do?

pod lib lint LassoTestUtilities.podspec

What did you expect to happen?

I expected the podspec to successfully lint (it lints ok with CocoaPods v1.8.4).

What happened instead?

I get the following error in the lint result:

 -> LassoTestUtilities (1.0.1)
    - ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code.
    - NOTE  | xcodebuild:  note: Using new build system
    - NOTE  | [iOS] xcodebuild:  note: Planning build
    - NOTE  | [iOS] xcodebuild:  note: Constructing build description
    - NOTE  | xcodebuild:  ld: warning: Could not find or use auto-linked library 'XCTestSwiftSupport'
    - NOTE  | xcodebuild:  clang: error: linker command failed with exit code 1 (use -v to see invocation)
    - NOTE  | [iOS] xcodebuild:  warning: Skipping code signing because the target does not have an Info.plist file and one is not being generated automatically. (in target 'App' from project 'App')

[!] LassoTestUtilities did not pass validation, due to 1 error.

In the --verbose output, I see the following error:

    Ld /Users/steven/Library/Developer/Xcode/DerivedData/App-ddghdbbkrumxuycytntergoqunad/Build/Intermediates.noindex/App.build/Release-iphonesimulator/App.build/Objects-normal/x86_64/Binary/App normal x86_64 (in target 'App' from project 'App')
        cd /var/folders/jy/1y545m4s3gnfq1_7s6xx6h900000gn/T/CocoaPods-Lint-20200228-72150-xsw2cx-LassoTestUtilities
        /Developer/Xcode_11-3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target x86_64-apple-ios10.0-simulator -isysroot /Developer/Xcode_11-3.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk -L/Users/steven/Library/Developer/Xcode/DerivedData/App-ddghdbbkrumxuycytntergoqunad/Build/Products/Release-iphonesimulator -F/Users/steven/Library/Developer/Xcode/DerivedData/App-ddghdbbkrumxuycytntergoqunad/Build/Products/Release-iphonesimulator -F/Developer/Xcode_11-3.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks -F/Users/steven/Library/Developer/Xcode/DerivedData/App-ddghdbbkrumxuycytntergoqunad/Build/Products/Release-iphonesimulator/Lasso -F/Users/steven/Library/Developer/Xcode/DerivedData/App-ddghdbbkrumxuycytntergoqunad/Build/Products/Release-iphonesimulator/LassoTestUtilities -F/Developer/Xcode_11-3.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks -filelist /Users/steven/Library/Developer/Xcode/DerivedData/App-ddghdbbkrumxuycytntergoqunad/Build/Intermediates.noindex/App.build/Release-iphonesimulator/App.build/Objects-normal/x86_64/App.LinkFileList -Xlinker -rpath -Xlinker /usr/lib/swift -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -Xlinker -rpath -Xlinker @executable_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/steven/Library/Developer/Xcode/DerivedData/App-ddghdbbkrumxuycytntergoqunad/Build/Intermediates.noindex/App.build/Release-iphonesimulator/App.build/Objects-normal/x86_64/App_lto.o -Xlinker -objc_abi_version -Xlinker 2 -fobjc-link-runtime -L/Developer/Xcode_11-3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/steven/Library/Developer/Xcode/DerivedData/App-ddghdbbkrumxuycytntergoqunad/Build/Intermediates.noindex/App.build/Release-iphonesimulator/App.build/Objects-normal/x86_64/App.swiftmodule -framework Lasso -framework LassoTestUtilities -framework XCTest -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/steven/Library/Developer/Xcode/DerivedData/App-ddghdbbkrumxuycytntergoqunad/Build/Intermediates.noindex/App.build/Release-iphonesimulator/App.build/App.app-Simulated.xcent -framework Foundation -framework Pods_App -Xlinker -dependency_info -Xlinker /Users/steven/Library/Developer/Xcode/DerivedData/App-ddghdbbkrumxuycytntergoqunad/Build/Intermediates.noindex/App.build/Release-iphonesimulator/App.build/Objects-normal/x86_64/App_dependency_info.dat -o /Users/steven/Library/Developer/Xcode/DerivedData/App-ddghdbbkrumxuycytntergoqunad/Build/Intermediates.noindex/App.build/Release-iphonesimulator/App.build/Objects-normal/x86_64/Binary/App
    ld: warning: Could not find or use auto-linked library 'XCTestSwiftSupport'
    Undefined symbols for architecture x86_64:
      "__swift_FORCE_LOAD_$_XCTestSwiftSupport", referenced from:
          __swift_FORCE_LOAD_$_XCTestSwiftSupport_$_App in main.o
          __swift_FORCE_LOAD_$_XCTestSwiftSupport_$_App in dummy.o
         (maybe you meant: __swift_FORCE_LOAD_$_XCTestSwiftSupport_$_App)
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

CocoaPods Environment

Stack

   CocoaPods : 1.9.0
        Ruby : ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin18]
    RubyGems : 3.0.6
        Host : Mac OS X 10.14.6 (18G103)
       Xcode : 11.3 (11C29)
         Git : git version 2.24.0
Ruby lib dir : /usr/local/Cellar/ruby/2.6.5/lib
Repositories : cocoapods- - CDN - https://cdn.cocoapods.org/
               ww-digital - git - [email protected]:WW-Digital/ios-cocoapods-specs.git @ 26b87196b07c1b05011341361d5a9400cfbe5e71

Installation Source

Executable Path: /usr/local/bin/pod

Plugins

claide-plugins        : 0.9.2
cocoapods-deintegrate : 1.0.4
cocoapods-keys        : 2.1.0
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.1.0
cocoapods-trunk       : 1.4.1
cocoapods-try         : 1.1.0
slather               : 2.4.7

Note: the same error occurs running Ruby 2.7.

Project that demonstrates the issue

Lasso: https://github.com/ww-tech/lasso

help wanted

Most helpful comment

This is biting us hard on our project(s). Any news on a fix?

All 14 comments

What simulator version are you using?

Simulator v11.3, I believe.

I do have multiple Xcode versions installed for backwards compatibility testing, but my xcode-select is for 11.3.

Possibly related to this https://github.com/CocoaPods/CocoaPods/pull/9500. Currently unable to investigate so any help would be welcome.

Note that I was able to get the test utility podspec to lint by forcing should_apply_xctunwrap_fix to be false in target/build_settings.rb here

At first I though it was because there was a difference between Apple's recommended workaround, and the actual workaround applied in build_settings.rb. The applied framework search paths are different from what Apple recommends (should be /Developer/Library/Frameworks), but fixing that locally didn't fix the linting failure.

I'm now wondering if the extra search paths are only necessary for creating the xcode project files, and not for linting?

I'd really like if we get to the bottom of this. Changing the CocoaPods sources is definitely not recommended as it might break others who dont do this change.

@g-mark 馃う鈥嶁檪 you are right regarding:

The applied framework search paths are different from what Apple recommends (should be /Developer/Library/Frameworks), but fixing that locally didn't fix the linting failure.

Will have a follow up PR.

We did land https://github.com/CocoaPods/CocoaPods/pull/9579 for 1.9.1 but as you said I dont think this fixes the issue.........

I took a look at the temporary workspace & project that pod lib lint generates, and an issue I see is that the spec is treated as an application target dependency rather than a unit test target dependency.

Not sure how CocoaPods < 1.9.0 gets this to work - or how the search paths change comes into play with this - but I think it would work if the dummy project were set up so that the spec was a dependency of a unit test target, since it has a dependency on the XCTest framework.

Also seeing this issue on my pod that uses XCTest. pod _1.8.4_ ... is successful.

This is biting us hard on our project(s). Any news on a fix?

Adding "$(PLATFORM_DIR)/Developer/usr/lib" (where XCTestSwiftSupport lives) to library search paths fixed the issue for us locally. Unsure if this is safe to add to a podspec though 馃槵. Just fixes a local test framework for us. Fix was needed for 1.9.1 (maybe 1.9.0)

We found the issue. Turns out SWIFT_INCLUDE_PATHS is not parsed properly from Xcode I think.

does not work:

SWIFT_INCLUDE_PATHS = $(inherited) "$(PLATFORM_DIR)/Developer/usr/lib"

works:

SWIFT_INCLUDE_PATHS = "$(inherited) $(PLATFORM_DIR)/Developer/usr/lib"

馃う

That's awesome @dnkoutso ! Happy to test it out if you need a hand.

LIBRARY_SEARCH_PATHS = "$(inherited) $(PLATFORM_DIR)/Developer/usr/lib" helped (WITH QUOTES!!!)

Was this page helpful?
0 / 5 - 0 ratings