IOS開發基礎知識--碎片41

1:UIWebView加載本地的HTMLcss

NSString *path = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:path];
NSString * htmlPath = [[NSBundle mainBundle] pathForResource:@"index1"
                                                      ofType:@"html"];
NSString * htmlCont = [NSString stringWithContentsOfFile:htmlPath
                                                encoding:NSUTF8StringEncoding
                                                   error:nil];
[self.webView loadHTMLString:htmlCont baseURL:baseURL];

注意:如何建立工程內的Css,js,html文件,建立iOS -other-Empty 若是Css 則以.css結尾,Js則以.js結尾,Html則是以.html結尾html

 

2:JSPatch的運用ios

a:OC轉JSPatch的地址:http://bang590.github.io/JSPatchConvertor/git

b:JSPatch腳本介紹地址:https://github.com/bang590/JSPatch/wikigithub

c:比較不錯的文章地址:ww.cnblogs.com/dsxniubility/p/5080875.htmlweb

d:JSPatch自動補地址:https://github.com/bang590/JSPatchXsql

注意版本控制(能夠根據APP的版本號架服務端的請求地址)跟JS安全性(MD5加密而後再APP解密);swift

管理中心的一些考慮:xcode

下面分享一個幫助類:安全

#import "JSPatchHelper.h"

//文件名稱
NSString * const jsPatchJsFileName=@"main.js";

@implementation JSPatchHelper

+ (instancetype)sharedInstance
{
    static JSPatchHelper* instance = nil;

    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [JSPatchHelper new];
    });

    return instance;
}


+(void)HSDevaluateScript
{
    //從本地獲取下載的JS文件
    NSURL *p = FilePath;
    
    //判斷文件是否存在
    NSString *curFilePath=[p.path stringByAppendingString:[NSString stringWithFormat:@"/%@",jsPatchJsFileName]];
    if (![[NSFileManager defaultManager] fileExistsAtPath:curFilePath]) {
        return;
    }
    
    //獲取內容
    NSString *js = [NSString stringWithContentsOfFile:curFilePath encoding:NSUTF8StringEncoding error:nil];
    
    //若是有內容
    if (js.length > 0)
    {
        //-------
        //服務端要對JS內容進行加密,在此處解密js內容;增長安全性
        //----
        
        
        //運行
        [JPEngine startEngine];
        [JPEngine evaluateScript:js];
    }
}


+(void)loadJSPatch
{
    //優化間隔一段時間 再去請求一次 不然太頻繁(這邊定義爲一個小時纔去請求一次)
    NSDate *myNowDate=[NSDate date];
    if (!BBUserDefault.MBJsPatchTime) {
        BBUserDefault.MBJsPatchTime=myNowDate;
        return;
    }
    if ([myNowDate timeIntervalSinceDate:BBUserDefault.MBJsPatchTime]<3600) {
        return;
    }
    
    //使用AFNetWork下載在服務器的js文件
    NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
    AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
    NSURL *URL = [NSURL URLWithString:kJSPatchServerPath];
    NSURLRequest *request = [NSURLRequest requestWithURL:URL];
    NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:nil destination:^NSURL *(NSURL *targetPath, NSURLResponse *response)
                                              {
                                                  NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response;
                                                  if (httpResponse.statusCode==200) {
                                                      NSURL *documentsDirectoryURL = FilePath;
                                                      //保存到本地 Library/Caches目錄下
                                                      return [documentsDirectoryURL URLByAppendingPathComponent:jsPatchJsFileName];
                                                  }
                                                  else
                                                  {
                                                      return nil;
                                                  }
                                              }
                                                            completionHandler:^(NSURLResponse *response, NSURL *filePath, NSError *error)
                                              {
                                                  NSLog(@"下載失敗 to: %@", filePath);
                                              }];
    [downloadTask resume];
}


@end

詳細的源代碼能夠到:https://github.com/wujunyang/MobileProject查看

 

3:證書快要過時問題

