Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
472 views
in Technique[技术] by (71.8m points)

objective c - Use a fork of Restkit on github via CocoaPods?

restkit is using in a different way the oauth2 protocol, I need to change the code to be able to use it in my way:

From:

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

to:

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

Use of "Bearer" instead of "Oauth2" ....

I'm using CocoaPods to import restkit in my project.

Can I fork Restkit repository on github and use the fork via CocoaPod instead of the official version?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You certainly can. Take a look at https://github.com/CocoaPods/CocoaPods/wiki/Dependency-declaration-options

If RestKit included its .podspec file in the repository then you could just change your Podfile to point to your fork i.e.

pod 'RestKit', :git => 'https://github.com/you/RestKit.git'

Unfortunately RestKit does not include its .podspec. Instead copy RestKit.podspec from https://github.com/CocoaPods/Specs/blob/master/RestKit/0.10.2/RestKit.podspec and add it to your project. Edit the .podspec to use your fork as its source. You can then specify a local .podspec in your Podfile:

pod 'RestKit', :podspec => 'local/path/to/RestKit.podspec'

Alternately you might just add this .podspec to your fork and use the former dependency declaration.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...