Xcode Workspace-找不到从框架开发窗格导入的内容 [英] Xcode Workspace - Not finding imports from framework development pod

查看:371
本文介绍了Xcode Workspace-找不到从框架开发窗格导入的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立了一个包含两个Swift项目的工作区:一个是我正在开发的框架,另一个是该框架的演示应用程序.

I've set up a workspace with two Swift projects in it: one a framework I'm developing, the other a demo app for the framework.

Podfile看起来像这样:

Podfile looks like this:

platform :ios, '9.0'
workspace 'foo.xcworkspace'

target 'framework' do
    project 'framework.xcodeproj'
end

target :'demo' do
    project 'demo/demo.xcodeproj'
    pod 'framework', :path => 'framework.podspec'
end

.podspec文件如下所示:

the .podspec file looks like this:

Pod::Spec.new do |s|
    s.name         = 'framework'
    s.authors      = { "foo author" }
    s.version      = '0.1.0'
    s.summary      = 'foo summary.'
    s.homepage     = 'foo homepage'
    s.platform     =  :ios, '9.0'
    s.license      = {
        :type => "Proprietary",
        :file => "LICENSE"
    }
    s.source       = {
        :git => 'https://url.to/foo.git',
        :tag => s.version.to_s
    }
    s.source_files = 'framework/framework/**/*.{swift,h,m}'
    s.requires_arc = true
    s.weak_framework = "XCTest"
    s.pod_target_xcconfig = {
        'FRAMEWORK_SEARCH_PATHS' => '$(inherited) "$(PLATFORM_DIR)/Developer/Library/Frameworks"',
    }
end

运行pod install后,Xcode/AppCode仍然看不到框架项目中的类.因此,如果我在演示应用程序的类中添加手动导入并尝试编译,则导入失败:

After running pod install, Xcode/AppCode can still not see the classes from the framework project. So if I add a manual import to a class in the demo app and try to compile, it fails with:

错误:(13,21)使用未声明的类型'FooClass'

Error:(13, 21) use of undeclared type 'FooClass'

要使演示应用程序项目正确查看框架项目生成的pod中的类,我该怎么做?

What do I have to do to properly have the demo app project see the classes from the framework project generated pod?

推荐答案

我终于解决了这个问题:

I finally resolved this issue:

  1. 确保分钟.必需的iOS在 Podfile 中定义,例如:

platform:ios,'10 .0'

platform :ios, '10.0'

还将任何第三方Pod也添加到 podspec 文件中,例如:

Add any third-party pods also to the podspec file, e.g.:

spec.dependency'Alamofire','〜> 4.5' spec.dependency'Serpent','〜> 1.0'

spec.dependency 'Alamofire', '~> 4.5' spec.dependency 'Serpent', '~> 1.0'

如果在没有use_frameworks!的情况下执行pod install,则会使某些事情混乱(请参阅以下答案:

If doing pod install without the use_frameworks! it will mess up some things (see this answer: ld: framework not found Pods). So in between I got these invalid Pod xconfigs that I had to delete and then do a clean and pod install.

确保至少构建一次框架项目,然后演示源应该找到导入到框架容器名称的文件!

Make sure to build the framework project at least once and then the demo source should find the import to the framework pod name!

确保所有类均已正确添加到其目标中,尤其是不应将测试目标中的类意外添加到应用程序目标中.

Make sure that all classes are correctly added to their target, especially classes in the test target should not have been added to the app target accidentally.

归根结底,在使用多种IDE和开发技术的情况下,Xcode和Cocoapods只能概括为一个事故的巨大集群!!

After all is said and done, having worked with a multitude of IDEs and development technologies, Xcode and Cocoapods can only be summed up as one giant clusterf*** of an accident!

这篇关于Xcode Workspace-找不到从框架开发窗格导入的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