配置阶段
安装Cocoapods
git clone https://coding.net/u/hging/p/Specs/git ~/.cocoapods/repos/master
pod setup
pod install --verbose --no-repo-update
pods 文件配置
https://www.jianshu.com/p/8a0fd6150159
错误解决
- pod 安装
通过
pod init
初始化Podfile
,然后执行pod install
时出现
[!] The 'Pods-qianfengDriver' target has transitive dependencies that include statically linked binaries:
(/Users/xlz/Desktop/qianfengDriver/ios/Pods/AMap3DMap/MAMapKit.framework)
解决:
在 Podfile
文件中注释
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!
- 打包的时候卡在
building: double-conversion|Building n of NN tasks ...
原因: 打开 /项目/node_modules/react-native/scripts/ios-install-third-party.sh
中可以看到下面4个文件(每个项目环境需要的文件版本会不一样),项目构建的时候需要这四个文件,若是本地没有,则需要去 GitHub clone,所以速度慢
https://github.com/google/glog/archive/v0.3.5.tar.gz
https://github.com/google/double-conversion/archive/v1.1.6.tar.gz
https://github.com/react-native-community/boost-for-react-native/releases/download/v1.63.0-0/boost_1_63_0.tar.gz
https://github.com/facebook/folly/archive/v2018.10.22.00.tar.gz
解决: 手动下载 ios-install-third-party.sh
中需要的几个文件,放在目录 ~/.rncache/
下,注意下载到的文件名和.sh里面的文件名是否相同。
AMapFoundationKit/AMapFoundationKit.h file not found
高德地图组件react-native-amap3d
官方配置完成后如果出现该问题,还需要配置下图,即可解决Loading...Loading...- bitcode 错误
does not contain bitcode.
You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE),
obtain an updated library from the vendor, or disable bitcode for this target.
解决:Build Settings
中修改 Enable Bitcode
为 No
- 极光推送
undefined symbol: _OBJC_CLASS_$_JPUSHRegisterEntity
选择6、6s、7,及这些的plus的模拟器
真机测试阶段
团队证书问题
Code Signing Error: Signing for "qianfengDriverTests" requires a
development team. Select a development team in the project editor.
Code Signing Error: Code signing is required for product type
'Unit Test Bundle' in SDK 'iOS 11.4'
解决:
Build Settings
中Code Signing Identity
修改为iOS Developer
- 把
Development Team
选择对应的团队
注意:报错信息中含有 qianfengDriverTests
,那么需要切换到对应的 target
修改
Loading...
连接服务器
手机和电脑都必须在同一局域网中
- 查看电脑的IP地址,在
terminal
中输入ifconfig | grep 192
- 在
AppDelegate.m
文件中修改jsCodeLocation
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSURL *jsCodeLocation;
NSString *cacheDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *path = [cacheDir stringByAppendingPathComponent:@"index.ios.jsbundle"];
if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
jsCodeLocation = [NSURL fileURLWithPath:path];
} else {
#ifdef DEBUG
// jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
jsCodeLocation = [NSURL URLWithString:@"http://192.168.31.71:8081/index.bundle?platform=ios&dev=true"];
#else
jsCodeLocation = [CodePush bundleURL];
#endif
}
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"driverClient"
initialProperties:nil
launchOptions:launchOptions];
// 其它代码
iOS 9+
系统需要在Info.plist
文件中配置Loading...- 项目根目录运行
react-native start --reset-cache