第一步:若是開發者證書過時了的話,首先,打開密鑰中心,生成一個CSR(證書請求)。而後,到Apple Center把證書revoke,而後新建一個,新建的將會默認是剛剛revoke的證書的全部設置的。把下載回來的證書導出一份p12格式的保存起來(由於若是其餘人須要的時候,只能跟你拿了,在Apple Center下載的用不了的。)而後去provision profile edit 一下,重新下載,替換掉原來的。你就能夠繼續開發了(對外面已經安裝的用戶不會有影響)。

 

第二步:安裝新的p12證書,並下載修改後的描述文件,若是本地已經安裝之後的provisioning profile要先進行刪除,能夠進入~/Library/MobileDevice/Provisioning Profiles ,找到相應的文件進行刪除,由於在文件裏面它是以一串字符爲命名,能夠把舊證書先刪除而後在Xcode裏面打包,它會有提示這個provisioning profile的名字,刪除就能夠;而後在進行安裝最新的provisioning profile,並選擇相應證書就能夠了;

 

 

4:給項目新建文件都默認增長前綴

5:iOS遠程推送知識點

咱們的設備聯網時(不管是蜂窩聯網仍是Wi-Fi聯網)都會與蘋果的APNs服務器創建一個長鏈接(persistent IP connection),當Provider(咱們自個的後臺服務器,用於推送)推送一條通知的時候,這條通知並非直接推送給了咱們的設備,而是先推送到蘋果的APNs服務器上面,而蘋果的APNs服務器再經過與設備創建的長鏈接進而把通知推送到咱們的設備上(參考圖1-1,圖1-2)。而當設備處於非聯網狀態的時候,APNs服務器會保留Provider所推送的最後一條通知,當設備轉換爲連網狀態時,APNs則把其保留的最後一條通知推送給咱們的設備;若是設備長時間處於非聯網狀態下,那麼APNs服務器爲其保存的最後一條通知也會丟失。Remote Notification必需要求設備連網狀態下才能收到,而且太頻繁的接收遠程推送通知對設備的電池壽命是有必定的影響的。

deviceToken的生成:當一個App註冊接收遠程通知時,系統會發送請求到APNs服務器,APNs服務器收到此請求會根據請求所帶的key值生成一個獨一無二的value值也就是所謂的deviceToken,然後APNs服務器會把此deviceToken包裝成一個NSData對象發送到對應請求的App上。而後App把此deviceToken發送給咱們本身的服務器,就是所謂的Provider。Provider收到deviceToken之後進行儲存等相關處理,之後Provider給咱們的設備推送通知的時候,必須包含此deviceToken

遠程推送內容

每一條通知的消息都會組成一個JSON字典對象,其格式以下所示,示例中的key值爲蘋果官方所用key。自定義字段的時候要避開這些key值。

{
     "aps" : {  
         "alert"              :              {   // string or dictionary
            "title"          :   "string"
            "body"           :   "string",
            "title-loc-key"  :   "string or null"
            "title-loc-args" :   "array of strings or null"
            "action-loc-key" :   "string or null"
            "loc-key"        :   "string"
            "loc-args"       :   "array of strings"
            "launch-image"   :   "string"
         },
          "badge"             :    number,
          "sound"             :    "string"
          "content-available" :    number;
          "category"          :    "string"
     },
}

aps:推送消息必須有的key

alert:推送消息包含此key值,系統就會根據用戶的設置展現標準的推送信息
badge:在app圖標上顯示消息數量,缺乏此key值,消息數量就不會改變,消除標記時把此key對應的value設置爲0
sound:設置推送聲音的key值,系統默認提示聲音對應的value值爲default
content-available:此key值設置爲1,系統接收到推送消息時就會調用不一樣的回調方法,iOS7以後配置後臺模式
category:UIMutableUserNotificationCategory's identifier 可操做通知類型的key值

title:簡短描述此調推送消息的目的,適用系統iOS8.2以後版本
body:推送的內容
title-loc-key:功能相似title,附加功能是國際化,適用系統iOS8.2以後版本
title-loc-args:配合title-loc-key字段使用,適用系統iOS8.2以後版本
action-loc-key:可操做通知類型key值,不詳細敘述
loc-key:參考title-loc-key
loc-args:參考title-loc-args
launch-image:點擊推送消息或者移動事件滑塊時,顯示的圖片。若是缺乏此key值,會加載app默認的啓動圖片。

