Linker command failed with exit code 1 - duplicate symbol __TMRbBp - xcode8

Since I've updated to Xcode 8.1 I can't archive and also not run in Release mode (in debug mode its working). The error is that there are several "duplicate symbols for architecture arm64" and all are "duplicate symbol __TMRbBp". Whats that?

It seems to be a bug in Swift. See
discussion on Apple developers portal
It is said to be fixed in Xcode version that is about to be released.
But for now there is temporary workaround:
Go to your target Build Settings and set Reflection Metadata Level flag to None

Don't double click Project.xcodeproj to start your xcode project. Instead, close your project and open the xcworkspace.
File -> Close Workspace
File -> Open -> Search your project folder for Project.xcworkspace
All my errors are gone.

I faced the same problem with archiving on Xcode 8.1.
X Code Version: Version 8.2.1 (8C1002)
The following fix worked on Mar 2019
1) Go to Project & Select your Project
2) Select Build Settings -
Search for "Enable Bitcode" Set option as "NO"
3) Most of version will fix this issue, for few other XCode version try this option also,
Search for "Reflection Metadata Level" Set option as "NONE"

I had similar issues with Version 9.2 (9C40b), the solution is
0) Close Xcode
1) Open project folder in terminal
2) pod update
3) open .
4) open project by clicking Project.xcworkspace

Surprisingly, in some occasions, simply cleaning the product worked for me.
Product/Clean (Shift+Cmd+K)
Product/Clean Build Folder (Alt+Shift+Cmd+K)
Quick fix to try before looking at other solutions.

1.Close your project:Completely quit Xcode.
2.Go to your project location:there you will find two files in you root folder with varying extensions:
Appname.xcodeproj and Appname.xcworkspace
Now open your project by Double clicking on file with the extensions xcworkspace.(***Appname.xcworkspace*)**
Yourproject will open in xcode.
Now run your project again.
If you pay close attention when installing your pods,firebase makes it clear to open your project with your-project.xcworkspace after installing pods
firebaseIOS Setup
$ cd your-project directory
$ pod init
Add to Podfile
pod 'Firebase/Core'
And finally:
$ pod install
$ open your-project.xcworkspace
Dont forget to add firebase to your AppDelegate

If you're using Ionic and the Push and Console plugins that's the problem. Remove the cordova console plugin (which is deprecated) and the error will disappear.
The linker error is saying that a library is duplicated which is, in fact, true because the console plugin is already in cordova-ios 4.5+
It took me a couple of hours to figure this out!

In my case
Select your project (In my case i have 2 targets)
Go to Build Phases
Compile Sources
Check if the number of items on each targets is the same (mine was different)
Add the missing file / Remove the duplicated file
Problem Solved

I ran into this problem recently creating a new project and adding some pods (AlamoFire specifically) to the project. Troubled with it a couple hours or so recreating the project (it was new) several times. Tried all the methods here and no luck.
Eventually I figured out that it was because XCode V10.1 was also opening the old project file along with the new pod-created workspace when I opened the workspace via command line "open myProject.xcworkspace" when I reopened the project after doing "pod install"
Closing all projects before exiting XCode before I did my "pod install" fixed everything for me.

close you project then open xcode go to file -> open search your project and open it . this worked for me

I got this error due to deletion of some files. For me simply cloning my project worked.

For those that can't get the Thorax's answer to work, what I did was I closed out Xcode, ran pod update on my command line and then reopened the .xcworkspace file. After doing that, I was able to build and run the project.
I am using the Firebase Cocoapod and Xcode version 9.1.

I had removed files from Compile Sources in Build Phases in Targets. I added main.m and it worked.

Had the same problem in Xcode 10.1 and was able to resolve it. In path Project Target > Build Setting > No Common Blocks, I changed it to No.

I had similar kind of problem when I added a framework to my project.
I have resolved the issue by removing the framework and again adding the framework to the project by dragging and dropping the framework file to the projects frameworks folder and selecting the Copy items if needed option.

Related

Couldn't build Objective-C module 'Firebase'

