CocoaPods / CocoaPods

The Cocoa Dependency Manager.
https://cocoapods.org/
Other
14.54k stars 2.63k forks source link

Pod linting fails on XCode 14 with watchOS platform #11558

Closed soumyamahunt closed 1 year ago

soumyamahunt commented 1 year ago

Report

What did you do?

Ran pod lib lint on my pod with Xcode 14.

pod lib lint --platforms=watchos --no-clean --allow-warnings --verbose

What did you expect to happen?

I expected CocoaPods to run linting and tests and succeed if tests passed.

What happened instead?

Although tests succeeded, the command indicated failure with following results:

    ** TEST SUCCEEDED **

    Testing started
 -> AsyncObjects (1.0.0)
    - WARN  | keys: Unrecognized `parallelizable` key for `scheme` attribute.
    - ERROR | [watchOS] xcodebuild: Returned an unsuccessful exit code.
    - NOTE  | [watchOS] xcodebuild:  xcodebuild: error: Unable to find a destination matching the provided destination specifier:
    - NOTE  | xcodebuild:  note: Using codesigning identity override: -
    - NOTE  | [watchOS] xcodebuild:  note: Building targets in dependency order
    - NOTE  | [watchOS] xcodebuild:  Pods.xcodeproj: warning: The watchOS Simulator deployment target 'WATCHOS_DEPLOYMENT_TARGET' is set to 2.0, but the range of supported deployment target versions is 4.0 to 9.0.99. (in target 'OrderedCollections' from project 'Pods')
    - NOTE  | [watchOS] xcodebuild:  note: Metadata extraction skipped. No AppIntents.framework dependency found. (in target 'OrderedCollections' from project 'Pods')
    - WARN  | [watchOS] xcodebuild:  /Users/soumyaranjanmahunt/Documents/personal_projs/AsyncObjects/Tests/AsyncObjectsTests/StandardLibraryTests.swift:33:19: warning: immutable value 'val' was never used; consider replacing with '_' or removing it
    - NOTE  | [watchOS] xcodebuild:  note: Metadata extraction skipped. No AppIntents.framework dependency found. (in target 'AsyncObjects' from project 'Pods')
    - WARN  | [watchOS] xcodebuild:  /Users/soumyaranjanmahunt/Documents/personal_projs/AsyncObjects/Sources/AsyncObjects/CancellationSource.swift:6:62: warning: Topic reference 'init(linkedWith%3A)' couldn't be resolved. No local documentation matches this reference.
    - NOTE  | [watchOS] xcodebuild:  note: Metadata extraction skipped. No AppIntents.framework dependency found. (in target 'AsyncObjects-Unit-Tests' from project 'Pods')

On closer inspection I witnessed error is happening when building with xcodebuild:

