Adding Files and Select Multiple Targets in Xcode - xcode

I have over 200 projects in my XCode and when I add a new file or class I have to select each target one by one to add it to it. Is there a way to select multiple targets instead?

Try the awesome AllTargets Xcode plug-in by poboke available on Github (works with Xcode 5+).
Manual build and install
Download source code and open AllTargets.xcodeproj with Xcode.
Select "Edit Scheme" and set "Build Configuration" as "Release"
Build it. It automatically installs the plugin into the correct directory.
Restart Xcode. (Make sure that the Xcode process is terminated entirely)
Manual uninstall
Delete the following directory:
$HOME/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins/AllTargets.xcplugin
↳ Tutorial on how the plugin was created (Chinese).

Related

How do I archive Xcode project?

I am currently having issues when attempting to archive my project in Xcode. The following error below appears when archiving:
The link Xcode 12 Error: Multiple commands produce AccessibilityResources.bundle mentions to remove React-Core.common-AccessibilityResources from my target but I do not have this under my target. Can someone please assist?
I am using Xcode version 12.1.
This is what I have in the workspace settings:
Thank you.
I changed the derived data location but still getting the same error:
I am now seeing the below error after updating my Podfile.
Current error:
Updated Podfile:
Have a try with the below solution.
Initially clean the build cache data with the below steps:
You can go to File > Workspace Settings if you are in a workspace environment or File > Project Settings for a regular project environment.
Then click over the little grey arrow under the Derived data section and select your project folder and close the workspace and Xcode then delete the project directory from the derived data directory.
Open the workspace again in Xcode and clean and rebuild the project.
Also, make sure that you have applied pod install after the package installation.
Then, open workspace and set the active scheme as Any ios Device (arm64, armv7)
Click on Project from top Xcode Menu
Then select Archive.
Have a break till the Archive process completes.
Remove the below lines from PodFile:
use_flipper!()
post_install do |installer|
flipper_post_install(installer)
end
and do pod install in ios directory.

xcodebuild clean deletes non-target files in BUILD_DIR - new in Xcode 12.5

I have our Xcode build system setup to place all build products in a pair of directories, one for Debug configuration and the other for Release using the build setting
BUILD_DIR = /Library/DevWork/BuildProducts
specified in a shared .xconfig file.
This worked fine up through Xcode 12.4 as the xcodebuild clean command would delete only the target and leave all the other files in the build products directory intact.
New with Xcode 12.5, xcodebuild clean deletes the entire contents of the build products directory. Is there a way to disable this behavior?
New with Xcode 12.5, xcodebuild clean deletes the entire contents of the build products directory. Is there a way to disable this behavior?
The behavior isn't actually new with Xcode 12.5; it's been part of the "new build system" since it was introduced in Xcode 10:
The new build system uses the “clean build folder” behavior. The legacy “clean” behavior is not supported.
The "legacy" build system has been deprecated for a while. I don't know if it's still available at all in Xcode 12.5, but whether it is or not, it's time to make the move to the new system.
Is there a way to disable this behavior?
No.
If you really need to keep old build artifacts around, you could add a post-build script that copies them to another location.

Xcode 7.2 successful archives will not show in organizer, but will show in archives folder about derived data folder

I am using Cocoapods 0.39.0 and Xcode 7.2, I have a project that archives successfully but does not populate in organizer. When I tested my podfile in a blank project the archive showed up in the Organizer just fine.
While trying to troubleshoot this I found that there was an Archives folder above Derived Data. There I actually found all the .xcarchive files of the project that won't show up in the Organizer.
When clicking on the file details, I also noticed that the working Archive had a size (228.3 MB for the test project) but my main project I want working has a size of 0 bytes.
Figured it out.
Searched Installation Directory in Build Settings
Removed #executable_path/../Frameworks as the value for Installation Directory
Typed the following for the Installation Directory $(LOCAL_APPS_DIR)
Reference: "Xcode successfully archived my application, but the Archives Organizer does not list my archive" section https://developer.apple.com/library/ios/technotes/tn2215/_index.html
In XCode Project\Targets\Build Settings make sure
Skip Install = NO
for your Archive scheme, if you created one, or Release scheme
In my case (Xcode 8.3.3), the Installation Directory was pointing to /Applications which seemed correct, so that wasn't the issue. What worked was:
1. restart Xcode
2. Product ➞ Clean
3. delete the whole 'Derived Data' folder (to see where it is: Xcode ➞ Preferences... ➞ Locations ➞ Derived Data)
4. Product ➞ Clean
I had the same problem when I created debug build pointing to our QA environment.
Debug build was just Zero byte.
As #kareem mention above I figure that release/distributio build are having path as /Applications.
I just duplicated for my debug build and bingo !!!
Yes you can add /Application instead of current value which was '#executable_path/../Frameworks'
This way if you archive your debug build, you will have actual archive just like release build
All credit goes to kareem. I just try to enhanced by adding another prespective.
Easiest step that worked for me.
Delete folder Derived Data (to see where it is: Xcode ➞ Preferences... ➞ Locations ➞ Derived Data)
Generate the archive, select the Xcode ➞ Product ➞ Archive
Once the process is complete the archive will be displayed in the Archive screen of the Organizer dialog.
I was also facing the same issue in Xcode 12.4 then I tried with the method #kareem said.
But after that as well was not resolved.
One of the pod framework in my project is enabled for the App Extension as well. So I removed it from pod and installed using Swift Package Manager.
This resolved my issue.
Afterward I tried another way:
Also I modified the podfile like below and reintal and it worked:
target 'ProjectName'
do
use_frameworks!
. . .
target 'ProjectNameBroadcast'
do
inherit! :search_paths
end
target 'ProjectNameBroadcastSetupUI'
do
inherit! :search_paths
end
end
1. Clean
2. Build
Worked for me.