固然以上key值並非每條推送消息都必帶的key值,應當根據需求來選擇所須要的key值,除了以上系統所提供的key值外,你還能夠自定義本身的key值,來做爲消息推送的負載,自定義key值與aps此key值並列。以下格式:

{
    "aps" : {
        "alert" : "Provider push messag.",
        "badge" : 9,
        "sound" : "toAlice.aiff"
    },
    "Id"   : 1314,               //  自定義key值
    "type" : "customType"        //  自定義key值
}

指定用戶的推送

對於要求用戶登陸的App,推送是能夠指定用戶的,同一條推送有些用戶能夠收到,可是有些用戶又不能收到。提及來這個就要提到另外的一個token了,通常稱之爲userToken,userToken通常都是根據本身公司自定義的規則去生成的。userToken是以用戶的帳號加對應的密碼生成的。這樣結合上面提到的deviceToken,就能夠作到根據不一樣的用戶推送不一樣的消息。deviceToken找到對應某臺設備和該設備上的應用,而userToken對應找到該用戶。客戶端在上報deviceToken的時候,要把userToken對應一塊兒上報給服務端也就是Provider。

 

6:建立私有pod

關於這方面的知識能夠查看下面幾個文章,有時間再寫一篇文章

http://www.jianshu.com/p/ddc2490bff9f[如何建立私有 CocoaPods 倉庫]

http://www.jianshu.com/p/7a82e977281c[製做 CocoaPods 依賴庫]

http://blog.devzeng.com/blog/ios-cocoapods-private-repo.html [在iOS項目中使用CocoaPods私有庫]

http://www.pluto-y.com/cocoapods-getting-stared/ [Cocoapods系列教程1,2,3]

http://www.cocoachina.com/ios/20150228/11206.html[使用Cocoapods建立私有podspec]

http://www.jianshu.com/p/1139a603f413[建立私有pod]

http://eric-gao.iteye.com/blog/2128283  [提交framework到cocoapods官方去]

下面來幾張成功建立的圖片:

 
 

 

 

 

配置文件:

#
#  Be sure to run `pod spec lint WjyTestClasses.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         = "WjyTestClasses"
  s.version      = "0.0.2"
  s.summary      = "這是一個簡單的測試運用類"

  # 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  = DESC


  s.homepage     = "https://github.com/wujunyang/WjyTestClasses"
  # 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      = { :type => "MIT", :file => "/Doc/GitHub/WjyTestClasses/FILE_LICENSE" }


  # ――― 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             = { "wujunyang" => "wujunyang@126.com" }
  # Or just: s.author    = "wujunyang"
  # s.authors            = { "wujunyang" => "wujunyang@126.com" }
  # s.social_media_url   = "http://twitter.com/wujunyang"

  # ――― 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, "7.0"

  #  When using multiple platforms
  # s.ios.deployment_target = "5.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/wujunyang/WjyTestClasses.git", :tag => "v0.0.2" }


  # ――― 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  = "Pod/Classes/**/*.{h,m}"
#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

注意: a. s.version應和tag的版本一致.先push該文件以後,再push --tags

b. 將源代碼放置在固定的文件夾下,同時修改s.source

c. 必定要有開源協議

d.在私有庫中引用私有庫(配置文件 首先要寫上s.dependency)

即在Podspec文件中依賴(dependency)私有庫 這種狀況就比較麻煩一點,由於畢竟Podspec文件中並無指明私有倉庫地址的地方。那麼確定就不在Podspec文件裏面指明私有倉庫的地方。而是在驗證和上傳私有庫的時候進行指明。即在下面這兩條命令中進行指明:pod lib lint 項目名.podspec --sources=https://github.com/CocoaPods/Specs.git,192.168.0.100:Plutoy/Specs.git以及pod repo push --source=https://github.com/CocoaPods/Specs.git,192.168.0.100:Plutoy/Specs.git,要否則你在檢驗項目以及提交項目過程當中就會出現Error的狀況。

