What is the most annoying thing for iOS developers? Undoubtedly is the version of the online review, this should be our common fault, every time the online is careful, because a careless may be rejected, and then call back to modify again, and then wait again. So is there any way to do our version iteration technique without a review? In fact, this technology has existed for a long time, but only JS technology can be used now. It’s not clear why, but apple has officially blocked some technologies. Now I will talk about hot update technology based on JS. So let’s take a look at how JSpatch works.
1. Apply for an account and add our application
We started by signing up for an account on JSpatch’s website and adding our app.
—–> Go to JSpatch
2. Set the project name and PROJECT ID
3. Obtain the appKey
4. Download the JSPatch. Framework import project. Add the following dependency libraries
Dependency library name: libz.tbd
5. Import the JSPatch. Framework library in appdelegate. m and set the AppID.
#import "AppDelegate.h"
#import <JSPatch/JSPatch.h>
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[JSPatch startWithAppKey:@"Your own appID"]; // Check for updates [JSPatch sync];return YES;
}
Copy the code
6. Test the local JS script.
The name of the JS script we generated must be main.js according to JSpatch official requirements. Now we are testing the JS script locally. For tests, we’ll use the +testScriptInBundle method, which will search the project sandbox for ***main.js *** and execute the method once it’s found.
#import "AppDelegate.h"
#import <JSPatch/JSPatch.h>@interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application LaunchOptions didFinishLaunchingWithOptions: (NSDictionary *) {/ / test [JSPatchtestScriptInBundle];
return YES;
}
Copy the code
Note: +testScriptInBundle cannot be called with +startWithAppKey:. +testScriptInBundle is only used for local tests and needs to be removed at the end of the test.
7. Changes in online mode
When we launch our project, we need to move from test mode to live mode. At this point we need to remove our +testScriptInBundle and upload our ***main.js*** file to our server.
#import "AppDelegate.h"
#import <JSPatch/JSPatch.h>
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[JSPatch startWithAppKey:@"Your own appID"]; // Check for updates [JSPatch sync];return YES;
}
Copy the code
Hot update technology is of great significance when we don’t have seven days to make the apple official audit our project, we need to use to hot update technology, make our some bugs, and some corresponding theme to make corresponding modification, is of great significance, of course, JSpatch website price aspects are to be considered part of the problem.