-> Pod installation complete! There are 2 dependencies from the Podfile and 2 total pods installed.
   Building with `xcodebuild`. 
    $ /usr/bin/xcodebuild clean build -workspace
    /var/folders/fr/vlmkwkt93s9_0xv6q4hfmppr0000gp/T/CocoaPods-Lint-20220924-88954-1rh4pmz-AsyncObjects/App.xcworkspace
    -scheme App -configuration Release CODE_SIGN_IDENTITY=- -sdk watchsimulator
    -destination id=B01F93BB-ECD5-4F21-9BB9-6C3AFC153A51
    Command line invocation:
        /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild clean build -workspace /var/folders/fr/vlmkwkt93s9_0xv6q4hfmppr0000gp/T/CocoaPods-Lint-20220924-88954-1rh4pmz-AsyncObjects/App.xcworkspace -scheme App -configuration Release CODE_SIGN_IDENTITY=- -sdk watchsimulator -destination id=B01F93BB-ECD5-4F21-9BB9-6C3AFC153A51

    User defaults from command line:
        IDEPackageSupportUseBuiltinSCM = YES

    Build settings from command line:
        CODE_SIGN_IDENTITY = -
        SDKROOT = watchsimulator9.0

    2022-09-24 20:18:42.094 xcodebuild[88976:1465276] Writing error result bundle to /var/folders/fr/vlmkwkt93s9_0xv6q4hfmppr0000gp/T/ResultBundle_2022-24-09_20-18-0042.xcresult
    xcodebuild: error: Unable to find a destination matching the provided destination specifier:
            { id:B01F93BB-ECD5-4F21-9BB9-6C3AFC153A51 }

        The requested device could not be found because no available devices matched the request.

        Available destinations for the "App" scheme:
            { platform:watchOS, id:dvtdevice-DVTiOSDevicePlaceholder-watchos:placeholder, name:Any watchOS Device }
            { platform:watchOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-watchsimulator:placeholder, name:Any watchOS Simulator Device }
            { platform:watchOS Simulator, id:B01F93BB-ECD5-4F21-9BB9-6C3AFC153A51, OS:9.0, name:Apple Watch SE (44mm) (2nd generation) }
            { platform:watchOS Simulator, id:A40285F8-8247-49C6-AAFD-321B88E41658, OS:9.0, name:Apple Watch Series 5 (40mm) }
            { platform:watchOS Simulator, id:AB1C2816-BDFA-4D50-B790-69FA84D167DB, OS:9.0, name:Apple Watch Series 5 (44mm) }
            { platform:watchOS Simulator, id:71CC520D-FD75-43D7-B4E1-08E12F5ED52F, OS:9.0, name:Apple Watch Series 6 (40mm) }
            { platform:watchOS Simulator, id:E08E9ACD-7C2F-4256-B562-B29EDA91D679, OS:9.0, name:Apple Watch Series 6 (44mm) }
            { platform:watchOS Simulator, id:03CD2A9B-050D-4A1A-AEFF-C51504B775A7, OS:9.0, name:Apple Watch Series 7 (41mm) }
            { platform:watchOS Simulator, id:AE2DBAA4-BC7E-4FAD-96EE-887B14B78777, OS:9.0, name:Apple Watch Series 7 (45mm) }
            { platform:watchOS Simulator, id:737D2762-B22C-4998-85DE-EAB420085D88, OS:9.0, name:Apple Watch Series 8 (41mm) }
            { platform:watchOS Simulator, id:DBC3DAD8-1301-4DC3-B7FA-40952ED9966A, OS:9.0, name:Apple Watch Series 8 (45mm) }
            { platform:watchOS Simulator, id:C02DCFDF-D999-46E1-B53C-2A4C34B0EFA5, OS:9.0, name:Apple Watch Ultra (49mm) }
            { platform:iOS Simulator, id:3F0AC861-4587-44D9-B50D-5AB9E7D40696, OS:16.0, name:iPhone 14 }
            { platform:iOS Simulator, id:0F5297C4-5415-4897-AAA9-053510458D4C, OS:16.0, name:iPhone 14 Plus }
            { platform:iOS Simulator, id:E3E51727-DF1B-4FB9-ACA6-98B03C170EC6, OS:16.0, name:iPhone 14 Pro }
            { platform:iOS Simulator, id:0E1252BA-119A-449E-96A8-3BBA90BE4A66, OS:16.0, name:iPhone 14 Pro Max }

This error doesn't make sense as the destination id that is said to be unavailable is present in available destination list for app scheme. And this error only happens for watchOS platform. The complete log when running with GitHub action. available here.

CocoaPods Environment

Stack

   CocoaPods : 1.11.3
        Ruby : ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.arm64e-darwin21]
    RubyGems : 3.0.3.1
        Host : macOS 12.6 (21G115)
       Xcode : 14.0 (14A309)
         Git : git version 2.37.0 (Apple Git-136)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
Repositories : cocoapods - git - https://github.com/CocoaPods/Specs.git @ 38515a13a0e7b1cdfb3f38e19289ca754bd24b09

               trunk - CDN - https://cdn.cocoapods.org/

Installation Source

Executable Path: /usr/local/bin/pod

Plugins

claide-plugins                        : 0.9.2
cocoapods-deintegrate                 : 1.0.5
cocoapods-dependencies                : 1.3.0
cocoapods-disable-podfile-validations : 0.1.1
cocoapods-embed-flutter               : 0.6.1
cocoapods-generate                    : 2.2.2
cocoapods-packager                    : 1.5.0
cocoapods-plugins                     : 1.0.0
cocoapods-search                      : 1.0.1
cocoapods-stats                       : 1.1.0
cocoapods-trunk                       : 1.6.0
cocoapods-try                         : 1.2.0
cocoapods_debug                       : 0.1.0