Can someone help me out with this?
When I compile the application I get an error equal to this: Could not build Objective-C module 'Firebase'
Please take a look https://imgur.com/a/enbAN25
I tried to use this method and it did not work
1. Quit Xcode.
2. Delete project's temp files located at ~/Library/Developer/Xcode/DerivedData
3. Delete ProjectName.xcworkspace
4. Delete Podfile.lock file and Pods folder
5. Run pod install.
6. Open the newly created ProjectName.xcworkspace file and build.
This problem appeared after upgrading to Xcode 12.
Apparently removing the build configuration for valid architectures (VALID_ARCHS) fixes the problem. See Xcode 12 release notes.
To fix, just set:
Build Settings / TARGET / Architectures / Build Active Architecture
Only / Yes
I hope to help other people not to waste time with this

Intellij IDEA - JavaFX packager : access denied

I'm trying to generate an artifact of my JavaFX application using Intellij but for some reason I always end up having JavaFX packager throwing an access denied error on my output directory.
Generating a simple jar works fine though.
I'm using it on Windows 8.1 with Java 8.
I had the same problem. I kind of solved it:
by ticking the "Build on make" box in the Project Structur Dialog
starting a Run of my Java App in Intellij Idea
Now the executable jar magically appeared in my build folder. God knows why.
I had this problem and solved it by deleting the Artifact from IntellIJ, then deleting the "out/artifact" previously created folder where it tried to build my jar and finally re created an artifact from scratch. For no specific reason it now worked.
I have encountered the same problem recently. I checked the permissions of the directory and can read and write. Later I deleted the artifact and re-created a new one to solve the problem. I hope to help people who have encountered this problem.
I had this problem. I ran into it because When I added artifact with + button in Project Settings->Artifacts, I selected JAR artifact , and change JAR to JavaFx Application from type drop down box on right side pane. Later, I removed this artifact and pressed + button, then selected JavaFx Application from drop down list, then it was builded successfully. My JDK version is 8.
When I call JavaVXPacker from the command line I get the following:
C:\Users\Ingo>javafxpackager -help
javafxpackager.exe has been renamed javapackager.exe.
The original file may be removed in a future release in lieu of javapackager.
Please update your scripts.
...
...
So I guess IntelliJ has to update it's script to re-enable the feature???
(using Windows 10 and JDK Liberica 15+36)
Go to File > Project Structure
Click on Artifacts on the left panel.
Thereafter click on the plus icon to add a Jar From modules with dependencies…
A pop-up will be shown and there you would have to select for the startup class of your project.
Click on OK twice to save the changes.
Lastly go to Build > Build Artifacts... And select build action.
Now your jar will be generated in the out folder of your project.
For a more details guide, please refer to this post

Invalid JDK configuration found, while importing a project via Gradle

