Why do I need to clean the xcode project everytime I build the project? - ios

I have an iOS app written in Swift. Whenever I run the project, it gives Shell Script Invocation Errors:
When I clean the project, the subsequent build performs ok. But again, if I build the project next time, it again gives the same error.
Cleaning and rebuilding the project takes a lot of time. Is there some way around it?

It's difficult to know exactly what is causing this issue as it could be a number of things, So the question is quite broad.
Few things to try...
Check your build phases in the project and look for anything that might not be expected
Try checking out your project (if using version control) in another location such as your Documents folder to make sure there isn't a permissions issue.
Try cleaning the build folder using alt, cmd, shift + k.
If your still having issues after that try providing additonal information.
What version of xcode are you using?
Are you using any xcode plugins?
Are you using any package management solutions? carthage? pods?
Have you tried to build your project on another computer?
Are you using the latest version of the command line tools?

Related

Firebase Unity xCode linking errors

I am having issues trying to make a build from Unity (version 5.5.2f1) with Firebase Auth / Database imported. I am using the newest Firebase SDK of 3.0.0.
The errors I get are as follows:
I believe it has something to do with cocoaPods. The XCode project compiles with a podfile. And the errors I believe are related to missing libraries? But all the required libraries are set to iOS, and are included with the XCode project.
Unsure of what to try next. Thanks in advance to anyone able to help.
When you build and run from within unity, it tries to run the pod installation for the dependencies needed, and patches the xcode project file (not workspace).
If there is an error with this process, you should see it in the console.
Normally pods are meant to be used with the workspace file, but since unity automatically opens the xcode project the plugin tries to make it work.
Try opening the .xcodeproj instead of the workspace.
So I finally figured out my issue. I had a previous build that worked all the way through to my device. So I eventually tried opening that one again, and I ran into the same errors with an older build.
So that got me thinking.. Why would a previous build that used to work fail this time around?
I came to the conclusion that the only things that changed were possibly me updated Unity to 5.5.2f1. So I updated again to the latest release at this time which is 5.5.2p3, and ran through the same steps:
1) Build to iOS
2) Install pods in the target folder
3) Run xc workspace
And it successfully built. So it must of been something on Unity's side. If anyone ever runs into a similar situation, hopefully this will help.
P.S. I also did update to the latest release (at this time) of Unity Firebase SDK of 3.0.1. Not sure if that had anything to do with making a successful build, but wanted to put that information out there.

Build operation failed without specifying any errors for React Native Xcode project

I have a React Native project that works fine most of the time(Android and iOS). But sometimes out of nowhere I receive this error when I am trying to build the Xcode project (Xcode or react-native run-ios):
Build operation failed without specifying any errors.
Individual build tasks may have failed for unknown reasons.
One possible cause is if there are too many (possibly zombie)
processes; in this case, rebooting may fix the problem.
Some individual build task failures (up to 12) may be listed below.
How do I solve this? Push to a branch on git, fresh clone, npm install, and all is working fine for a period. And after that the problem will repeat. Making fresh clones of project each time is a pain and takes long time. Is there another way or something that I don't know?
Maybe a some files that are in .gitignore is causing the problems, and after a fresh clone that solves the problem. This is the .gitignore file for my iOS project:
# Created by .ignore support plugin (hsz.mobi)
# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace
I had this same issue and it was fixed by deleting the contents of node_modules and doing a npm install in the parent folder.
I was faced with this problem too. And I noticed that my folder name was too long. I changed the project folder's name with the short one and this error gone. Try to change the project folder name.
It was really a time killer issue. I rebased the complete code base to a collegue's mac where it worked fine. After sparing more than a couple of morning hours I could find a solution.
Solution - Simply shorten your Project folder name (in mac).
This is undoubtedly irritating that its suggested to have longer and meaningful variable names but the folder name has to be this concise.
I had a issue with XCode 9.1 and iOS 11...
I solved this issue moving up my folder to another path, I know it doesn't make sense and is dumb but it really work for me. My project was at /Users/Me/Documents/MyProjectDir and I changed to /Users/Me/Desktop/MyProjectDir
What helped me was removing the ios/build folder in my React Native project, followed by rebuilding the project.
I highly recommend to run the build on console, to see if it outputs any other relevant information.
react-native run-ios --scheme "app-debug" # Or any aproppriate target
Read more about building+archiving from CLI here or try with other OSS tooling like fastlane.
For me it found bugs twice, that both were unrelated with the building process itself:
1) One was fixed rolling back to node v8 (LTS) apparently. It was very obscure, but I suspect had to do with having little memory available (running flow + packager + xcode + spotify + chrome on 8GB RAM MBP)
2) The other one was related to having a space on the xcode output. "App Canary.app" could not be installed. I figured it out doing ls ios/build/Build/products.... This error only happened after upgrading xcode, and wasn't happening with the release target, that did not have any whitespaces.
The only take away here is to run build directly on the console to debug further. You might find out things that are completely unrelated, and probably can't be solved by just removing the build folder.
Hope it helps.
Trashing ios/Build resolved this issue for me
In my case simulator is not shutdown correctly.
So I opened simulator manually again then I got an error that simulator is not shutdown correctly.So I relaunched the simulator successfully and built xcode project again. Error is resolved

