简体   繁体   English

iOS Cocoapods问题:我的项目部分没有这样的模块(自定义文件夹和Apple Watch目标)

[英]iOS Cocoapods issue: No such module in parts of my project (custom folder & Apple Watch target)

I have trouble installing following cocoapod correctly: github.com/drmohundro/SWXMLHash 我无法正确安装以下cocoapod:github.com/drmohundro/SWXMLHash

Interestingly enough, I can access the framework "SWXMLHash" installed by the pod in my regular ViewController.swift but cannot access it in my Apple Watch Extension files. 有趣的是,我可以在我的常规ViewController.swift中访问由pod安装的框架“SWXMLHash”,但无法在Apple Watch Extension文件中访问它。 Furthermore, I cannot access it in a custom group/folder I made to encapsulate the helper methods like WebServiceHelper.swift 此外,我无法在自定义组/文件夹中访问它,以封装辅助方法,如WebServiceHelper.swift

Overview of my folder structure (Image link) 我的文件夹结构概述(图片链接)

I can easily import and use the framework provided by the pod in my ViewController.swift for iPhone . 我可以在我的ViewController.swift for iPhone中轻松导入和使用pod提供的框架。 But when I try to access it outside the folder containing "ViewController.swift" / "AppDelegate.swift" I get following error: 但是当我尝试在包含“ViewController.swift”/“AppDelegate.swift”的文件夹之外访问它时,我收到以下错误:

No such module 'SWXMLHash' 没有这样的模块'SWXMLHash'

Error when I try to access the framework in my "myAppName Kit"-folder (Image link) 我尝试访问“myAppName Kit”文件夹中的框架时出错(图片链接)

My Podfile: 我的Podfile:

# Uncomment this line to define a global platform for your project
# platform :ios, '8.0'
# Uncomment this line if you're using Swift
use_frameworks!

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

pod 'SWXMLHash', '~> 2.1.0'

target 'myAppName' do

end

target 'myAppNameTests' do

end

target 'myAppNameUITests' do

end

target 'myAppName Watch' do

end

target 'myAppName Watch Extension' do

end

Thank you very much for your help! 非常感谢您的帮助!

please make podfile like this 请像这样制作podfile

# Uncomment this line to define a global platform for your project
# platform :ios, '8.0'
# Uncomment this line if you're using Swift
use_frameworks!

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'



target 'myAppName' do
pod 'SWXMLHash', '~> 2.1.0'
end

target 'myAppNameTests' do

end

target 'myAppNameUITests' do

end

target 'myAppName Watch' do
pod 'SWXMLHash', '~> 2.1.0'
end

target 'myAppName Watch Extension' do
pod 'SWXMLHash', '~> 2.1.0'
end

Here's how I think your Podfile should look ( note that I only specified the iOS and Watch targets for clarity, you'll need to include whichever ones are necessary with the correct platform for each): 以下是我认为你的Podfile看起来的样子( 请注意 ,为了清晰起见,我只指定了iOS和Watch目标,你需要为每个目标包含正确平台所需的任何一个):

use_frameworks!

source 'https://github.com/CocoaPods/Specs.git'

target 'myAppName' do
    platform :ios, '8.0'
    pod 'SWXMLHash', '~> 2.1.0'
end

# snipped...

target 'myAppName Watch' do
    platform :watchos, '2.0'
    pod 'SWXMLHash', '~> 2.1.0'    
end

I didn't add it for every one of them, but note that the :platform is specified differently for the watch target. 我没有为它们中的每一个添加它,但请注意:platform watch :platform的指定目标不同。 You don't want the ios target at the global level. 您不希望ios目标处于全局级别。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM