通过CocoaPods在github上使用Restkit的fork?

Nic*_*nin 32 objective-c ios restkit cocoapods

restkit以不同的方式使用oauth2协议,我需要更改代码以便能够以我的方式使用它:

从:

// OAuth 2 valid request
if (self.authenticationType == RKRequestAuthenticationTypeOAuth2) {
    NSString *authorizationString = [NSString stringWithFormat:@"OAuth2 %@", self.OAuth2AccessToken];
    [_URLRequest setValue:authorizationString forHTTPHeaderField:@"Authorization"];
}
Run Code Online (Sandbox Code Playgroud)

至:

// OAuth 2 valid request
if (self.authenticationType == RKRequestAuthenticationTypeOAuth2) {
    NSString *authorizationString = [NSString stringWithFormat:@"Bearer %@", self.OAuth2AccessToken];
    [_URLRequest setValue:authorizationString forHTTPHeaderField:@"Authorization"];
}
Run Code Online (Sandbox Code Playgroud)

使用"Bearer"而不是"Oauth2"....

我正在使用CocoaPods在我的项目中导入restkit.

我可以在github上分叉Restkit存储库并通过CocoaPod而不是官方版本使用fork吗?

Jon*_*nah 88

你当然可以.看看https://github.com/CocoaPods/CocoaPods/wiki/Dependency-declaration-options

如果RestKit将其.podspec文件包含在存储库中,那么您可以将其更改Podfile为指向您的分叉即

pod 'RestKit', :git => 'https://github.com/you/RestKit.git'
Run Code Online (Sandbox Code Playgroud)

不幸的是,RestKit不包括它.podspec.而是RestKit.podspechttps://github.com/CocoaPods/Specs/blob/master/RestKit/0.10.2/RestKit.podspec复制并将其添加到您的项目中.编辑.podspec以使用fork作为其源.然后,您可以指定一个地方.podspecPodfile:

pod 'RestKit', :podspec => 'local/path/to/RestKit.podspec'
Run Code Online (Sandbox Code Playgroud)

或者,您可以将其添加.podspec到fork并使用以前的依赖项声明.