How to build and run ios app in specified folder on device? - ios

After pressing build and run button in XCode I want to install my app to the specified folder on my device. For example, in directory "/DebugApps". Can I do it?

I'm not sure why you would even want to do that, but no, that is an automated process and the corresponding folders are created by the system.

Related

How do I find the iOS Product Bundle Identifier without XCode?

I'm on a linux machine and am unable to run XCode. I have a React Native application. Based on what I've read online, the only way to view the Product Bundle Identifier is to run XCode which isn't possible for me. I need this for my app's Auth0 integration. I use expo to run the app.
Yes, it's possible. What you need to do is go to the ios folder (If you don't see it, you have to run expo eject), then go into the chatapp.xcodeproj directory, and open the project.pbxproj as a plaintext file. After that, look for "PRODUCT_BUNDLE_IDENTIFIER" and you should find what you're looking for!

Xcode: invalid symlink error when trying to run app in iOS simulator

At the end of my app's compilation phase, I see an invalid symlink error.
This is just some temp directory that's created every time I run. I tried deleting it to no avail.
The app runs fine on device.
Any help would be much appreciated.
That error usually happens when your app contains a symlink that points outside the app bundle. When building for device or the Simulator, Xcode creates the app bundle, then copies it out for MobileInstallation to do the install or update. MobileInstallation will not install an app that has symlinks to locations outside the app bundle.
Do you have any simulator-specific build scripts or steps? Does your bundle contain any symlinks? Open the Products group in Xcode. Right-click on "<name>.app" and select "Show in Finder". Right-click the app and select "Show Package Contents". Examine the app for the presence of any symlinks. You can also open that directory in Terminal and use ls -al. Any links will have an l character in the first position.
The other possibility is you have a file permission problem or other filesystem corruption. Run Disk Utility to check for errors. Assuming everything is OK, you can reset your Simulators with xcrun simctl erase all.
I had same problem. cleaning the project build directory fixed the issue for me.
I had same problem once, then i deleted the simulator from opened window after followed way "Set the active scheme -> Add additional simulator".After that i added a new simulator. I'm not sure about the solution for you.
Second way to solve the problem (in my opinion), check the simulator path "Finder -> Library -> Developer -> CoreSimulator -> Devices" like this. After that, find your project simulator then delete it :) and run the project on the same simulator again.
I hope it works for you. Good luck.

If I moved my Xcode project folder to another computer running OS X, Can the app still be built and run there?

I have an Xcode project that needs to be copied to another Mac. Because I don't have another Mac, I can't try it to see what happens.
If the user opens the .xcodeproj file and build it. Will the build succeed? And if he/she opens the project and click on the run button on the top-left corner, will the app run on a simulator?
I am asking this because in project settings, I set the Team to myself, I'm afraid that the app won't run because of this. Because I think when you run the app, it finds the certificates from the keychain. If a valid certificate is found, the app will run. But in someone else's Mac, the keychain does not contain the required certificate. So I think the app might not run successfully.
Will the project run on other Macs if they don't have the certificates? Do I need to do additional things to make this work?
Yes, As long as you aren't trying to run it on a physical device and only the simulator it will work.
If you are trying to install and run it on a physical device you will need to be able to link your username/certificate type thing in the build settings in Xcode

How to edit a Phonegap/Cordova-project in XCode?

I built a Phonegap/Cordova iOS-app using the command line. I can run it with the CLI.
After that I'm using XCode to compile and run the project that was created in 'platforms/ios' on the iOS simulator. This works too.
Now I would like to use XCode to make changes to the app. XCode does display a www-folder and config.xml but these are the top ones in the project folder , not in platforms/ios.
So if I change the files that are displayed in XCode, no changes appear when I run the project.
So, how can you edit a files of a Phonegap/Cordova project and run it with XCode ? (and still being able to use the CLI, would be nice as well).
You always need to modify the project_folder/www files. You can edit this files using Xcode, notepad++ or even with a simple notepad. Use what ever you like.
Then run the command using CLI
cordova build ios
Your project is now completely built. You can see the changes you made inside platform/ios/.../www files too. Now you can run the project using CLI or Xcode as wish. To run in CLI
cordova run ios
Or to emulate in emulator
cordova emulate ios
You are doing it right, you have to edit the root www folder.
Your problem is you have to do a cordova prepare ios to copy the changes from the root www folder to the platform/ios/www folder
You can do it from the cordova CLI or you can add a build script to you project (on build phases -> new Run Script phase) that runs the cordova prepare ios every time you run the project from xcode
The code you need on the scrip is
PATH=${PATH}:/usr/local/lib/node_modules/cordova/bin/:/usr/local/bin
cordova prepare ios
Put it the first one
If you really want to edit the patform/ios/www folder, on xcode you will see a staging folder, there you have the www folder and the changes you do there are applied to the project, but when you do a cordova prepare ios that files will be replaced by the ones on the root www folder and you will lose all your work, so don't do that

How to clean the sandbox every time I run the applications?

I am wondering if I could clean up sandbox everytime I run the application. I don't want to clean and rebuild every time since it takes long time.
Delete the app off the device/simulator. That deletes the entire sandbox environment. Deleting off the target device/sim is independent of doing a clean. Clean deletes compiled object files and the app from the Xcode build directory, which is separate from deleting it from the device/sim.
Clean and rebuild doesn't delete the application data stored on the simulator by the previous runs of the app. Clean and rebuild only cleans away and rebuilds the executable before sending it to the device.
To delete the sandbox app data, you can select "Reset contents and settings of simulator" in Simulator menu, or properly delete the app from the simulator.
If you want to clean the simulator stored data more easily, there are a few helpers:
http://simpholders.com iOS app that creates a system tray icon that allows you to wipe simulator data per app (or uninstall apps entirely)
http://swinden.com/ios-simulator-folders-alfred-workflow Alfred workflow which gives you the same kind of options as the above
http://markstruzinski.com/blog/2012/05/02/quick-wipe-of-ios-simulator-using-alfred Another Alfred workflow, simpler than the previous
i don't know if you found the solution but i'll share what I've created:
but be warned this will always wipe your iOS Simulator apps
At first you need to this bash script Gist: Clean iOS Simulator Apps
and then you need to configure a behaviour in the Xcode like I did in this screenshot. When the run finishes I've set the script to be executed.
If you need to clean a specific app you should create a clean script for each app you need to clean, it will look like this:
pkill -9 -fi simulator 2>/dev/null
_WD="$HOME/Library/Application Support/iPhone Simulator"
find "$_WD" -iname "TheApp.app" | while read l; do
f=$(dirname "$l")
rm -rf "$f"
unset f
done
unset _WD
in the find command you will change the parameter "TheApp.app" to the app you need to remove.
(Not tested).
Create a directory called 'dev' and store everything in that (as if it was your documents folder). At launch, delete it if it exists?

Resources