React Native run-ios with .xcworkspace - ios

react-native run-ios --project-path 'ios/myProject.xcworkspace' --simulator=\"iPhone 8 Plus\"
Specifying the project path to the .xcworkspace file fails Could not find Xcode project files in ios folder
I've seen that this is an item proposed in the React Native roadmap: https://react-native.canny.io/feature-requests/p/specifying-the-xcworkspace-to-be-used-in-the-command-line-options
Is there a way (right now) to use Cocoapods with React Native and run with the command line? I'm aware that it works perfectly fine when building through xcode.
Thanks

You should just be able to run it without --project-path. You would use --project-path to specify ios (the folder containing both .xcworkspace and .xcodeproj. Then the CLI will automatically pick .xcworkspace if it exists, otherwise it will pick .xcodeproj. When you start you should get a message like this:
Found Xcode workspace myProject.xcworkspace

Related

Renaming a React Native project

I have a working react native app (without expo), running and compiling in both Android and iOS devices. Now I'm trying to rename the app, but I'm having problems with that.
Steps followed:
I have deleted both ios and android directories.
Changed the project name in my app.json
Regenerated the android and ios directories with react-native upgrade --legacy (cause eject is not working anymore)
Updated my podfile with the need
Pod install
When i tried to compile my app via xcode, I got "null is not an object (evaluating '_RNGestureHandlerModule.default.Direction')
I guessed that was due to the autolinking when you install some react native third party components. So I deleted node_modules, and installed all react native navigation again. Then I ran react-native link. The previous error went away.
Now, I'm stuck with:
Target 'cjlrnneTests' has target dependency on Target 'cjlrnne'
That command depends on command in Target 'cjlrnne': script phase “[CP] Copy Pods Resources”
Honestly, I don't know what else more to do / look for.
Can anyone please provide with some clue, or the steps to change a RN app's name?
Thanks!
You can try this package for renaming the app.
react-native-rename
https://www.npmjs.com/package/react-native-rename
react-native-rename <newName>
It will automatically configure all the things.

Getting error in Xcode no such file or directory found with libReactNativeLocalization.a during build and archive

I am having issue in Xcode while I try to build or archive my react-native project. Xcode throwing error like no such file or directory: '/Users/...../DerivedData/myproject/Build/Products/Debug-iphonesimulator/libReactNativeLocalization.a'.
when I run react-native run-ios or in release mode react-native run-ios --configuration Release then it is working perfectly fine but when I try to build or archive it from Xcode then it is throwing error.
I am using Xcode version 10
My react-native version is 0.57.4
iOS development target is 9.0
react-native-localization version is 2.0.3
Tried things which didn't worked for me
Removed node_modules and pods completely and run npm install and pod install didn't worked for me .
In menue File --> workspace setting changed build system from Use Shared System to Legacy build system. in this particular case app is build and archived successfully but when I lunch my app then it crashes after splash screen.
Removed Derived Data completely and rebuild again still getting this error.
If I remove react-native-localization completely from my project then all the things are working fine and I am able to build and archive the project.
When we run react-native link react-native-localization command then it also applies the changes on ios app too which creates an issue in our case. So due to this command, it creates an entry in project_name → ios → podfile (podfile)
Here ReactNativeLocalization is pointing to project_name/node_modules/react-native-localization directory due to this line when we run pod install command then there is one dependence React in this package is going to reinstall in your pods as you can see in this image.(as you can see here)
Follow the following steps to overcome form this issue
After react-native link react-native-localization command navigate to project_name → ios → podfile and remove or comment pod ‘ReactNativeLocalization’, :path => ‘../node_modules/react-native-localization’
Now its time to link react-native-localization library manually from Xcode. So to link this library manually open project_name → ios → project_name.xcworksace file in Xcode and select your target.
After that in project navigator right click on library and select Add Files to “...” and after that navigate to project_name → node_modules → react-native-localization and select ReactNativeLocalization.xcodeproj file.
Now navigate to project Target → Build Phase and expand Link Binary With Library after that click on plus icon and add libReactNativeLocalization.a library
I had been stuck on this issue since morning. A simple hack made my build.
I observed that in folder Xcode/DerivedData/MyProject/Build/Products/Debug-iphonesimulator/ lib files were being generated in their folder. i.e libLinearGradient.a was in libLinearGradient.
One .a file which was being successfully lined was there without it's folder so I did the same for all .a files. ( Simply put them outside without their folder.)
So now path became Xcode/DerivedData/MyProject/Build/Products/Debug-iphonesimulator/libLinearGradient.a instead of Xcode/DerivedData/MyProject/Build/Products/Debug-iphonesimulator/libLinearGradient/libLinearGradient.a

React Native - .xcworkspace doesn't contain any files after pulling from git

I've just pulled my latest commits at home, run npm install and then get some issues running react-native run-ios:
xcodebuild: error: The workspace named "Contractor" does not contain a scheme named "Contractor". The "-list" option can be used to find the names of the schemes in the workspace.
When I opened up the .xcworkspace in XCode there's nothing in the project navigator sidebar and no schemes. If I open up the .xcodeproj file, all of my source files are there, so it seems like there's been some disconnect between the workspace and the project?
I'm not really sure where to go from here..
Are you using cocoapods? I ran into the same issue, cd PROJECT_ROOT/ios && pod install fix it for me.

Why does my xcode project build on simulator but not device in xcode project?

I have a react native project that runs successfully on simulator but not on device.
I have run the project on the same device before, but not since I've incorporated cocoapods, though none of the above library are in cocoapods. I'm building in xcworkspace rather than a project file, not sure if that is it.
Not sure what this could be... Any suggestions appreciated!
Usually these type of errors appear when the libraries are not linked with the project.
The libraries might have been unlinked after adding cocoapods. Try running npm install and then react-native link to link all the libraries or run react-native link <library-name> to link the specific library in the terminal from your project root directory.

Missing dependency target "CordovaLib (from CordovaLib.xcodeproj)"

Missing dependency target "CordovaLib (from CordovaLib.xcodeproj)" When running ios with Xcode
A different solution
Before reading this MAKE SURE you are opening YourProject.xcworkspace and NOT YourProject.xcodeproj
I couldn't get this to work using #manzapanza 's solution
The Problem
CordovaLib.xcodeproj is missing from your xcode project
Solution (for mac users)
Download a copy of CordovaLib.xcodeproj and drag it into your xcode project.
$ sudo npm install -g cordova (installs a "global" copy of cordova to your computer, you might be able to skip this step)
$ find ~/ -name 'CordovaLib.xcodeproj' (mine was at /Users/Jackson//.cordova/lib/npm_cache/cordova-ios/4.3.1/package/tests/spec/unit/fixtures/ios-config-xml/CordovaLib/CordovaLib.xcodeproj)
Open folder the folder path found above $ open [path] (open /Users/Jackson//.cordova/lib/npm_cache/cordova-ios/4.3.1/package/tests/spec/unit/fixtures/ios-config-xml/CordovaLib/)
Drag CordovaLib.xcodeproj to your xcode project
This is what your file navigator should look like at this point:
Delete red (missing) file
Select your app in the navigator (very top of file tree). Go to Targets > [Your Project Name] > Build Phases > Link Binary With Libraries > "+"
type in / look for libCordova.a and add it
Compile project
For some reasons the xcode project was corrupted. Generally, to solve this kind of problems, you can try removing and re-adding the platform ios:
ionic platform rm ios
ionic platform add ios
ionic build ios
Attention: Any changes that you applied directly from xcode will be lost and you will need to apply manually after you will have run these commands. Do a backup of platforms/ios before.
Same solution for Apache Cordova project.
Remove platform and re-add:
cordova platform remove ios
cordova platform add ios
cordova prepare ios
cordova run ios
Successful!
I downgraded my Cordova version to 6.2.0 and it started working.
I had multiple issues with my app that I was able to resolve when I was missing CordovaLib from my XCode project.
First I ran
cordova requirements ios
and found that I was missing ios-deploy and CocoaPods. These were not requirements for Cordova 6.2.0 but are as of Cordova 6.4.0. I did not try 6.3.0 so I do not know the status for that version.
In addition, I had some icon files in my config.xml for iOS that did not exist because I was using a 3rd party cordova-icon maker to generate them and the fact that they were missing was apparently breaking the add platform command mid-process. Again 6.2.0 did not have this issue with the same config file, but 6.4.0 is definitely strict about not having any errors. My guess is that they were either continuing past the errors in prior version of Cordova or they re-arranged the way things are built so that the CordovaLib is now last and if there are any errors before that step, you will be missing the folder and its contents.

Resources