I have installed IntelliJ and I need to import a Gradle project.
I have build the gradle project using command prompt with the gradlew build command.
At the IntelliJ welcome page, I have proceeded with proper instructions, and when I choose "Finish". I get the following error:
Invalid Gradle JDK configuration found. Open Gradle Settings JAVA_HOME ennvironment variable not set.
When I click on "Open Gradle Settings" it pop up with error of Not found with a path under IntelliJ directory in Program files and searching in jre/jre/bin/....etc.
Deleting .gradle and .idea will likely solve the problem.
So:
Close the project
Go to the project dir and delete .gradle and .idea
Get back and re-open the project using the IDE
These two must be generated locally on your PC (Some content of .idea might be version controlled though) and not pulled from a remote or somewhere else (Also they should be in .gitignore).
In my case the reason was that these two folders were generated on another computer and I had opened a project with these two folders existing before.
Just found the solution :
Create an empty Gradle project, then go to "Project Structure" and check the path to JDK (it should be valid, if it isn't you can add your own path).
Then build this empty project, wait and once done, close IntelliJ.
Relaunch it and try to import/open your Gradle project, now it should work.
You don't need to create a new project to fix this. You can do it from the main window (Configure -> Project Defaults -> Project Structure):
Then, on SDKs, set the appropriate JDK home path:
If you are on a Mac, click on the button with 3 dots and select the folder /Library/Java/JavaVirtualMachines/jdk1.8.0_141.jdk/Contents/Home.
I've found this here:
https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000266650-invalid-gradle-jdk-configuration-found
Mac OS X Solution:
I had the same issue and fixed it by setting the JAVA_HOME environment variable using the command:
launchctl setenv JAVA_HOME /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/
Refer to this answer on how to set environment variables in Mac OS X:
Setting environment variables in OS X?
Close the project
Go to the project dir and delete
.gradle
.idea
Get back and re-open the project using the IDE
I recently had the same problem while importing a Gradle project. The trick was the remove the quotes from the JAVA_HOME variable. So instead of "C:\Program Files\Java\jdk1.8.0_66" my path now contains only the plain path C:\Program Files\Java\jdk1.8.0_66.
To add to the previous responses, if you want to prevent this problem when cloning a repository in Git, you can simply remove .idea/misc.xml from your .gitignore file. This contains information about the project jar. For example:
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_10" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
</project>
For my case, I just restart the IDE and it works. It automatically download Gradle to suit the project version.
I had the same problem on the fresh installed Windows OS.
I did not have a JDK at all and forgot to check it invalid JDK configuration .
By default, you can check the Project configuration. If it is empty NO_SDK_ProjectStructure try to download JDK from Oracle web site and configure your project structure
I have faced same problem for tomcat 9 with my project based on Gradle.
You can easily rectify the problem by configuring the application.properties file with the following code.
location - src/main/resources/application.properties
server.port = 9090
spring.security.user.name= admin
spring.security.user.password= password
My issue was not addressed by the above solution, instead root cause was that I've imported settings from my old system and internal Intellij configuration was invalid because first jdk that it had in the list in jdk.table.xml pointed to a wrong path.
To fix this you should find this file in the intellij config folder and then simply open it with an editor and remove whole block related to the bad jdk version.
Close the project you are working on and then create another new project and build it and then close it and go back to your old project and it will work.
Comment this code on gradle.properties, the Issue was gone.
#org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_141.jdk/Contents/Home
I was getting:
Invalid JDK: /home/sz97/idea-IC-223.7571.182/jbr/bin/jlink is not a file!
Ensure JAVA_HOME or buildSettings.javaHome is set to JDK 15 or newer
As mentioned by Mahdi-Malv, delete .gradle & .idea folders from the project directory.
Then delete other SDKs from File > Project Structure > Platform Settings > SDKs keeping the only required one.
Finally change the SDK version from Project Structure > Project Settings > Project.
This may solve the problem.

Xcode custom shell scripts are slowing down the compiling time

Testing any changes to my Xcode project has become an exercise in patience whenever I build. After all the source files have compiled, I get the following message in the activity window at the top of Xcode:
"Running 3 of 3 Custom Shell Scripts"
I have not added any of my own custom shell scripts but I am using quite a few dependencies via Cocoapods and I am using 2 frameworks for the build environment, Crashlytics and Tapstream. Crashlytics requires you add a run script in the build phases, other than that I don't know where the other ones are coming from and they appear to be the bottleneck in my build time.
Can anyone enlighten me as to what is going on and how i possibly speed it up?
I can't enlighten you but I can tell you how I stopped mine from running. This also happened after installing Cocoapods. In my main project's Target, under Build Phases, I noticed two entries entitled Check Pods Manifest.lock and another called Copy Pods Resources.
Under both there was an unchecked option Run script only when installing. I checked both and at least for now my projects build and run fine without running the scripts.
This is kind of a crappy answer because I can't really give you any more information, and it might not even work for your case, so hopefully someone comes along and enlightens us.
POSSIBLE EXTERNAL BUNDLE ISSUES
So I just had a frustrating experience debugging an issue where a pod installed library's NSLocalized strings file weren't working. Turns out it was because I checked the option mentioned above. Pods-resources.sh, which had the lines to install the bundle, wasn't running in debug mode. It was only running when installing - of course! Something to watch out for.
More info in this question:
NSLocalizedStringFromTable not working in CocoaPod dependency
To fix the slow "Copy pods resources" problem I figured out a solution to only copy the resources if they haven't been copied before.
For this purpose we have to patch the *-resources.sh files that are created by cocoapods such that the copy procedure only happens if a generated file in the target directory doesn't exist (it is created upon first copy). As long as this target directory exists and includes this autogenerated file, the copy resources phase is skipped. This saves me about 30 seconds in my project (of course depends on your project size). To accomplish this do the following:
Create a patch file called 'copy_pod_resources_once.patch' in your project root dir with the following contents:
5a6,13
> NONCE_FILE="${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/copyresources-done.nonce"
> if [ -f "$NONCE_FILE" ]; then
> echo "already copied resources"
> exit 0
> else
> touch "$NONCE_FILE"
> fi
>
In the Podfile for your project add the following post install hook:
post_install do |installer_representation|
system('find "./Pods/Target Support Files" -name "*-resources.sh" | xargs -I{} patch -p0 {} -i ./copy_pod_resources_once.patch')
<other post install stuff>
end
For me, it was Crashlytics. There were some outstanding changes, as Crashlytics does auto-updating of its files. I reset/removed them and rebuilt and got past it.
So the general answer may be to check any third party components and make sure they're working properly.
As Ramsel has said in this answer,
https://stackoverflow.com/a/21318086/1752988
I also went to Build Phases and cleared out all the possible links to PODs, after trying most of the other solutions and the three build issues shown regarding Pods were cleared out.
But then one file which was not list under the XCode Project navigator was missing, but they were in the Downloaded Git Zip folder! Obviously, I copied it and put into the XCode project and try running it runs cleanly! :)
I had a similar issue in my project (however not using Cocoapods). It ended up being an issue with an application external to Xcode (Spritebuilder) somehow holding onto a resource within my Xcode project when it crashed. I forced the non-xcode application to close and now the issue is gone
Check your project folder name have any space.Because space creates problem in directory path like "SRCROOT".I removed spaces and project run fine.
I've found that this happens to me frequently. Exact cause unknown, but appears to be switching between git branches that have differences in what pods are being used. In my case simply touching the Pods-xxx-Resources.sh shell script file causes it to speed back up.
Probably not going to work for you, but cleaning the project fixed it for me (Product -> Clean)

