Migrating to Cocoa Pods from Submodules (Xcode iOS) - ios

I'm migrating from submodules to Cocoa Pods. After moving over I have a strange error when I build.
error: unable to open
'/Users/myname/Library/Developer/Xcode/DerivedData/myapp-gzbqnssczmguxecctczxyqqjktqs/Build/Products/Release-iphoneos/myapp.app.dSYM':
No such file or directory
I've Product > Build Clean but get it when running. I don't entirely get derived data, but my understanding is that once I've pod install and run the workspace (as opposed to the project) this should run properly and this missing dSYM should be accessible?
I have actually two build failures, the second being around a different pod, but I'll assume an answer on the more basic question might lead me to an answer on the second.

Well, I would suggest you simply clean the complete derived data. You can do this by going to Window-> Projects and then simply pressing the delete button beside of derived data.
Once you delete that the project should build newly, also creating a new .dysm
Now just build and run and you should be good to go.
Hope that helps, Julian.

Related

Xcode 9 - linker command failed with exit code 1

While compiling the application getting as following error
" compiled with older version of Swift language (3.0) than previous files (4.0) file "
Could you please help me?
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.
Delete the derived data and do a clean build.
And if you are building a framework, make sure you've selected Generic IOS Device while building or set the Build for Active Architecture only as true in Build Settings.
I think this happens because you changed your app name or maybe the target
look to solve this problem see your target in Podfile
and then come back to your xcode in the targets
select your target app and in linked Frameworks and Libraries (the last one down) see if there's
any pods with light color and a strange name than your target in the podfile
and remove it using the minus button down .
I'd rather fix the specific problem, but if none of the other answers worked a full reset can solve it. If you are getting this error and you are also getting error readouts that refer to "duplicate symbol files", AND all other efforts have failed, then a full reset could work for you.
What worked for me:
Read the error report to identify the repo that supposedly contains duplicate files.
Drag repo to the trash.
re-clone your repo.
set up your repo with correct remote tracking. git remote add <url.git>, or git remote set-url <url.git>
This absolutely worked for me. In my case for some elusive reason, when I ran git pull upstream develop for a local dependency, git would pull in/generate duplicate files from multiple commits.
After following the above steps, the issue went away and git pull upstream develop was no longer pulling from multiple commits at once. Perhaps there was a weird git cache for my repo.
I had the two copies of files in the codebase. Deleting one copy helped code to build successfully
I am probably late for you, but for future devs in problems...
If you have been manipulating the podfile or creating new targets or maybe changing the name of any of them, check that in build phases options your just have correct pod framework for the name of the targets.
if you have pod
first clean project and close Xcode then open terminal and go to folder of Project then pod update
open the project and run
in my case work!
I fixed this problem today by running the app in the simulator using the target associated with the bundle file named in the Build Settings-->Bundle Loader setting of the test target. Previously I had deleted my derived data folder while working on a different target that has a different Product Name than the one associated with the test target bundle file. Rerunning the app in the simulator must have recreated the bundle file in the derived data folder that the test target is looking for and then my tests started running fine.

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

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?

Does 'pod setup' need to be run every time a CocoaPod is added to a project?

Original issue: xcodeproj components didn't display in workspace
I've installed Cocoapods on my machine. When I install a pod in a project, a workspace is created, but when I open the workspace the files associated with the original project don't display. I had Xcode closed when I created the pod. I've attached a screen cap of my project after installing the Pods.
I think I've got an installation problem, but I don't know where I need to look to fix it. What/where should I be checking?!
Update: Compiler error
The following compiler error comes up when I open the workspace file:
podsexample.xcodeproj Couldn't load podsexample.xcodeproj because it is already opened from another project or workspace
I closed Xcode when I created the pod, so I'm stumped on this one.
Update 2: It works, but is this the way it's supposed to work? I got partway to the answer to my problem by following the steps outlined in this helpful post:
Can't get to work CocoaPods and Yosemite
In order to open the workspace file correctly, I have to run 'pod setup' each time. Are CocoaPods supposed to work like this, or is setup supposed to be a one time thing? If I've got an installation/configuration problem, where/what should I be looking at to fix?
Screen Cap of Original Issue
podsexample.xcodeproj Couldn't load podsexample.xcodeproj because it is already opened from another project or workspace
Looks like you had two copies of Xcode open with the same project. One was inside the Xcodeworkspace that CocoaPods created, and the other was the original Xcodeproject itself. Xcode doesn't allow this, so it won't compile as long as both are open. You only need to open the XCWorkspace.

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

How to force XCode 4 to always update resources?

I am adding resources (lots of .pngs and other) to my iPhone project dragging the folder to it and choosing "Create Folder references for any added Folder", to retain the folder structure.
They are correctly added to the Copy Resources build phase.
Problem is, I am wasting A LOT of time because when I create/delete/update a new resource, it will often ignore changed files and stick with the older version.
Looks like it tries to only updates resources when they are changed, but it fails to see the changes.
In the simulator it was possible to manually update the files in the .app, but when working on the device it will complain that the code sign of some resources has changed!
The only reliable way I've found to force it to update everything is deleting the build products, the app and the device app some times, until it finally decides to forget about the old version, but doing this for each resource change is wasting me an insane amount of time (game content changes more than often).
So, in short: how do I force XCode to disable "versioning" and to just scrap all the resources and copy them all each time?
Thanks!
EDIT: I have found that deleting the .app folder built in "build" folder always forces XCode to add new files...
I still have no clue on where it keeps the old files when I delete that folder, but this is for the better as it only copies new resources as intended.
So a simple script like
rm -rf "$CODESIGNING_FOLDER_PATH"
Does the trick of deleting the folder at each build...
Unfortunately, XCode apparently runs the codesigning BEFORE anything in the Build Phases tab is executed, so it updates the old target, the script deletes the old target, and then it crashes complaining that no Code Signing Resources were found.
So... I have to stick with manually deleting the file, or is there a way to run a script before code signing?
I had this kind of issue as well, about files not getting updated when I built my project (A PhoneGap project, but that should not matter).
What I did, was add this to the Build Phase of my project:
find "${PROJECT_DIR}/www/." -exec touch -cm {} \;
That will make sure the files are being picked up as updated when XCode builds the project. Of course, you should modify the command to your needs - my needs were to update the www folder on build, as I am editing my files using Visual Studio, running in a VM.
Ok, I finally found a (somewhat ugly) workaround against this.
In you project, create two aggregate targets, say Clean Build and Cleaner.
In Cleaner, add a "Run Script" Phase with rm -rf "$CODESIGNING_FOLDER_PATH" that will purge the temporary app from the build folder.
In Clean Build, add first Cleaner, and then your normal app target to the Target Dependencies.
Select Clean Build from the run list, then Edit Scheme and set your app target as the executable. Hit run, and it should work :)
You might want to use the Clean option under the Product menu (or hold down shift and command and press K) after you update a resource and before you build the updated app. I have noticed that this has helped me out at times when I update a resource or a user-defined build setting.

Resources