Xcode: ld: library not found for -lAFNetworking

Because of this one reason, build always fails...Any ideas about what I could try?
EDIT: the solution is to open the xcworkspace instead of the xcproject!
Might be you are opening .xcodeproj file after installing pods. Close the project and open .xcworkspace file.
Have the same issue.
What I did with the help of https://premium.wpmudev.org/forums/topic/anybody-solved-this-linker-command-failed-with-exit-code-1 and Adlair Cerecedo-Mendez
Delete the "Pods" project on the left panel of Xcode.
Close Xcode and delete this file in the finder too.
Install pods again.
Open Xcode and clean.
Verify that the build option "Build Active Architecture Only" is set to "NO" for your project but also for your Pods project (selection with left panel).
Click on your project Scheme (top, near the stop button) and "Manage Scheme".
Check, select all your pods libraries and close.
Then, for all libs, select them (scroll the list) and build manually for the selected architecture.
Every time you change your architecture (simulator, device or for archive(Generic iOS Device)) you must do the above step: namely, manually build each libraries by selecting them in your scroll list one by one, and only than build and run your main project.
Seems a bit WTF, but it is the only way I resolve this issue...
I Had this Issue several Times with PODS Libraries.
Here is something you can Try:
Run pod cache clean --all and pod install again.
Check your Header Search Paths and Library Search Paths, Remove all entries and place $(PROJECT_DIR) in recursive mode and $(inherited) as a Second Entry
Go to your target Build Settings -> Other linker flags -> double click . Add $(inherited) to a new line.
Make sure Build Active Architecture Only is set to NO in the Pods project settings.
I'm thinking on two possibilities:
1) Install cocoapods-deintegrate project:
$ gem install cocoapods-deintegrate
Then run $ pod deintegrate, after that run $ pod install again. If it not works, then...
2) You can try open your Pods project and create new scheme for the target that you need, in this case for AFNetworking.
When the static library is created, then add it to your Frameworks references into your main project.
Hope that helps.
I have in project->TARGETS->Build Phases ->Link Binary With Libraries one "extra" framework that remains from recent project. Delate it and all run smoothly
Had a similar issue ... took a while to realize that I had updated my app's "iOS Deployment Target" to iOS 9.0, but the Pods project's "iOS Deployment Target" was still iOS 8.0!!!
I encountered this error when I downloaded some code from github. I tried to build .xcodeproj file but it failed giving the library not found error. I then opened .xcworkspace file and build that file first by clicking Product -> Build for -> Running. The workspace file built fine with no errors. Then in workspace file I changed scheme to the xcode project I was trying to build, and clicked Product -> Run. The app got built and ran with no errors.
I had this issue while using fastlane with a ReactNative project. I had added a dependency that required cocoapods.
My Fastfile looked like this:
...
gym(
scheme: "AppName",
project: "./ios/AppName.xcodeproj"
)
....
And had to change it to the workspace like this:
...
gym(
scheme: "AppName",
workspace: "./ios/AppName.xcworkspace"
)
...
For me all this thing not help. Only delete in Build settings project.
open xcode, from the top left select the pod library that is being shown as not found.Use 'Command B' to build this pod, then again select your target scheme and run.
For me this fixed it.
Use the xcworkspace to build instead of the xcproject?
This usually happens when using Cocoapods and you are building from the xcproject which doesn't know about the cocoapod libraries.

Xcode Won't Compile To Simulator

I've just updated Xcode 4.5 via the App Store, from my previous version which I got from my Apple Developer Account. Since the update I can't compile any apps into the Simulator. I can compile onto a device, e.g. my iPhone.
The error I recieve is
fatal error: file
'/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/
Developer/SDKs/iPhoneSimulator6.0.sdk/usr/include/Availability.h'
has been modified since the precompiled header was built
1 error generated.
go in ~/Library/Developer/Xcode/DerivedData/{project name + gobly-gook} and delete folder with your project name.
EDIT After suggestion
NOTE:
By default Library Folder is hidden so we can't see it.
So we have three way to use this hidden ~/Library folder
1.Unhide Library folder by following command to unhide ~/Library folder
chflags nohidden ~/Library
Now you can see Library folder as /Users//Library
2. Open GO menu of finder and press Alt key and Library will be visible as new menu item.
Select that to open Library folder
3. You can access ~/Library folder by Terminal.
There's easiest way: Just "clean" project (Product > Clean)
You can just open the Organizer (top-right corner of XCode), go to the Projects tab, select your project on the left and then delete the Derived Data.
This happened when I updated Xcode from 6.0.1 to 6.1
I cleaned the project and could compile successfully!!

Resources