fastlane-old / snapshot

Automate taking localized screenshots of your iOS app on every device
https://fastlane.tools
1.95k stars 140 forks source link

How to fix error - Undeclared Identifier Snapshot for Objective-C Project? #397

Closed varmeh closed 8 years ago

varmeh commented 8 years ago

The swift.h file created by XCode holds no reference to snapshot.

vpolouchkine commented 8 years ago

Did you add the helper and bridge files per https://github.com/fastlane/snapshot#quick-start?

varmeh commented 8 years ago

I did. I added -Swift.h to .m files and I could also see that in derived data folder. Though the bridge header created by XCode hold no reference to Snapshot.

zauberware commented 8 years ago

Following solution worked for me:

  1. Change "class Snapshot: NSObject" to "@objc class Snapshot: NSObject" in SnapshotHelper.swift
  2. Change the build settings of your test target (not the normal project). Set "Install Objective-C Compatibility Header" to YES.
  3. Clean and build, you should now have a bridge file in your derived data (not in your project).
  4. The bridge file is not added to your project but only to the derived data. Sometimes with a different name than expected and then the import doesn't work. To find it go to XCode-->Window-->Projects, click on the arrow right beside your derived data folder. Finder opens, then search for Swift.h and you will find your bridge file. Import that into your testcase-class via "#import "NameOfYourBridgeFile-Swift.h".

Hope that helps!

varmeh commented 8 years ago

Hey Zuber, sorry for delayed response. I tried all this and it still did not work for me. Derived header did not have the implementation of snapshot class (checked in derived data folder). That's why it's still not working for me.

cguess commented 8 years ago

I'm fighting with the same issues here. @zauberware I've gone through every step you've laid out and Snapshot still cannot be found in my test files as a class. Any ideas?

zauberware commented 8 years ago

Hi @cguess ,

could you get to step 3 to generate the bridge file in the derived data? If not you can try to delete and add the UI target again. I had to change the valid target architectures in the build settings of the UI target and the product name to generate the bridge file.

Hope that helps!

Marcus

fastlane-bot commented 8 years ago

This issue was migrated to https://github.com/fastlane/fastlane/issues/1657. Please post all further comments there.

fastlane is now a mono repo, you can read more about the change in our blog post. All tools are now available in the fastlane main repo :rocket: