Go back to Installation for iOS Development
Please make sure you have read:
(WebAppEnv) $ cd /Users/<YOUR NAME HERE>/MyProjects/WeVoteReactNative
(WebAppEnv) $ react-native run-ios
This opens the iOS simulator.
I recommend this method because then you have easier access to the XCode console log.
-
Open XCode.
-
From within XCode, open this project. Be sure to open the xcworkspace! (not the xcodeproj!):
/Users/\<YOUR NAME HERE\>/MyProjects/WeVoteReactNative/ios/WeVoteReactNative.xcworkspace
Don't pick a project from the reverse blue history list on the top right of the dialog, those are xcodeproj's not the xcodeproj files that you need to use.
Click the "Open another project..." link at the bottom right, then select the WeVoteReactNative.xcworkspace entry.
- Click the "Play" (sideways triangle button), and this opens the iOS Simulator.
See "Developing mobile apps with React Native in WebStorm" - https://blog.jetbrains.com/webstorm/2016/12/developing-mobile-apps-with-react-native-in-webstorm/
Be sure to open the xcworkspace! (not the xcodeproj!):
/Users/<YOUR NAME HERE>/MyProjects/WeVoteReactNative/ios/WeVoteReactNative.xcworkspace
If your build is failing due to an issue with RCTWebSocket, you may have to follow the following steps:
-
Cmd+space to bring up spotlight search, type in and double click "RCTWebSocket.xcodeproj".
-
In the project navigator on the left side, click the RCTWebSocket file and click "Build Settings" on the top navbar.
-
Select "All" and "Combined" on the second level of the top navbar below "Build Settings".
-
Look for "Apple LLVM 8.0 - Custom Compiler Flags" and remove all the flags under "Other warning flags". Y ou can do this by double clicking the existing flags and pressing the minus button to remove them individually.
If your build fails due to an error with the message Ignoring return value of function declared with warn_unused_result attribute
,
proceed as instructed below:
-
Cmd+space to bring up spotlight search, type in and double click "RCTWebSocket.M".
-
In "RCTWebSocket.M", find the lines:
int result = SecRandomCopyBytes(kSecRandomDefault, sizeof(uint32_t), (uint8_t *)mask_key);
assert(result == 0);
Comment them out and add the following line:
//int result = SecRandomCopyBytes(kSecRandomDefault, sizeof(uint32_t), (uint8_t *)mask_key);
//assert(result == 0);
(void)SecRandomCopyBytes(kSecRandomDefault, sizeof(uint32_t), (uint8_t *)mask_key);
- Also in "RCTWebSocket.M", find the lines:
int result = SecRandomCopyBytes(kSecRandomDefault, keyBytes.length, keyBytes.mutableBytes);
assert(result == 0);
Comment them out and add the following line:
//int result = SecRandomCopyBytes(kSecRandomDefault, keyBytes.length, keyBytes.mutableBytes);
//assert(result == 0);
(void)SecRandomCopyBytes(kSecRandomDefault, keyBytes.length, keyBytes.mutableBytes);
If you are 'stack-overflowing' around trying to resolve npm issues, be careful about deleting all the node modules and re-installing them. You will see recommendations to "rm -rf node_modules" and then "npm i", ie: physically remove all the downloaded node modules and rebuild from fresh copies, based on the latest versions specified in package.json.
The problem with starting from scratch is (unfortunately) other work arounds will have you editing the source in these downloaded modules, and removing all, will end up with all those edits being lost. Eventually we will get to stability with react-native and other modules that include ObjectiveC and Java, but we are not there yet.