Compile, Build or Archive problems with Xcode 4 (and dependencies)

This question has evolved over the past several weeks to cover more general issues with xcode4 (and upgrading projects form older xcodes).
However many of the issues can be solved by following the same set of instructions.
If you have any of the following issues, try the methods in the accepted answer:
Xcode 4 fails to archive an App
Xcode 4 creates an unusable archive
Xcode 4 does not create an .ipa
Xcode 4 fails to compile due to preprocessor errors
Xcode 4 cannot find headers
Xcode 4's code complete is not working
Project dependancies won't compile
Adding a dependancy causes any of the above issues
Original Question
Title: "lexical or preprocessor issue file not found" in Xcode 4
I have a project in Xcode 4 that will build fine and run on the device and simulator but when trying to Archive it errors when looking for headers files associated with a static library:
In file included from /Volumes/Development/Path/LBProject/LBProject/LBProject-Prefix.pch:15:
In file included from /Volumes/Development/Path/LBProject/LBFDefines.h:23:
In file included from /Volumes/Development/Path/LBProject/Classes/LBProjectAppDelegate.h:11:
In file included from /Volumes/Development/Path/LBProject/LBProject/../FKNDirectory/FKNDirectoryManager.h:10:
/Volumes/Development/Path/LBProject/LBProject/../FKNDirectory/FKNDataModel.h:11:9: fatal error: 'Merchant.h' file not found [1]
#import "Merchant.h"
^
1 error generated.
Xcode gives the error
lexical or preprocessor issue file not found
Much Googling has show many people are having this issue but no solution. Anyone got a fix or even a clue.
Update: The user header search paths are set to ${BUILT_PRODUCTS_DIR} in all configurations. It builds fine using any configuration except when archiving.
Update 2: Merchant.h is a Core Data class that is auto-generated and therefore inside .xcdatamodeld package, however the headers are all copied to the public headers directory when the library is built.
NB: The steps below will solve 90% of your Xcode archive issues
however, from the comments it is suggested you try quitting Xcode
first. This may save you hours of setting tweaking.
Check the "user header paths" are correct (Add "" to paths for spaces, both in your project and dependencies)
Set "Always search user paths" to YES
Create a group call "Indexing headers" in your project and drag the headers to this group, DO NOT add to any targets when prompted. This includes any headers inside your .xcdatamodeld, you'll need to right-click and view package contents to find them.
For all dependencies set "Skip Install" build setting to "Yes"
Moving any "Public" headers in Build Phases to "Project"
Set the Build Setting "Installation Directory" on your Target to $(LOCAL_APPS_DIR)
Change the target build setting "scan all source files for includes" to YES. (link)
With newer versions of Xcode (> 4.2) you might want to read this question related to workspaces.
Manually delete the project.xcworkspace files form all referenced projects
I had the same problem in XCode 4: "Lexical or preprocessor issue MyFile.h not found". However, MyFile.m was not a static library, just a standard class. And MyFile.m and MyFile.h were included properly and indexed in the project.
So ... I quit XCode and the Simulator, then restarted them and the problem disappeared.
I found that the problem went away when I changed the target build setting "scan all source files for includes" from no to yes.
I was able to resolve this issue without any changes to any of the build settings by simply copying the .h files into the Project's directory in the finder. I did NOT add them to the project at all. Just having them in the project's filesystem directory seemed to be enough to allow Xcode's implicit linking to work properly. More details here.
I had a weird issue like this. Changing "Scan all resource files..." to Yes didn't help. I took a look at the Framework Search Paths and noticed that I had
$(inherited)
"$(SRCROOT)"
"$(SRCROOT)/my/correct/path"
It seemed right but was still failing. I then tried rearranging the order of 2 & 3 and all of a sudden it built fine. So not sure why that was the hickup, but wanted to add it to the list of things to try in case it helps someone else.
My solution was to change my
#import "HeaderFile.h"
to
#import <FrameworkName/HeaderFile.h>
and everything started working again.
What was unusual was that it had stopped working suddenly after building
a few times.
The problem resolved itself when I set
Build Settings->Project->Search Paths to Yes
I had the same — 2 targets in my project (Project and ProjectTest of GHUnit). When my scheme was set up to Project, the import of <GHUnitIOS/GHUnit.h> was problem of “lexical or preprocessor issue file not found”. But when I set as a scheme ProjectTest, everything was OK. So, I have added GHUnitIOS.framework in Project too.
Looks like your header search paths are incorrect not configured properly in your build settings for the active scheme. Verify them and update your question with the current setting.
I'm having similar issues on the simulator but not the device and my header search path fields are empty (Seems to be default). But changing Workspaces seems to have solved the issue. Maybe you could try creating a new Workspace, add your project to it and see if that helps. Now I'm investigating why.
I was getting this "file not found" error for one particular .h file in my project. I resolved the issue by removing that .h file from the project (selecting "Remove references") and re-adding it.
Adding on more variant: I had two instances of foo.m in the Compile Source build phase, which some how caused "Header not found" for foo.h.
Another chance:
In workspace project: watch in the Target for section Build Phases. As many manuals says you need to have a Copy Files Build Phase to copy all your headers to another place, as iOS Framework cannot contain header files to be shared (this is my case).
Choose for those Copy Files as Destination option "Products Directory". Or another directory of your like where the headers will reside.
That worked for me. Probably the build for Archive (or Release) directory is very different than expected in build for Debug .
Also check in your workspace settings your build directory.
XD
For me, this issue occurred after I added new files to the project; a blank .m and .h derived from NSObject. Here's how I resolved it:
Closed and restarted xCode
Deleted the two new files via XCode
Recompiled successfully
I then Re-added them afterward and it also worked.
Definitely a bug in xCode...