可是這兩種狀況仍是有點不一樣的,第一種狀況是能夠採用開發者模式,而第二種狀況不能採用開發者模式,只能經過打tag以後才能進行使用,因此在使用第二種狀況下最好是測試好以後打完tag再進行引用。

要推到私有倉庫時,先打上對應的TAG,而後也要加上sources指令:

 

e:模塊化配置:

Pod::Spec.new do |s|

s.name         = "jiaCore"
s.version      = "0.0.7"
s.summary      = "這是一個簡單SDFSDFSDF的測試運JIA用類"

s.homepage     = "https://github.com/wujunyang/jiaCore"
s.license      = { :type => "MIT", :file => "/Doc/GitHub/jiaCore/FILE_LICENSE" }
s.author             = { "wujunyang" => "wujunyang@126.com" }

s.platform     = :ios, "7.0"

s.source       = { :git => "https://github.com/wujunyang/jiaCore.git", :tag => "0.0.7" }

s.requires_arc = true

s.subspec 'JiaCore' do |jiaCore|
jiaCore.source_files = 'Pod/JiaCore/**/*.{h,m}'
end

s.subspec 'JIQNetwork' do |networkEngine|
networkEngine.source_files = 'Pod/YTKNetwork/**/*'
networkEngine.dependency 'AFNetworking', '~> 2.6.3'
networkEngine.dependency 'AFDownloadRequestOperation'
end

s.subspec 'JIQJCAlertView' do |jiqAlertView|
jiqAlertView.source_files = 'Pod/JCAlertView/**/*'
jiqAlertView.resource ='Pod/JCAlertView/JCAlertView.bundle'
end

s.frameworks = 'UIKit'

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

結構以下:

這樣就能夠全引用,也能夠模塊引用

其它實例:

platform :ios, '7.0'
 
pod 'PodTestLibrary/NetWorkEngine', '1.0.0'  #使用某一個部分
pod 'PodTestLibrary/UIKitAddition', '1.0.0'
 
pod 'PodTestLibrary', '1.0.0'   #使用整個庫

 

f:依賴自身模塊的寫法:

Pod::Spec.new do |s|

s.name         = "jiaCore"
s.version      = "0.0.10"
s.summary      = "這是一個簡單SDFSDFSDF的測試運JIA用類"

s.homepage     = "https://github.com/wujunyang/jiaCore"
s.license      = { :type => "MIT", :file => "/Doc/GitHub/jiaCore/FILE_LICENSE" }
s.author             = { "wujunyang" => "wujunyang@126.com" }

s.platform     = :ios, "7.0"

s.source       = { :git => "https://github.com/wujunyang/jiaCore.git", :tag => "0.0.10" }

s.requires_arc = true

s.subspec 'JiaCore' do |jiaCore|
jiaCore.source_files = 'Pod/JiaCore/**/*.{h,m}'
end

s.subspec 'JiaUmeng' do |jiaumeng|
jiaumeng.source_files = 'Pod/UmengCore/**/*.{h,m}'
jiaumeng.dependency 'jiaCore/JiaCore'
end



s.frameworks = 'UIKit'

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

特別注意:jiaumeng.dependency 'jiaCore/JiaCore'

提交podspec文件到Spec倉庫
1.檢查podspec文件是否正確
pod spec lint Foundation-pd.podspec --verbose --sources='git@gitlab.com:zengjing/Specs.git,https://github.com/CocoaPods/Specs' --use-libraries

2.提交podspec文件到Spec庫
pod repo push zengjing-spec Foundation-pd.podspec --verbose --sources='git@gitlab.com:zengjing/Specs.git,https://github.com/CocoaPods/Specs' --use-libraries --allow-warnings

實例:

 

說明:

(1)--verbose:表示顯示所有的日誌信息,建議加上這個,方便判斷錯誤信息。

