Xcode stops working after set "xcode-select -switch" - ios

OMG, what I've done?
Couple of days ago, I tried using macport to install something, because I'm using Xcode 4.3 and the command-line tool hadn't been installed by the time, macport wouldn't work. So I followed some guide to get command-line tool installed, then I used following command:
sudo xcode-select -switch /Applications/Xcode.app/
which I think screwed everything except macport: now, in Xcode, even a simple single-view iOS project won't be compiled, it says "UIKit/UIKit.h not found".
Does anyone know how to correct this? I don't want to re-install the gigantic Xcode again, gotta do some iOS project tonight, help!

You should be pointing it towards the Developer directory, not the Xcode application bundle. Run this:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
With recent versions of Xcode, you can go to Xcode ➙ Preferences… ➙ Locations and pick one of the options for Command Line Tools to set the location.

Related

Flutter build iOS got error: Requested but did not find extension point with identifier

I just upgraded to Xcode 13.3-beta, running a flutter project got this error:
Error output from Xcode build:
↳
2022-03-02 17:45:38.148 xcodebuild[62848:6695836] Requested but did not find extension point with identifier
Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in
com.apple.dt.IDEWatchSupportCore
2022-03-02 17:45:38.148 xcodebuild[62848:6695836] Requested but did not find extension point with identifier
Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of
plug-in com.apple.dt.IDEWatchSupportCore
** BUILD FAILED **
Now, I am confused, I am running a iOS app on simulator, why throughs out errors like watchOS?
And I totally don't know how to resolve this error.
Any one could help me?
OK, very weird but running xcrun multiple times seems to fix this. I had also updated to Xcode 13.3 recently.
xcrun -sdk iphoneos --show-sdk-path
The first time it shows the error. The second time it shows the right answer. I ran it with all three sdks, iphoneos, macosx, watchos and all showed the errors the first time. I also ran it with all five of the options for all three sdks:
xcrun -sdk iphoneos --show-sdk-path
xcrun -sdk iphoneos --show-sdk-version
xcrun -sdk iphoneos --show-sdk-build-version
xcrun -sdk iphoneos --show-sdk-platform-path
xcrun -sdk iphoneos --show-sdk-platform-version
The build error from xcodebuild went away after that, although I'm not certain which of the commands fixed it.
Fixed this by running.
xcrun -sdk macosx --show-sdk-path
This outputs your current skd path.
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk
Add this to your .zshrc file.
export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk
Source it
source ~/.zshrc
Now run
xcrun -sdk macosx --show-sdk-version
To avoid hard coding the version you can add this to your .profile:
export SDKROOT=$(xcrun -sdk macosx --show-sdk-path)
reload profile (source path to your profile) and run
xcrun -sdk macosx --show-sdk-version
to verify
Found solution:
Check for updates of Xcode in App Store (it should be updated
already, but just for confirmation)
Launch Xcode; it will ask you to install additional software. After installation finishes the errors will gone.
If it's a flutter project following step can be helpful:
Update MacOS
Update Xcode and command lines tools
Run flutter pub upgrade, flutter pub get in the project folder
Delete podfile.lock in ios folder of the project
Run cd ios, pod repo update, pod install in the project folder
This is problem from xcode when xcode select doesn't link with CommandLineTools
run below command for link it
// reset to the default command line tools path
xcode-select -r
// Link xcode-select with CommandLineTools
sudo xcode-select -s /Library/Developer/CommandLineTools
If that not working. Maybe problem from the keychain is not unlock.
You need to unlock that by
security unlock-keychain
Or with password
security unlock-keychain -p <password>
Hope this way can help you, thanks.
This issue is sadly with XCode 13.3.
This is pointed out by this answer - Stackoverflow Answer- Flutter for iOS run, build but not archive
The three solutions given were
Modify the code
Downgrade to Xcode 13.2.1
Wait for Apple to modify Xcode
For myself I use CodeMagic, and didn't have the luxury of downgrading my Archive. XCode could take months to update. So modifying the code was the only option. I was able to find this issue opened on March 15th 2022. Which eventually has this solution..
Open your Podfile and paste pod 'DKImagePickerController/PhotoGallery', :git => 'https://github.com/miguelpruivo/DKImagePickerController.git' as shown below:
`target 'Runner' do
use_frameworks!
use_modular_headers!
#Workaround for segmentation fault:11 while archiving
#Add the below line
pod 'DKImagePickerController/PhotoGallery', :git => 'https://github.com/miguelpruivo/DKImagePickerController.git'
flutter_install_all_ios_pods File.dirname(File.realpath(FILE))
end`
Yes I know your error said your errors were through WatchOS. However as I understand, this is an issue that occurs in version 13.3 of Xcode. In Xcode 13.3, if you have a code that uses UI_USER_INTERFACE_IDIOM(), you will get an "Out of Memory" error when you run Archive. Changing "UI_USER_INTERFACE_IDIOM()" to "UIDevice.current.userInterfaceIdiom" resolves the error. Commonly this issue occures with flutter pods using - DKImagePickerController/PhotoGallery.
I was able to fix this without touching anything Watch related. On top of this I made sure my flutter project had a minimum support level of 12, however that might be completely unrelated.
Ultimately downgrading is probably the solution. As well many of my links lead to other solutions if anyone is curious of the diving into it.
There is an error in file /Applications/Xcode.app/Contents/Developer/Platforms/WatchOS.platform/Developer/Library/Xcode/PrivatePlugIns/IDEWatchSupportCore.ideplugin/Contents/Resources/IDEWatchSupportCore.xcplugindata
You should make its backup, then open it in plist editor and fully remove the following items:
Root/plug-in/extensions/Xcode.DebuggerFoundation.AppExtensionHosts.watchOS
Root/plug-in/extensions/Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS
A workaround that worked for me was to install the previous stable Xcode version 13.2.1 and build it from the IDE.
You can have multiple versions installed, so you don't have to change anything in your current setup.
https://xcodereleases.com/
Check if there is some update for Xcode.
xcode-select --install
If you get the message below from the command above, try:
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
Also, you should check if there is a macOS update available.
Click on the Apple icon no top left > About this mac > Software update (for example, macOS Monterey 12.3)
I faced the same problem when updating the project with Flutter 3. After several attempts, the below solution worked for me.
I have deleted the podfile.lock file inside the ios folder and then run the below commands.
flutter pub upgrade
flutter pub get
cd ios
pod repo update > Actually, this was an error for me but ignored it
pod install
Also please make sure you are using the latest MacOS and Xcode.
I hope this will help someone else.
In my case, its React Native app, the problem was with cocoa pods.
Reinstalling pods helped. Run below in your project folder
rm -rf ios/Pods && npx pod-install
Okay, just found a solution which might sound super dumb but updating my Mac OS to Moterey 12.3 solved the issue with no change in the code required.
Got this as well when trying to run the app from Android Studio. Solved this by...
starting XCode,
open the Runner,
run the app from xcode,
stop the app in xcode,
...and then it worked fine to run the app without this error from Android Studio.
I had the same issue , and i could solve it by removing the image picker newer package manually from the package folder and set the image picker package version to image_picker: 0.8.4 , and this solved the issue , hope it can help , maybe if you can share all the error message then i can help you .
you can try install the latest xcode13.3
then you can try xcode-select --install to install the command tools
Run command sudo xcode-select -s /Applications/Xcode.app
Finally, I found solution, hope this helpul for you.
Change flutter channel from stable to master
code#kazus-MacBook-Air ios %flutter channel master
code#kazus-MacBook-Air ios %flutter channel
Flutter channels:
* master
beta
stable
Also experiencing the same issue, I tried #user1503606 and #MCCCS suggestion, sadly didn't work.
Looking at this answer, the issue stems from XCode 13.3 and as #y2ducky suggests, downgrading should solve the issue.
Solutions:
Downgrade to Xcode 13.2.1 (you can find older versions here https://developer.apple.com/download/all/ then expand it and move Xcode (Xcode.app) to Applications folder, which will replace your current Xcode 13.)
Wait for Apple to modify Xcode
Using xcode version "13.2.1" works for me. Seems like "13.3" is doing something differently
Here is another one that helped me to solve this issue. Go to About this mac -> storage and remove support watchOS in Xcode developer settings.
Works with xcode 13.3.1, Monterey intel:
downgrade flutter sdk to Flutter ->2.10.0 Dart ->2.16.0
which can be downloaded here:
https://docs.flutter.dev/development/tools/sdk/releases?tab=macos
change your valid sdk path in terminal with flutter --version
this includes for new projects.
running May 1, 2022
Restart of iPhone solved the problem for me.
I brought another solution.
I tried multiple solutions which mentioned in this question, but all failed.
So, I just tried from flutter starting project. It did build perfectly. After adding some libraries, the library starts to require more higher ios version.
I usually upgrade ios version by Podfile like this,
# Uncomment this line to define a global platform for your project
platform :ios, '12.0'
but, instead of that, I upgraded ios version with Runner.xcworkspace and ios/Flutter/AppframeworkInfo.plist according to this link.
https://docs.flutter.dev/deployment/ios#review-xcode-project-settings
and after that, I finally succeeded to build project.
This also could be a problem with your pubspec.lock file. Some version of libraries probably trying to use Watch Support. That was the my case. So, I fixed some libraries's versions and then it worked fine.
This solution worked for me
Try xcode-select --install
If command line developer tools were already installed try fixing it by
sudo xcode-select -r
After a couple of days of trying all the solutions on the internet. I finally ended up deleting the ios folder inside the project and creating it again using flutter .
then Open Terminal and go to the project and do the follwing.
pub get
cd ios
pod install
And you can run the app now.
It could be this:
Try turning off your Apple Watch. I know... I know. I ignored it for a long time, then dug into the logs, the error messages, researched, etc.
The device name format changes when building when there's a watch involved and can sometimes hang up the Flutter tools because - well, because they're garbage and don't take that into consideration.
I basically just can't use my Apple Watch when I'm building on Flutter (some times), like at all. I have to power it down completely.
After you get a successful build, you may or not be able to turn it back on and have the builds succeed. It's hit and miss.
I get this problem every few weeks, and 100% of the time, it's my Apple Watch being on, changing the build targets that Flutter reads, presumably through Xcode.
** shrug **
In my case it was as simple as a new location added to assets within pubspec.yaml
assets:
- assets/images/
- assets/images/icons # this line broke the whole project because of a missing /
What helped in my case was to run update Xcode CLI to the newest (version: 13.4.0.0.1.1651278267
) which was only displayed with --all --install --force:
softwareupdate --all --install --force

Flutter Doctor : Xcode installation is incomplete

I have an app created with Flutter want to build it in IOS.
When i want to run simulator or build the I get error ,When I run Flutter doctor I get this error L
Xcode - develop for iOS and macOS
✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
I was facing the same issue. I did not installed Xcode from Apple Store. If your scenario is same, you can try below steps,
Open Xcode
Go to Preferences -> Location tab
You will find "Command Line Tools" option. If it is blank, select the Xcode version from list (see image below). It will ask for password or Touchid to update it.
Run flutter doctor again. It should resolve the issue
You probably miss the xcode command line tools, you may want to reinstall XCode, or select the xcode command line tools with the command xcode-select
Here's a full fix that should solve your problem: https://github.com/flutter/flutter/issues/6308#issuecomment-257812324
So, I was facing this same issue, and tried to and copy paste the command already given. Namely
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
But why did it not work? Silly mistake of mine: I have two Xcode versions in my Applications folder. One is called Xcode_12_3_0 and the other Xcode_12_5_1. Make sure that, when you run the command, you also make sure you enter your app's real name. For instance:
sudo xcode-select -s /Applications/Xcode_12_5_1.app/Contents/Developer
An answer for us, absent-minded people.
If you already have Xcode and this happens. Just run this command
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
And
sudo xcodebuild -runFirstLaunch
It will automatically show

Xcode 8 Command Line Tools Missing (Git, Clang, etc)

Two days ago, I upgraded to OSX Sierra. My development tools seemed to be working fine after that.
However, today I upgraded Xcode 7.3.1 -> 8.1 to make certain features work for React-Native development. To be precise, I deleted the 7.3.1 and installed 8.1 anew. That is where the woes had started.
In particular, it seems that most of the Command Line Tools are gone. I get errors when trying to use git as well as other commands. I was able to get Git back after installing from .dmg file.
I have also tried installing Command Line Tools using xcode-select --install to no avail. Installation proceeds, but none of the tools become available afterwards.
As an example of what is happening, the following are the errors I receive when running: curl -sSL https://get.rvm.io | bash -s stable --ruby
xcodebuild: error: SDK "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk" cannot be located.
gcc: error: unable to find utility "gcc", not a developer tool or in PATH
configure: error: clang version 3.0 or later is required
Does someone know what the issue might be and how one goes about getting the development environment set up on Sierra + Xcode 8.1?
This error occurred after installing the new version of Xcode.
Just restarting helped for me. Sometimes, even quitting and restarting Terminal might also help.
The problem is that you need to repoint the command line tools to the new copy of Xcode. You can use xcode-select to do that, but the easiest way is, in Xcode, go to Preferences > Locations and choose the correct Xcode for the Command Line Tools pop-up menu at the bottom.
Also pls note that in order to use xcode-select you need to use sudo.

Xcode command line tools (two versions side by side)

Recently we've moved to Xcode 8 in order to compile the app with new Xcode version, but I still need to use Old Xcode (7.3.1) in order to use it's instruments with older ver of appium ...
I was wondering if there is a way to open each Xcode ver and to use it's relevant command line tools? currently , the command line tools I set in specific version is being used among two Xcode versions ...
Thanks!
I am using X-code 7.3.3. to run appium test and Xcode-8 to build app under test. I have moved xocde8 into folder name "xcode8".
And to switch between different Xcode version you can use -
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer/
sudo xcode-select -s /Applications/xcode8/Xcode-8.app/Contents/Developer/
If you have a particular version of Xcode (say Xcode 8) installed in your system, go to /Applications and rename it to something else like Xcode8 or Xcode7.3.1. Install the other version normally. Now you have both versions running in different names.
I hope this is what you were looking for..

Xcode 5.0 quit unexpetedly while using the automator plug-in

i open my project on xcode 5 but everytime it crashes, i am to much worried about that behaviour of xcode. it give me error "Xcode 5.0 quit unexpetedly while using the automator plug-in" kindly help me to find solution of this error. i did completely remove xcode and after that install again but it give same error when i open my project.
I uninstalled Xcode completely and then reinstalled it. To uninstall developer tools/Xcode type in the following command in the terminal.
sudo /Developer/Library/uninstall-devtools –mode=all
You can try some hints:
1)Download from App store after uninstall
2)upgrade Mac OSx
3)install the simulators path >Xcode menu>preferences>downloads>components
i resolved it by myself, just reinstall mavericks again it solve my problem at last.

Resources