Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EarlGrey 2.0 Helper Bundle (Swift) can't find XCTest.h #759

Closed
jn000 opened this issue Oct 4, 2018 · 20 comments
Closed

EarlGrey 2.0 Helper Bundle (Swift) can't find XCTest.h #759

jn000 opened this issue Oct 4, 2018 · 20 comments

Comments

@jn000
Copy link

jn000 commented Oct 4, 2018

I set up EarlGrey 2.0 according to setup.md.

In Helper Bundle Section, I added Bridging-Header for Helper Bundle, then I got compile error.
Error message is 'XCTest/XCTest.h' file not found in XCTestCase+GREYSystemAlertHandler.h.

How can i resolve this issue.

I tried to find what is different to FunctionalTests HostDOCategoriesSwift with my bundle.

  • Build Settings
    • Always Embed Swift Standard Libraries
      • FunctionalTests is Yes
    • Enable Bitcode
      • FunctionalTests is No

I fix these, but i can't resolve the issue...

@tirodkar
Copy link
Collaborator

tirodkar commented Oct 4, 2018

You should not link TestLib to the Helper Bundle. Only have a weak dependency on the AppFramework. Expose the Headers for the TestLib to that target.

@jn000
Copy link
Author

jn000 commented Oct 5, 2018

@tirodkar
Thank you for your reply.

I don't link TestLib in Helper Bundle. My configuration at Build Phase is below.

2018-10-05 10 44 17

Expose the Headers for the TestLib to that target.

How can i configure that?

My Build Setting configuration for Helper Bundle is below.

User Header Search Path ('EarlGrey' directory is downloaded git repository.)
2018-10-05 10 45 39

Bridging Header
2018-10-09 19 28 37

@tirodkar
Copy link
Collaborator

I'm surprised the XCTest import is failing here. Hmm, this is being copied correctly to only the tests right?

@tirodkar
Copy link
Collaborator

I think I know what the issue is. I'm guessing that you're handling an alert in your Helper Bundle.

The Helper Bundle is an app side component. There is no XCTest at all within that component. The correct solution here would be to move the System Handler code to your test side. It should build just fine after.

@jingyul
Copy link

jingyul commented Oct 10, 2018

I'm having the same issue, the helper bundles could not fine XCTest/XCTest.h during build, even though the @loader_path/Frameworks is in the runtime path

@tirodkar
Copy link
Collaborator

@jingyul Are you referring to any XCTest stuff in the bundle? Any System Handling / TestLib stuff?

@jingyul
Copy link

jingyul commented Oct 10, 2018

@tirodkar Not directly, the error is pointing to TestLib/AlertHandling as you mentioned. It's not from my source code. But I don't know how this dependency was created.

@tirodkar
Copy link
Collaborator

Is it in the bridging header? Try removing it from there.

@jingyul
Copy link

jingyul commented Oct 10, 2018

No, this is what is in the bridging header:

@jingyul
Copy link

jingyul commented Oct 10, 2018

#import "AppFramework/Action/GREYAction.h"
#import "AppFramework/Action/GREYActionBlock.h"
#import "AppFramework/Action/GREYActions.h"
#import "AppFramework/Matcher/GREYElementMatcherBlock.h"
#import "CommonLib/DistantObject/GREYHostApplicationDistantObject.h"
#import "CommonLib/Matcher/GREYMatcher.h"
#import "TestLib/AlertHandling/XCTestCase+GREYSystemAlertHandler.h"
#import "TestLib/EarlGreyImpl/EarlGrey.h"

@tirodkar
Copy link
Collaborator

Remove #import "TestLib/AlertHandling/XCTestCase+GREYSystemAlertHandler.h"
I'm sending a PR to update this.

@jingyul
Copy link

jingyul commented Oct 10, 2018

I did. But still get the same error, but this time it is from TestLib/EarlGreyImp/EarlGrey.h

@tirodkar
Copy link
Collaborator

Remove all TestLib imports from your Helper Bundle.

@jingyul
Copy link

jingyul commented Oct 10, 2018

Build Success! Thanks @tirodkar

@tirodkar
Copy link
Collaborator

Clarification added #763. Feel free to comment if there's something that's unclear.

@jingyul
Copy link

jingyul commented Oct 11, 2018

Wait, more questions, now the individual build on the helper bundles is good. But when run a UITest test case, it says that BuildEarlGreyHelperBundles:Failed on top of the XCode window. There is no more details. No red dot.

@tirodkar
Copy link
Collaborator

Can you ping me on Slack and we can continue this there?

@jingyul
Copy link

jingyul commented Oct 11, 2018

ok, thanks!

@jingyul
Copy link

jingyul commented Oct 11, 2018

Sorry have to go. Will be online later.

@jn000
Copy link
Author

jn000 commented Oct 11, 2018

@tirodkar
thank you so much your kind support.
i build successfully.

my bridging header for helper bundle is below.

#import "AppFramework/Action/GREYAction.h"
#import "AppFramework/Action/GREYActionBlock.h"
#import "AppFramework/Action/GREYActions.h"
#import "AppFramework/Matcher/GREYElementMatcherBlock.h"
#import "CommonLib/DistantObject/GREYHostApplicationDistantObject.h"
#import "CommonLib/Matcher/GREYMatcher.h"

i close this issue.

@jn000 jn000 closed this as completed Oct 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants