2016-02-05 47 views
1

我正在開發一個Swift 2項目,其中包含許多可用的CocoaPods,並且正努力爲GitHub的OrderedDictionary類創建podspec文件,因爲作者沒有創建Podfile。我跑:從GitHub生成的CocoaPods podspec不匹配任何source_files

pod spec create "OrderedDictionary|https://github.com/lukaskubanek/OrderedDictionary" 

這在我的項目的根目錄下創建OrderedDictionary.podspec

# 
# Be sure to run `pod spec lint OrderedDictionary.podspec' to ensure this is a 
# valid spec and to remove all comments including this before submitting the spec. 
# 
# To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html 
# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 
# 

Pod::Spec.new do |s| 

    # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 
    # 
    # These will help people to find your library, and whilst it 
    # can feel like a chore to fill in it's definitely to your advantage. The 
    # summary should be tweet-length, and the description more in depth. 
    # 

    s.name   = "OrderedDictionary" 
    s.version  = "0.5" 
    s.summary  = "An implementation of OrderedDictionary in Swift" 

    # This description is used to generate tags and improve search results. 
    # * Think: What does it do? Why did you write it? What is the focus? 
    # * Try to keep it short, snappy and to the point. 
    # * Write the description between the DESC delimiters below. 
    # * Finally, don't worry about the indent, CocoaPods strips it! 
    s.description = "This is a lightweight implementation of an ordered dictionary data structure in Swift packed into a µframework." 

    s.homepage  = "https://github.com/lukaskubanek/OrderedDictionary" 
    # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" 


    # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 
    # 
    # Licensing your code is important. See http://choosealicense.com for more info. 
    # CocoaPods will detect a license file if there is a named LICENSE* 
    # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. 
    # 

    s.license  = "MIT" 
    # s.license  = { :type => "MIT", :file => "LICENSE.md" } 


    # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 
    # 
    # Specify the authors of the library, with email addresses. Email addresses 
    # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also 
    # accepts just a name if you'd rather not provide an email address. 
    # 
    # Specify a social_media_url where others can refer to, for example a twitter 
    # profile URL. 
    # 

    s.author    = { "Lukas Kubanek" => "[email protected]" } 
    # Or just: s.author = "Lukas Kubanek" 
    # s.authors   = { "Lukas Kubanek" => "[email protected]" } 
    # s.social_media_url = "http://twitter.com/Lukas Kubanek" 

    # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 
    # 
    # If this Pod runs only on iOS or OS X, then specify the platform and 
    # the deployment target. You can optionally include the target after the platform. 
    # 

    # s.platform  = :ios 
    s.platform  = :ios, "8.0" 

    # When using multiple platforms 
    s.ios.deployment_target = "8.0" 
    # s.osx.deployment_target = "10.7" 
    # s.watchos.deployment_target = "2.0" 
    # s.tvos.deployment_target = "9.0" 


    # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 
    # 
    # Specify the location from where the source should be retrieved. 
    # Supports git, hg, bzr, svn and HTTP. 
    # 

    s.source  = { :git => "https://github.com/lukaskubanek/OrderedDictionary.git", :tag => "v0.5" } 


    # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 
    # 
    # CocoaPods is smart about how it includes source code. For source files 
    # giving a folder will include any swift, h, m, mm, c & cpp files. 
    # For header files it will include any header in the folder. 
    # Not including the public_header_files will make all headers public. 
    # 

    s.source_files = "Sources" 
#s.exclude_files = "Classes/Exclude" 

    # s.public_header_files = "Classes/**/*.h" 


    # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 
    # 
    # A list of resources included with the Pod. These are copied into the 
    # target bundle with a build phase script. Anything else will be cleaned. 
    # You can preserve files from being cleaned, please don't preserve 
    # non-essential files like tests, examples and documentation. 
    # 

    # s.resource = "icon.png" 
    # s.resources = "Resources/*.png" 

    # s.preserve_paths = "FilesToSave", "MoreFilesToSave" 


    # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 
    # 
    # Link your library with frameworks, or libraries. Libraries do not include 
    # the lib prefix of their name. 
    # 

    # s.framework = "SomeFramework" 
    # s.frameworks = "SomeFramework", "AnotherFramework" 

    # s.library = "iconv" 
    # s.libraries = "iconv", "xml2" 


    # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # 
    # 
    # If your library depends on compiler flags you can set them in the xcconfig hash 
    # where they will only apply to your library. If you depend on other Podspecs 
    # you can include multiple dependencies to ensure it works. 

    # s.requires_arc = true 

    # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } 
    # s.dependency "JSONKit", "~> 1.4" 

end 

我旁邊的Podfile:

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

pod 'OrderedDictionary', :podspec => "OrderedDictionary.podspec" 

我跑:

pod cache clean OrderedDictionary && pod install

,它在Pods項目下創建了一個Pods/OrderedDictionary組。

不幸的是,組是空的,所以項目不能建在:

import OrderedDictionary 

error: No such module 'OrderedDictionary'

掉毛通行證:

pod spec lint OrderedDictionary.podspec --verbose

對於我的生活我無法獲得OrderedDictionary.swiftOrderedDictionary.h複製到項目中的pod組中。

奇怪的是,我確實看到OrderedDictionary.h出現在組中一次,但無法讓它再次發生。我擔心CocoaPods可能不是冪等的,但可能會忽略一些明顯的東西。感謝您的任何幫助,您可以提供。

的Xcode 7.2.1(7C1002),OS X 10.10.5(14F27)的CocoaPods 0.39.0

+1

你podspec行之有效通過雙方的CocoaPods v0.39.0和v1.0.0.beta.3我的系統上。請同時發佈您的Podfile。 – IvanRublev

+0

已更新Podfile和環境版本信息。 –

回答

2

回答基於IvanRublev's comment我自己的問題。我想我的podspec在這個IceCreamShop CocoaPods swift example然後後在那裏工作,它在我原來的項目工作。

繁殖步驟:

後,我昨晚寫了這個問題,我咬了子彈和下載的OrderedDictionary GitHub上項目的拉鍊,它擴展到我的項目目錄的根目錄下,動了我的podspec裏面,並改變了我的Podfile說:

pod 'OrderedDictionary', :path => "OrderedDictionary" 

,讓我把它作爲一個發展莢,我看到OrderedDictionary.swift和OrderedDictionary.h複製到吊艙的組。

今天我IceCreamShop工作之後,我刪除了OrderedDictionary目錄從我的項目目錄,打動我podspec回到我的項目目錄的根目錄下,並改變了Podfile回:

pod 'OrderedDictionary', :podspec => "OrderedDictionary.podspec" 

即使我沒有改變任何東西,該吊艙現在工作。

我認爲這可能是在的CocoaPods一個緩存的問題,導致其對下列原因之一是不一致的:

  • 作爲不透明,其中類似的子項目未能建立或過程存在的問題終止將緩存置於不一致的狀態,這使得我們可以通過故障檢測緩存的存在。

  • 沒有被正確無效,所以一旦它發現我的項目目錄中的文件,它以某種方式記住他們,並能夠包括他們後,他們被刪除。

  • 根據負載和存儲的執行位置不同,負載和存儲的行爲會有所不同,允許副作用影響未來的裝載和存儲。

  • 由於超時優先於真值源,存在暫時性問題,其中加載和存儲是非確定性的。

  • 來自遙遠星系的宇宙射線在高速緩存中翻轉了一下,導致我的波狀態陷入了現實,在這個現實中,我花了數小時追逐一個錯誤,而不是從未知道錯誤存在的錯誤。

我喜歡的CocoaPods並意識到這是在臉頰都有點舌頭,但緩存問題往往對生產力有不利的影響,我建議所有的項目有一個選項來禁用其緩存,以及有它每次使用時運行內部一致性檢查。

下面是一些命令,可以幫助別人遇到類似的問題:

sudo rm -rf ~/Library/Caches/CocoaPods/ 
sudo rm -rf ~/.cocoapods/repos/master/ 

sudo rm -rf Pods/ 
pod install