(2)--sources:若是咱們在podspec裏面依賴到一些私有的庫以後,直接進行校驗是會報錯的提示找不到,這裏加上咱們的Spec倉庫的地址告訴CocoaPods找不到的時候去哪裏找。

(3)--allow-warnings:表示容許警告.

(4)--use-libraries:表示使用靜態庫或者是framework,這裏主要是解決當咱們依賴一些framework庫後校驗提示找不到庫的時候用到。

 

g:[iOS] xcodebuild: Returned an unsuccessful exit code錯誤解決方式:

pod repo push <repo-name> <podspec-file-name>.podspec --allow-warnings --use-libraries  加上指令:--use-libraries

 

8:若是依賴別人的SDK報錯解決

能夠把SDK相關的內容,在公司私有再架一個,而後依賴公司的私庫;

#
#  Be sure to run `pod spec lint getui-sdk-ios-cocoapods.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         = "QiJIAGTSDK"
  s.version      = "1.4.3"
  s.summary      = "個推iOS SDK Cocoa Pods集成庫"

  s.description  = <<-DESC
                   A longer description of getui-sdk-ios-cocoapods in Markdown format.

                   個推iOS SDK
                   DESC

  s.homepage     = "https://github.com/GetuiLaboratory/getui-sdk-ios-cocoapods"
  # 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 (example)"
  s.license      = { :type => "MIT", :file => "LICENSE" }


  # ――― 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             = { "個推" => "support@getui.com" }
  # Or just: s.author    = "個推實驗室"
  # s.authors            = { "個推實驗室" => "support@getui.com" }
  # s.social_media_url   = "http://twitter.com/個推實驗室"

  # ――― 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, "7.0"

  #  When using multiple platforms
  s.ios.deployment_target = "7.0"
  # s.osx.deployment_target = "10.7"
  # s.watchos.deployment_target = "2.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/wujunyang/jiaGTSDK.git", :tag => "1.4.3" }


  # ――― 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  = "Pod/**/*.{h,m}"
  #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 = "libGeTuiSdk-1.4.2.a"
  s.ios.vendored_library = "libGeTuiSdk-1.4.2.a"


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

  #s.framework  = "UIKit"
  # s.frameworks = "SomeFramework", "AnotherFramework"
  s.frameworks = 'SystemConfiguration', 'CFNetwork','CoreTelephony','CoreLocation','AVFoundation','CoreBluetooth','Security','JavaScriptCore'
  s.ios.frameworks = 'SystemConfiguration', 'CFNetwork','CoreTelephony','CoreLocation','AVFoundation','CoreBluetooth','Security','JavaScriptCore'
  # s.library   = "sqlite3"
  s.ios.libraries = 'z','sqlite3.0'

  # ――― 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 "jiaCore"
end

把個推相關文件下載,並修改podspec讓它指向咱們當前的GIT,而後工程裏面引入QiJAGSDK就能夠了,也會把個推的文件引入;

 

9:若是提交時報下面這一句:

[!] The validator for Swift projects uses Swift 3.0 by default, if you are using a different version of swift you can use a `.swift-version` file to set the version for your Pod. For example to use Swift 2.3, run: 

    `echo "2.3" > .swift-version`.

 

解決問題:

 

在命令終端輸入:

 

echo 3.0 > .swift-version

 

 

10:報以下錯誤:

 

ERROR | name: The name of the spec should match the name of the file.

 

是由於.podspec文件的名字跟腳本內還有提交的指令沒有對應上,特別要當心大小寫

 

 

11:問題file not found with <angled> include; use "quotes" instead

 

 [JiaCordova/JiaCordovaManager] xcodebuild:  /gitHub/JiaCordova/JiaCordova/JiaCordovaManager/JiaCordovaViewController.h:9:9: error: 'CDV.h' file not found with <angled> include; use "quotes" instead

 

這個是引入頭文件時要注意;

 

引入#import <CDV.h>時報錯的,由於是第三方庫因此要把其前綴也帶上;以下面

 

#import <Cordova/CDV.h>

相關文章
相關標籤/搜索