how add manually a cordova plugin to ios existing project

i've a cordova project created via cordova cli command.
i build the project for Android and iOS platform but... i copied the build project into respective workspace (eclipse/xcode) and i updated that single project.
Now i need to add a plugin.
The project into cordova project folder is now so outdate so i would add the plugin via cli and copy the plugin to the respective project.
I copied successfully the generated plugin into the android project, but i'm not able to do the same thing with iOS.
For example i added the console plugin for iOS
cordova plugin add org.apache.cordova.console
if i open and run the build project it work and i see my message in console, but if i try to copy the generated plugin into my existing project it doesn't work.
nobody could help me to understand how add manually a plugin into my existing project?
update
yes i know, i'll try to explain better
i have my cordova project under folder /Document/cordova
when i made an ios build via command line cordova put the built project under /Document/cordova/platforms/ios
well i copied the folder ios under /workspace/my-project-name
after some work under workspace i see that i need to add a cordova plugin.
i added the plugin via command line and it was added to /Document/cordova/platforms/ios
at this poin i have a project under /Document with plugin but asset outdated and one project updated without plugin under /workspace
i'm trying to copy from built project to /workspace project.
i copied
/workspace/my-project-name/my-project-name/Plugins
/workspace/my-project-name/my-project-name/config.xml
/workspace/my-project-name/www/plugins
/workspace/my-project-name/www/cordova.js
/workspace/my-project-name/www/cordova_plugins.js
but it doesn't work... i missed somethings?
After reading it several times I think I get more less the idea...
Well, I am not sure why do you want to copy the ios project outside the current location. I suppose you have a good reason to do it, however you can always tweak that project instead of going back and forward, cordova will not impact non cordova related files each time you run "cordova build".
Are you familiar with control versioning? Git, SVN, mercurial? If so it is simple just we which files were impacted once you add the plugin and copy those... If no, I suggest using control versioning anyways to help keep track of your code changes.
NOTE: Be aware if you build the cordova projet and then you just want to update the files noted above it is highly likely that it won't work, that is why you run "build" is not a simple file sync. I recommend taking the new cordova project with the plugin added and then just add you personal tweaks on the ios in the other folder. Or just tweak the ios folder inside platforms folder...
I hope you are doing for good reason. Anyway you are missing to copy below file to work
/workspace/my-project-name/my-project-name/platforms/ios/my-project-name/config.xml
Copying the cordova iOS platform folder is not a good idea. The reason is, cordova builds an Xcode project in the platform folder, and there is some sort of caching/built in references to absolute location of the original Xcode project. Therefore it would be unclear to you and to Xcode which file is being referenced from within Xcode. This may have caused some other unnoticed errors in the project as well. So therefore, instead of keeping original project path available along with the new path, I would recommend renaming the original project folder in order to remove the ambiguity. This way, you will assure that the right file versions are referenced.

xcodebuild failure clang:error no such file or directory:

