mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-08 09:12:05 +08:00
Summary: Updated the commands provided in the comments to re-generate the static bundle in the Movies and UIExplorer examples, making them match the URL used in `sourceURL` while in dev mode. Closes https://github.com/facebook/react-native/pull/3132 Reviewed By: @svcscm Differential Revision: D2547140 Pulled By: @vjeux fb-gh-sync-id: 450049d3c3d4eb9919d0a3a6bd6c611e90d0f958
91 lines
3.1 KiB
Objective-C
91 lines
3.1 KiB
Objective-C
/**
|
|
* The examples provided by Facebook are for non-commercial testing and
|
|
* evaluation purposes only.
|
|
*
|
|
* Facebook reserves all rights not expressly granted.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
|
|
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
#import "AppDelegate.h"
|
|
|
|
#import "RCTBridge.h"
|
|
#import "RCTJavaScriptLoader.h"
|
|
#import "RCTRootView.h"
|
|
|
|
@interface AppDelegate() <RCTBridgeDelegate>
|
|
|
|
@end
|
|
|
|
@implementation AppDelegate
|
|
|
|
- (BOOL)application:(__unused UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
|
{
|
|
RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self
|
|
launchOptions:launchOptions];
|
|
|
|
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
|
|
moduleName:@"UIExplorerApp"
|
|
initialProperties:nil];
|
|
|
|
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
|
UIViewController *rootViewController = [UIViewController new];
|
|
rootViewController.view = rootView;
|
|
self.window.rootViewController = rootViewController;
|
|
[self.window makeKeyAndVisible];
|
|
return YES;
|
|
}
|
|
|
|
- (NSURL *)sourceURLForBridge:(__unused RCTBridge *)bridge
|
|
{
|
|
NSURL *sourceURL;
|
|
|
|
/**
|
|
* Loading JavaScript code - uncomment the one you want.
|
|
*
|
|
* OPTION 1
|
|
* Load from development server. Start the server from the repository root:
|
|
*
|
|
* $ npm start
|
|
*
|
|
* To run on device, change `localhost` to the IP address of your computer
|
|
* (you can get this by typing `ifconfig` into the terminal and selecting the
|
|
* `inet` value under `en0:`) and make sure your computer and iOS device are
|
|
* on the same Wi-Fi network.
|
|
*/
|
|
|
|
sourceURL = [NSURL URLWithString:@"http://localhost:8081/Examples/UIExplorer/UIExplorerApp.ios.bundle?platform=ios&dev=true"];
|
|
|
|
/**
|
|
* OPTION 2
|
|
* Load from pre-bundled file on disk. To re-generate the static bundle, `cd`
|
|
* to your Xcode project folder and run
|
|
*
|
|
* $ curl 'http://localhost:8081/Examples/UIExplorer/UIExplorerApp.ios.bundle?platform=ios' -o main.jsbundle
|
|
*
|
|
* then add the `main.jsbundle` file to your project and uncomment this line:
|
|
*/
|
|
|
|
// sourceURL = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
|
|
|
|
#if RUNNING_ON_CI
|
|
sourceURL = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
|
|
#endif
|
|
|
|
return sourceURL;
|
|
}
|
|
|
|
- (void)loadSourceForBridge:(RCTBridge *)bridge
|
|
withBlock:(RCTSourceLoadBlock)loadCallback
|
|
{
|
|
[RCTJavaScriptLoader loadBundleAtURL:[self sourceURLForBridge:bridge]
|
|
onComplete:loadCallback];
|
|
}
|
|
|
|
@end
|