fastlane-community / fastlane-plugin-cordova_screenshots

Take screenshots of your Cordova/Ionic app with fastlane
MIT License
17 stars 10 forks source link

Multiple commands produce '.../Info.plist' #25

Open brownoxford opened 4 years ago

brownoxford commented 4 years ago

With XCode 11.2.1, I get the following error when running snapshot after retrofit_cordova_screenshots_ios:

❌  error: Multiple commands produce '/var/folders/b8/zbn4kbds68d8s7_brr4yx3880000gn/T/snapshot_derived20191220-99448-1de3tt3/Build/Products/Debug-iphonesimulator/ui-snapshots-Runner.app/PlugIns/ui-snapshots.xctest/Info.plist':

    The Compile Sources build phase contains this target's Info.plist file '/src/my.project/my.bundle/fastlane/cordova_screenshots/ios/ui-snapshots/Info.plist'. (in target 'ui-snapshots' from project 'my.project')
    duplicate output file '/var/folders/b8/zbn4kbds68d8s7_brr4yx3880000gn/T/snapshot_derived20191220-99448-1de3tt3/Build/Products/Debug-iphonesimulator/ui-snapshots-Runner.app/PlugIns/ui-snapshots.xctest/Info.plist' on task: ProcessInfoPlistFile /var/folders/b8/zbn4kbds68d8s7_brr4yx3880000gn/T/snapshot_derived20191220-99448-1de3tt3/Build/Products/Debug-iphonesimulator/ui-snapshots-Runner.app/PlugIns/ui-snapshots.xctest/Info.plist /src/my.project/my.bundle/fastlane/cordova_screenshots/ios/ui-snapshots/Info.plist (in target 'ui-snapshots' from project 'my.project')
Testing failed:
        Multiple commands produce '/var/folders/b8/zbn4kbds68d8s7_brr4yx3880000gn/T/snapshot_derived20191220-99448-1de3tt3/Build/Products/Debug-iphonesimulator/ui-snapshots-Runner.app/PlugIns/ui-snapshots.xctest/Info.plist':
1) Target 'ui-snapshots' (project 'my.project') has copy command from '/src/my.project/my.bundle/fastlane/cordova_screenshots/ios/ui-snapshots/Info.plist' to '/var/folders/b8/zbn4kbds68d8s7_brr4yx3880000gn/T/snapshot_derived20191220-99448-1de3tt3/Build/Products/Debug-iphonesimulator/ui-snapshots-Runner.app/PlugIns/ui-snapshots.xctest/Info.plist'
2) Target 'ui-snapshots' (project 'my.project') has process command with output '/var/folders/b8/zbn4kbds68d8s7_brr4yx3880000gn/T/snapshot_derived20191220-99448-1de3tt3/Build/Products/Debug-iphonesimulator/ui-snapshots-Runner.app/PlugIns/ui-snapshots.xctest/Info.plist'

        Testing cancelled because the build failed.
janpio commented 4 years ago

Hmm, I am pretty sure this was required before. Maybe recent Xcode updates or something like that? Any idea?

andrey3diq commented 4 years ago

I have the same issue. First in XCode 11.0, then upgraded to 11.3. Build failed in both versions. Interesting is that it's running fine when I start recording. But recording doesn't work, It's not adding any commands to the test. When I run the test manually from XCode, it's trying to rebuild and then displaying this error:

Multiple commands produce '.../Info.plist':
1) Target 'test_schema' (project 'White Noise') has copy command from '.../Info.plist' to '.../Info.plist'
2) Target 'test_schema' (project 'White Noise') has process command with output '.../Info.plist'

If I delete the Info.plist from the list of compiled files I've got another error:

.../Plugins/cordova-admob-plus/AMSPlugin-Bridging-Header.h:2:9: error: 'GoogleMobileAds/GoogleMobileAds.h' file not found
#import <GoogleMobileAds/GoogleMobileAds.h>
        ^
1 error generated.
<unknown>:0: error: failed to emit precompiled header '.../Build/Intermediates.noindex/PrecompiledHeaders/Bridging-Header-swift_2GL6M2402HZSA-clang_1V56BLNWUN2R4.pch' for bridging header '.../Bridging-Header.h'

The same error appear if I switch the build system to "Legacy build system".

Another issue, the swift version 3.0 is set for some reason after retrofit_cordova_screenshots_ios command. It would be great to switch to 5.0. Because now I should fix it manually in XCode.

brownoxford commented 4 years ago

Hmm, I am pretty sure this was required before. Maybe recent Xcode updates or something like that? Any idea?

This stackoverflow post contained a number of possible problems that could be causing the issue, but this one seemed like the best fit:

To elaborate a bit: This error is happening because Xcode 10's new build system is better at catching project configuration issues. Issues like these can sometimes cause subtle problems with your build, so it's good to fix them

I'm currently running Xcode Version 11.3 (11C29), and when I manually run fastlane run retrofit_cordova_screenshots_ios using v0.2.0 of the plugin I can see that the Info.plist file is accounted for in both Build Phases -> Compile Sources and Build Settings -> Packaging

I haven't yet found anything that indicated when Xcode might have started to include use both of these in the output, but it looks like newer versions of Xcode are noticing the misconfiguration and reporting it by failing the build.

My patch removes the Info.plist file from Build Phases -> Compile Sources and the build then works for me.

brownoxford commented 4 years ago

@andrey3diq, I think there may be a couple of things here that are causing you trouble. First, can you elaborate on what you mean here by "recording doesn't work"?

Interesting is that it's running fine when I start recording. But recording doesn't work, It's not adding any commands to the test.

It sounds like you are trying to generate a test through Xcode by recording your actions, but I don't believe that you can do that with apps that use web views (Cordova, Ionic, etc.). You have to write your UI tests manually and reference your UI elements using the accessibility labels ("aria-label" attributes in the HTML), for example:

<!-- view.html -->
<button aria-label="btn-login">Login</button>
// ui-snapshots.swift
app.webViews.buttons["btn-login"].tap()

Next, how are you removing Info.plist from the list of compiled files? If you do this through Xcode by removing Info.plist from Build Phases -> Compile Sources, it should work, but keep in mind that it will simply be added back the next time you run the retrofit_cordova_screenshots_ios lane. If you are not doing so already, have a look at the change I made for PR #26. Edit your own local version of the plugin to match and try this again to see if that resolves things for you.

The error you are reporting with cordova-admob-plus does not appear to be related to the issue of screenshots. Can you try to re-add the platform to your project and compile without running any fastlane-plugin-cordova_screenshots lanes to confirm?

If I delete the Info.plist from the list of compiled files I've got another error:

.../Plugins/cordova-admob-plus/AMSPlugin-Bridging-Header.h:2:9: error: 'GoogleMobileAds/GoogleMobileAds.h' file not found
#import <GoogleMobileAds/GoogleMobileAds.h>
        ^
1 error generated.
<unknown>:0: error: failed to emit precompiled header '.../Build/Intermediates.noindex/PrecompiledHeaders/Bridging-Header-swift_2GL6M2402HZSA-clang_1V56BLNWUN2R4.pch' for bridging header '.../Bridging-Header.h'

Lastly, the swift version issue is addressed by PR #24, which is currently pending release.

Another issue, the swift version 3.0 is set for some reason after retrofit_cordova_screenshots_ios command. It would be great to switch to 5.0. Because now I should fix it manually in XCode.