Xcode 7 can't find header files from framework

放肆的年华 提交于 2019-12-02 21:43:27

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)

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

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

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.

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

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!

Cleaning the project and restarting XCode sometimes helps

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