google/EarlGrey

EarlGrey2 unable to setup with Cocoapods

fbaumgart opened this issue · 14 comments

Hello, since EG1 is no longer supported I've been trying to migrate to EG2. Using instructions provided in README I have edited my podfile accordingly and was able to retrieve the most recent version.
I followed the steps provided in "setup for Swift" section and pasted the contents of EarlGrey.swift linked in readme to the file with the same name which was already created in my project (by Cocoapods I guess). I also created the header file but the contents provided in readme did not work so I used contents of EarlGreySwiftBridgingHeader-Pods.h file from the FunctionalTests example which didn't produce any errors. As setup said I attached the file to my test target. I made necessary changes to my test code to adapt to the new API, but I still get very ambiguous error in the console at the end of ui test target build: "ld: framework not found EarlGrey".
Can you please provide some steps to resolve the issue?

First check to confirm - this is a UI Test target? You should not get ld: framework not found EarlGrey - I think this is coming from an EG 1 dependency in your Xcode Project.

Yes, this is UI test target. I have managed to remove the mentioned error - just had to remove EarlGrey.framework item from Link Binary With Libraries and delete "EarlGREY Copy Files" phase - I believe this was used by EG1.

Screenshot 2021-03-08 at 09 57 49

Now I am able to build and run UITests on the target however it crashes just at the beginning - no particular error or logs just
usual crash.

Do you have any suggestions?
Xcode 12.4, macOS big sur 11.2.1

Screenshot 2021-03-08 at 10 11 04
Screenshot 2021-03-08 at 10 09 27

@tirodkar can I kindly ask you for assistance? Or maybe you can advise where I can seek for help with this issue?

today I tried to perform additional setup to see if it will help - I followed information from this page https://github.com/google/EarlGrey/blob/earlgrey2/docs/white-boxing-setup-guide.md
and after that I'm no longer able to build my Unit or UI tests - I get a message 'Cycle inside test target name ; building could produce unreliable results'

Do you have a simple project I can repro this with? If you have a cycle, then I'm guessing the distant object bundle is being double linked or the app is being added as a dep into it and vice versa.

@tirodkar I have tried to setup a simple project - here is my repo https://github.com/fbaumgart/ethereum-price-monitor/tree/earl_grey_debug

First problem is - the compiler cannot find the paths to files from the header file - I tried to add the paths I looked up in macOS Finder to the Header Search Paths in Build Settings and it worked only for the first file from the list, second and others couldn't be found. Can you advise what these paths should look like? https://github.com/fbaumgart/ethereum-price-monitor/blob/earl_grey_debug/EarlGreySwiftBridgingHeader.h

Did you try setting the search paths to be recursive for this?

Yes, it did not work.

Change your Header to just contain #import <EarlGreyTest/EarlGrey.h>

https://github.com/google/EarlGrey/blob/earlgrey2/Demo/EarlGreyExample/EarlGreySwiftBridgingHeader-Pods.h

Saw some launch issues with your test process. Do tell me if you see these as well.

Thanks, after change in the header the build is successful, but I am getting a crash as in the screenshot:
Screenshot 2021-04-16 at 10 43 56
It crashes in regular XCUITest and on EarlGrey example too. Also I am not able to launch unit tests with this error:
Screenshot 2021-04-16 at 10 47 27

In "Other Linker Flags" - of the UI Test target, you have $(inherited) which is passing -framework AppFramework since I believe !use_frameworks is on. Can you remove the $(inherited) and check?

I removed $(inherited) as advised but I still get the same error.

Due to the configuration problems I decided to stop using EG, closing the issue.

FWIW, I was actually able to get the sample project up and running - https://github.com/fbaumgart/ethereum-price-monitor/compare/earl_grey_debug...tirodkar:earl_grey_debug?expand=1

I had to uncomment a few things from the Podfile, change the $inherited as above by commenting out inherit! :search_paths and updating the Pods to the latest versions. Might be worth giving it a look.