Project that demonstrates the issue

Demonstration project: https://github.com/SwiftyLab/AsyncObjects/tree/obj-wait-err, use the same branch as in the url.

Jeehut commented 1 year ago

I'm also getting an error when I run pod trunk push on the current main branch of BartyCrouch to release 4.12.0, here's the full output:

pod trunk push       

[!] Found podspec `BartyCrouch.podspec`
Updating spec repo `trunk`
Validating podspec
nil versions are discouraged and will be deprecated in Rubygems 4
 -> BartyCrouch (4.12.0)
    - NOTE  | xcodebuild:  note: Using codesigning identity override: 
    - NOTE  | xcodebuild:  note: Building targets in dependency order
    - NOTE  | [OSX] xcodebuild:  Pods.xcodeproj: warning: The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET' is set to 10.6, but the range of supported deployment target versions is 10.9 to 12.3.99. (in target 'Pods-App' from project 'Pods')
    - NOTE  | [OSX] xcodebuild:  Pods.xcodeproj: warning: The macOS deployment target 'MACOSX_DEPLOYMENT_TARGET' is set to 10.6, but the range of supported deployment target versions is 10.9 to 12.3.99. (in target 'BartyCrouch' from project 'Pods')
    - NOTE  | xcodebuild:  note: Using codesigning identity override: -
    - NOTE  | [iOS] xcodebuild:  Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 11.0 to 16.0.99. (in target 'Pods-App' from project 'Pods')
    - NOTE  | [iOS] xcodebuild:  Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 11.0 to 16.0.99. (in target 'BartyCrouch' from project 'Pods')
    - NOTE  | [iOS] xcodebuild:  /var/folders/n_/vfzcwr7j3gndx375gg3pf9600000gn/T/CocoaPods-Lint-20220925-3947-snqta7-BartyCrouch/App.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 11.0 to 16.0.99. (in target 'App' from project 'App')
    - NOTE  | [tvOS] xcodebuild:  Pods.xcodeproj: warning: The tvOS Simulator deployment target 'TVOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 11.0 to 16.0.99. (in target 'Pods-App' from project 'Pods')
    - NOTE  | [tvOS] xcodebuild:  Pods.xcodeproj: warning: The tvOS Simulator deployment target 'TVOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment target versions is 11.0 to 16.0.99. (in target 'BartyCrouch' from project 'Pods')
    - ERROR | [watchOS] xcodebuild: Returned an unsuccessful exit code. You can use `--verbose` for more information.
    - NOTE  | [watchOS] xcodebuild:  xcodebuild: error: Unable to find a destination matching the provided destination specifier:

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

I'm using Xcode 14.0.1 and I have all platform SDKs installed (including watchOS). I'm on CocoaPods 1.11.3.

jberkel commented 1 year ago

According to man xcodebuild you can't specify id= for watch simulators:

A watchOS app is always built and deployed nested inside of an iOS app. To use a watchOS device as your destination, specify a scheme which is configured to run a WatchKit app, and specify the iOS platform destination that is paired with the watchOS device you want to use.

So even though the device id is listed, it can't be used by xcodebuild.

