Xcode Couldn't Generate Swift Representation for my own framework

♀尐吖头ヾ 提交于 2019-11-27 15:39:04

问题


I have created a framework which I want to use in my OS X app. Since updating to Xcode 7 on El Capitan, when I try to command-click on the import statement, Xcode goes to the following view.

How can I get Xcode to display the Swift representation properly? I've had it happen before, and my solution was to recreate every project file which I don't want to do again.


回答1:


From my experience there are two possible causes for this issue. The first one is that your framework can't be located. To fix this you need to go to target's Build Settings and add a path to Framework Search Paths either an absolute:

/Users/{user}/path-to-framework-parent-directory

or relative to project directory:

$(PROJECT_DIR)/path-to-framework-parent-directory

Another possible cause is that the path to your framework contains a space in it. I found that it doesn't matter whether you try to escape it with backslash ../Project\ Name/frameworks or take the whole path in double-quotes "../Project Name/frameworks". The result would be that SourceKit could not load the module.

Note that $(PROJECT_DIR) could expand to a path with a space in it and it would too result in the same error. So it looks like a bug in Xcode/SourceKit (I tried the latest Xcode 7.2-beta3 and the bug is still there).

My repository was on the second hard drive /Voluems/Macintosh HD/Repos. I just renamed the hard drive to HD, so the path looks like /Volumes/HD/Repos and the problem was gone.




回答2:


Max S. answer pointed me in the right direction, however I was using the 'recursive' option for my framework path.

To get things to work I had to explicitly add a path to directly the framework in question's immediate parent directoy (as oposed to just having a path to one of its higher up directories with the 'recursive' option set).

HTH




回答3:


I had this problem too and the other solutions didn't work. I finally figured it out in my case:

The target name cannot have a space in it either

To rename it:

  • Go to your project settings
  • Expand the target list column on the left if not already there
  • Click on the relevant target once (or press Enter or Tab when having it selected) and type in the new name without the space



回答4:


Running Product->Clean, Product->Build is what worked for me.




回答5:


Weirdly, just changing the name of my folder from 'Developer' to 'Development' fixed the issue from me.




回答6:


In my case, I have created a framework for my SDK along with podspec for making it cocoa pod.

I had the same problem when i use my SDK and it fixed when I imported Foundation API to the file where I am consuming my SDK

import Foundation



来源:https://stackoverflow.com/questions/32894901/xcode-couldnt-generate-swift-representation-for-my-own-framework

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!