Having a problem when building with xcodebuild. My project/app builds fine with the Xcode - gui. It simply isn't finding/building the libcryptopp library which is part of the build process.
The error is:
clang: error: no such file or directory: '/Users/builder/repo/ioskpay/xcode-cryptopp/cryptopp/build/Release-iphoneos/libcryptopp.a'
This particular file should be derived from another project inside the main app - xcodebuild simply isn't correctly pointing at the right file folder which should be:
~/Library/Developer/Xcode/DerivedData
Any ideas?
To fix this, go to your project settings, go to Targets and select your main project target. Then go to Build phases. Under Target dependencies add the static library project.
This way, when you compile the main project, the static library subproject gets compiled before the main project and your static library will be available.
I had the same problem, but for a resource file .m
I opened target -> build phases -> Compile sources
and I found the file the compiler was tell it can't find duplicated: one with strange icon and the other with a normal icon. I simply removed the one with strange icon and it worked. ( I added the file multiple times and I had a merge conflict before that which made something wrong in the project file)
For your case I think you need to remove the lib from target dependencies list and add it again. This may work for you.
In Xcode Version 9.2 (9C40b) this happened when I drug a bunch of files into the project, some of which were duplicate. Rather than simply not adding the duplicates, it added them again and only the name, not the path.
In Target > Build Phases > Compile Sources each of the duplicates showed with no "...in" after them. Each one caused the clang error.
After removing all of the duplicates that Xcode collected, the project compiled and ran.
It makes you use the Project Navigator instead of managing your source files in the Finder. Then the Project Navigator can't replace duplicates like any decent file management system (ahem Finder). 🤨
My xCode info is:
I faced similar errors during xcode building projects (native swift, flutter, react native, native script) in which I got error messages related to clang compilar. Errors like:
clang-4.0: error: no such file or directory: '/Users/xxxxxxxx/Library/Developer/Xcode/DerivedData/xxxxxxxxxxxxxxx/Index/Data Store'
clang-4.0: error: cannot specify -o when generating multiple output files
others
Despite of errors related with DerivedData for native apps can be fixed by deleting the directory and, eventually, restart xCode and even restart the machine... in this case, you will see that after deleting the directory and start building process again, the error comes back.
Then, is the moment of checking the clang installation by running clang --version. The normal output will be something like:
as you can see the InstalledDir is incorrect for xCode. In my case, some days ago I needed to install Anaconda app (R, Python, etc) and, now, I remember that I had to install some dependencies and one of them was clang and its installation was altered.
To fix this problem (in my case that I will not need anaconda any more): (edited)
1.- Delete anaconda and all its dependencies (I recommend to use App Cleaner).
2.- Re-install xCode
After reinstalling xCode, if you type again clang --version, you'll get this:
More info at: https://github.com/flutter/flutter/issues/32457#issuecomment-496161092
Hopefully, this info helps some else.
Best
Ok so by simply adding the correct -target -configuration and -scheme parameters I got this to run correctly. However due to my running this in Jenkins for autobuild purposes it still doesn't work as I'd like - getting stuck in exactly the same place. It's odd because I have the exact same code being built in another job that isn't having this problem. There is no rhyme or reason for it at this point. I will keep shooting rubber bands at it and update when I have an answer...
Sometimes Xcode performs weird.
You have to find that static library project e.g.. "filename.a" under 'Link Binary With Libraries' in Build Phase and then remove it and add it again.
I had the same problem while I was archiving my target. I removed the library and the build succeeded.
For me it was because I had removed a package or pod. I ran pod install and it fixed it
Look for the missing file in the Xcode project i.e the files may be deleted or miss placed.
add the missing files to the xcode, then everything will work fine.
Run this command :
$ conda deactivate

Three20 Issues with Build and Archive on XCode 4

I have ported an existing Three20 xcode 3.2 project to xcode 4 using the tutorial
The code compiles and runs on the device. Now, I am trying to build an ipa (using the archive command) and am running into similar errors as this stackoverflow post
The error is:
cd: /Users/[username]/Library/Developer/Xcode/DerivedData/Pulse_News-cnosepsavjismxbmhuvmmvxnnpgh/ArchiveIntermediates/Pulse News/BuildProductsPath/Release-iphoneos/../three20/Three20Core: No such file or directory
Unfortunately, neither the tutorial nor the post have helped much. Is there something I am missing? Is funny that I am able to build the project and run it fine, but not able to build an archive! Please help.
My guess is the "No such file or directory" error message is correct. Considering this, the answer to your question depends on your providing more information about how you have project dependencies and search paths configured in your project.
For self-help, take a careful look at the path it's saying doesn't exist and see if you can figure out why. Note projects within the same workspace share build paths; if you're not using a workspace, you'll need to verify the search paths point to the build location of the other (three20) project.
This is probably the first of your problems. When you upgrade a three20 xcode 3.2 project to 4, you will probably also get an invalid binary message when you upload to itunes.
The only solution that worked for me was to create a new project, re-add all the source files and run the three20 python script with something like:
python /Users/yourpath/three20/src/scripts/ttmodule.py -p /Users/yourpath/YourProject.xcodeproj Three20 extThree20JSON:extThree20JSON+SBJSON --xcode-version=4 -c Debug -c Release
It's a pain to have to do this but it will probably save you more pain down the line

Resources