Xcode 7 can't find header files from framework

一曲冷凌霜 提交于 2019-12-20 10:19:24

问题


I'm trying to add PassSlot into my project, but it says it can't find the .h file. I'm following everything correctly from here: https://github.com/passslot/passslot-ios-sdk

Is this an Xcode 7 problem? It was working fine and now that I opened the project in Xcode 7, it is giving me this problem. I reopened it on Xcode 6 and it starts showing the problem as well.


回答1:


I think Dinesy is right. This solves the problem for me.

I've noticed that Xcode7 doesn't automatically fill in the required Framework search paths when you import a 3rd party one (I believe Xcode6 did do this). Check if yours are empty by going to Project -> Build Settings -> Search Paths -> Framework Search Paths. Fill it in with wherever your Frameworks live. If it's under your project you can use $(PROJECT_DIR)




回答2:


Replacing #import "Headerfile.h" with #import <Framework/Headerfile.h> worked for me.




回答3:


When you Drag & Drop the required framework to your Frameworks folder, Tick on "Destination: Copy items if needed"

Then you would be able to reference it properly now.

Screenshot




回答4:


Just ran into this with Xcode 7 and I ended up having to copy the 3rd party Framework (and bundle) file into my project's main directory before dragging it into the Xcode project. This allowed it to add the correct Framework search path and no longer gave me any problems.




回答5:


Just hit this problem myself after making a new test target in Objective-C.

One thing to remember is that under some circumstances, each test target must be listed in the Podfile with pod dependencies. If the Podfile only associates the project with the pods, it may not find the pod header files.

Here's an example of a more complex Podfile from the cocoapods docs.

target 'MyApp' do
  pod 'ObjectiveSugar', '~> 0.5'

  target "MyAppTests" do
    inherit! :search_paths
    pod 'OCMock', '~> 2.0.1'
  end
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    puts "#{target.name}"
  end
end



回答6:


In my case, using CocoaPods, Xcode was building fine, but a command line build couldn't locate the framework headers.

The solution was to build the workspace, not the project!




回答7:


I ran into this error when trying to link to my own custom framework. The problem was that I hadn't set up my framework to export the needed headers. To do so:

  1. Select each header file you want to make available, go to the File Inspector > Target Membership, and make sure the target is checked and set to "Public".
  2. In the MyFrameworkName.h top-level file, import each header file you want to make available: e.g. #import <MyFrameworkName/MyPublicHeader.h>



回答8:


Cleaning the project and restarting XCode sometimes helps



来源:https://stackoverflow.com/questions/30762492/xcode-7-cant-find-header-files-from-framework

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