Executing xcodebuild manually, without the id parameter, does indeed build OK. A simple fix would therefore be to skip the id parameter when linting watchOS (or pick the paired iOS one–I haven't tried that)

imaginaris commented 1 year ago

I managed to fix error: Unable to find a destination matching the provided destination specifier: error by removing all unpaired watchOS simulators. Here's a script that does that:

xcrun simctl list --json > simulators.json
watch_os_udids=$(jq '.devices[] | map(select(.name | contains("Watch"))) | .[].udid' simulators.json -r)
paired_watch_udids=$(jq '.pairs | map(.watch) | .[].udid' simulators.json -r)

while IFS= read -r udid; do
    if [[ ! "${paired_watch_udids[*]}" =~ "${udid}" ]]; then
        xcrun simctl delete ${udid}
    fi
done <<< "$watch_os_udids"

(The script can be probably improved though)

Ensure that you have at least one iPhone-Watch pair in your simulator list (xcrun simctl list)

jimmyeisenhauer commented 1 year ago

Is there a plan to fix how pod lib lint selects watch simulators?

thomasvl commented 1 year ago

Even with 1.12.0, I'm still seeing failures:

https://github.com/google/gtm-session-fetcher/actions/runs/4294972442/jobs/7484744227

    xcodebuild: error: Failed to build workspace App with scheme GTMSessionFetcher-Unit-Tests.
        Reason: Cannot test target “GTMSessionFetcher-Unit-Tests” on “Any watchOS Simulator Device”: Tests must be run on a concrete device
paulb777 commented 1 year ago

With 1.12.0, we've been able to successfully restore watchos to our pod lib lint build tests, for the first time with Xcode 14.

We've never been able to run test specs for watchos which looks like you're doing.

NachoSoto commented 1 year ago

Unfortunately this is still not working for us either:

-> Pod installation complete! There is 1 dependency from the Podfile and 2 total pods installed.
   Building with `xcodebuild`. 
    $ /usr/bin/xcodebuild clean build -workspace /var/folders/bl/wbxjgtzx7j5_mjsmfr3ynlc00000gp/T/CocoaPods-Lint-20230302-2072-11u0ac8-PurchasesHybridCommon/App.xcworkspace -scheme App -configuration Release CODE_SIGN_IDENTITY=- -sdk watchsimulator -destination id=A0259AC0-8B2E-4108-B955-0346B484F15B
    Command line invocation:
        /Applications/Xcode-14.1.app/Contents/Developer/usr/bin/xcodebuild clean build -workspace /var/folders/bl/wbxjgtzx7j5_mjsmfr3ynlc00000gp/T/CocoaPods-Lint-20230302-2072-11u0ac8-PurchasesHybridCommon/App.xcworkspace -scheme App -configuration Release CODE_SIGN_IDENTITY=- -sdk watchsimulator -destination id=A0259AC0-8B2E-4108-B955-0346B484F15B

    User defaults from command line:
        IDEPackageSupportUseBuiltinSCM = YES

    Build settings from command line:
        CODE_SIGN_IDENTITY = -
        SDKROOT = watchsimulator9.1

    2023-03-02 18:21:35.299 xcodebuild[2435:13349] Writing error result bundle to /var/folders/bl/wbxjgtzx7j5_mjsmfr3ynlc00000gp/T/ResultBundle_2023-02-03_18-21-0035.xcresult
    xcodebuild: error: Unable to find a destination matching the provided destination specifier:
            { id:A0259AC0-8B2E-4108-B955-0346B484F15B }

        The requested device could not be found because no available devices matched the request.

        Available destinations for the "App" scheme:
            { platform:watchOS, id:dvtdevice-DVTiOSDevicePlaceholder-watchos:placeholder, name:Any watchOS Device }
            { platform:watchOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-watchsimulator:placeholder, name:Any watchOS Simulator Device }
            { platform:watchOS Simulator, id:E4E68107-5F5E-4465-A4F4-84127452B78A, OS:9.1, name:Apple Watch SE (40mm) (2nd generation) }
            { platform:watchOS Simulator, id:7A34905B-E196-451C-844D-FEE14614F54C, OS:9.1, name:Apple Watch SE (44mm) (2nd generation) }
            { platform:watchOS Simulator, id:A0259AC0-8B2E-4108-B955-0346B484F15B, OS:8.5, name:Apple Watch Series 5 (40mm) }
            { platform:watchOS Simulator, id:320D632C-B34A-4631-9316-759976F281C8, OS:9.1, name:Apple Watch Series 5 (40mm) }
            { platform:watchOS Simulator, id:1DC0569E-60D1-490D-8D18-CEDB0C9E7927, OS:8.5, name:Apple Watch Series 5 (44mm) }
            { platform:watchOS Simulator, id:C1310AE1-107D-4DE3-B658-BC33A45C4061, OS:9.1, name:Apple Watch Series 5 (44mm) }
            { platform:watchOS Simulator, id:AD6956CB-957C-4396-8B3C-14CEAD1FDD10, OS:8.5, name:Apple Watch Series 6 (40mm) }
            { platform:watchOS Simulator, id:7543BB53-1D42-42D8-8E7A-17144F3D0684, OS:9.1, name:Apple Watch Series 6 (40mm) }
            { platform:watchOS Simulator, id:7DCC8291-880F-43E4-8F09-65C1368D8386, OS:8.5, name:Apple Watch Series 6 (44mm) }
            { platform:watchOS Simulator, id:6EFE3B05-E90F-4462-99E0-3E60DC8A3FCF, OS:9.1, name:Apple Watch Series 6 (44mm) }
            { platform:watchOS Simulator, id:8D24FD3F-C77C-4430-8FAC-DA50AC2BBC2A, OS:8.5, name:Apple Watch Series 7 (41mm) }
            { platform:watchOS Simulator, id:8898253D-63CA-4B7B-8BA7-541D6BE5AA03, OS:9.1, name:Apple Watch Series 7 (41mm) }
            { platform:watchOS Simulator, id:6293CC5D-1DA4-45CA-8AE9-FB9AF7410220, OS:8.5, name:Apple Watch Series 7 (45mm) }
            { platform:watchOS Simulator, id:0D576C6E-FDC8-4732-81F6-1F4FB3645113, OS:9.1, name:Apple Watch Series 7 (45mm) }
            { platform:watchOS Simulator, id:EDDFD59E-5799-463E-9C52-4BCFC066C3ED, OS:9.1, name:Apple Watch Series 8 (41mm) }
            { platform:watchOS Simulator, id:0DC8EF45-0FFC-4E35-90EB-C568F4D5DEB7, OS:9.1, name:Apple Watch Series 8 (45mm) }
            { platform:watchOS Simulator, id:5ED61559-6467-4EAE-AD30-805B2CD87C17, OS:9.1, name:Apple Watch Ultra (49mm) }
            { platform:iOS Simulator, id:E616C409-03A4-4A07-B2DC-FFF7544CBCCD, OS:16.1, name:iPhone 14 }
            { platform:iOS Simulator, id:F1215707-3211-428B-BD73-4C70637D400D, OS:16.1, name:iPhone 14 Plus }
            { platform:iOS Simulator, id:D1327065-A7D0-4C7D-A8E6-21C5F21F5B2C, OS:16.1, name:iPhone 14 Pro }
            { platform:iOS Simulator, id:B71CBE55-DCEC-414B-89AA-F23A19AE5820, OS:16.1, name:iPhone 14 Pro Max }
NachoSoto commented 1 year ago

Can this be reopened? The issue isn't actually fixed. It's unfortunate to have to use Xcode 13 because it's not even supported to submit apps anymore.

Buju77 commented 1 year ago

Another hint for anybody else also encountering this issue. I had exactly the same issue as OP, but I was then able to lint and release our pod.

I had Xcode 14.2 and 14.3 installed in parallel. My xcode-select was set to 14.2. So when linting Cocoapods would then unfortunately chose a watch simulator that was created when installing Xcode 14.3, which is unknown to 14.2 --> 💥

My fix was to switch to Xcode 14.3 and do the linting and release: sudo xcode-select -s /Applications/Xcode-14.3.app/Contents/Developer

Buju77 commented 1 year ago

Update:

So I just ran into this again and finally found the reason. The issue is that the watch simulator Cocoapods tries to use for linting doesn't have a paired iOS simulator yet.

So for fixing it, use that watch device from the error message and pair a iOS simulator using the command:

xcrun simctl pair <watch device id> <phone device id>

Example: xcrun simctl pair 96AAD8C9-F7B6-4487-A785-2A22581EB5B6 081F9AF2-55F7-4AB1-9620-8E304FC44841

Screenshot 2023-06-21 at 20 47 07

For the watch device id, use the id that it tries to find from your build logs error message. For phone device id, use any iOS 16.2 simulator.

Screenshot 2023-06-21 at 20 59 58

Warning: Make sure that the phone device doesn't have a pair watch yet! If your phone simulator have 2 or more paired watches, make sure that the correct watch is the active watch from the Xcode "Devices and Simulators" window! Won't work otherwise!

Screenshot 2023-06-22 at 10 24 46

nicolasrostan commented 1 year ago

This issue is still happening using Xcode 14.3.1 and Cocoapods 1.12.1, I have only one watchos simulator and paired, but it stills gives me the "xcodebuild: error: Failed to build workspace App with scheme Pod-Unit-Tests.: Cannot test target “Pod-Unit-Tests” on “Any watchOS Simulator Device”: Tests must be run on a concrete device"

Can we reopen this?