Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ios): make sdk version using macro defines #3571

Merged
merged 2 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion framework/ios/base/bridge/HippyBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
NSString *const HippyJavaScriptDidLoadNotification = @"HippyJavaScriptDidLoadNotification";
NSString *const HippyJavaScriptDidFailToLoadNotification = @"HippyJavaScriptDidFailToLoadNotification";
NSString *const HippyDidInitializeModuleNotification = @"HippyDidInitializeModuleNotification";
NSString *const HippySDKVersion = @"unspecified";
NSString *const HippySDKVersion = @HIPPY_STR(HIPPY_VERSION);


static NSString *const HippyNativeGlobalKeyOS = @"OS";
Expand Down
3 changes: 3 additions & 0 deletions hippy.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ Pod::Spec.new do |s|
base.source_files = ['modules/ios/base/*.{h,m,mm}', 'modules/ios/logutils/*.{h,mm}']
base.public_header_files = ['modules/ios/base/*.h', 'modules/ios/logutils/*.h']
base.dependency 'hippy/Footstone'
base.pod_target_xcconfig = {
'GCC_PREPROCESSOR_DEFINITIONS' => 'HIPPY_VERSION=' + s.version.to_s,
}
puts 'hippy subspec \'base\' read end'
end

Expand Down
5 changes: 5 additions & 0 deletions modules/ios/base/HippyDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@
#define HIPPY_CONCAT2(A, B) A##B
#define HIPPY_CONCAT(A, B) HIPPY_CONCAT2(A, B)

/**
* Convert number macro to string
*/
#define HIPPY_STR(x) HIPPY_STR_EXPAND(x)
#define HIPPY_STR_EXPAND(x) #x

/**
* Throw an assertion for unimplemented methods.
Expand Down
12 changes: 12 additions & 0 deletions modules/ios/base/HippyUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,16 @@ HIPPY_EXTERN NSString *HippySchemeFromURLString(NSString *urlString);
//Get String Encoding From HTTP URL Response
HIPPY_EXTERN NSStringEncoding HippyGetStringEncodingFromURLResponse(NSURLResponse *response);


#pragma mark -

/// 工具类
@interface HippyUtils : NSObject

/// SDK版本号
+ (NSString *)sdkVersion;

@end


NS_ASSUME_NONNULL_END
11 changes: 11 additions & 0 deletions modules/ios/base/HippyUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -698,3 +698,14 @@ id HippyJSONClean(id object) {

return HippyMakeError(errorMessage, nil, errorInfo);
}


#pragma mark -

@implementation HippyUtils

+ (NSString *)sdkVersion {
return @(HIPPY_STR(HIPPY_VERSION));
}

@end
Loading