Skip to content

Commit

Permalink
chore(ios): make sdk version using macro defines
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwcg authored and hippy-actions[bot] committed Oct 30, 2023
1 parent f2ba451 commit 355a1bf
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
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

0 comments on commit 355a1bf

Please sign in to comment.