"Redefinition of module ..." when building for simulator - ios

I have an iOS xcode project that builds fine when I have Generic iOS Device selected as my destination. However, when I select any of the simulator options I the build fails with many Redefinition of module 'abcde', one error for every module defined in iOS 11.4/usr/include/module.modulemap.
The duplicate definitions are coming from Simulator - iOS 11.4/usr/include/module.modulemap. I've combed through my workspace/project settings and found no reference to the simulator. All the deployment targets are iOS 11.4.
It appears that when I build for the simulator it is including both the platform and simulator modules. How can I specify one or the other?
This problem popped up out of the blue about a day after adding cocoapods and swift code but I don't know if it is related. (The sdk/deployment targets for the pods are also iOS 11.4 and swift version is 4 (except for Socket.IO which is using 3)).
My pods project is using the generated modulemap (I haven't edited it at all):
framework module Pods_MyProjectName {
umbrella header "Pods-MyProjectName-umbrella.h"
export *
module * { export * }
}
I've googled this problem over and over and haven't been able to find any solution for it. I've tried cleaning and rebuilding, deleting the contents of the Library/Developer/Xcode/DerivedData folder, deleting the pod's modulemap file, commenting out each line of the pod's modulemap file, removing all the code written since the problem began... I have the feeling that I'm looking in all the wrong places.

I had the same issue with other pods. I assume the issue has to do with recursive dependecnies that are also imported explicitly. I tried all the same things as you did, although the only thing that helped me was to close xcode, run
pod deintegrate
pod install
and rebuild.

Related

'Executable path is a directory' Xcode popup error

I have an iOS Xcode project with 3 targets - AppTarget, Lib1 and Lib2.
Hierarchy:
AppTarget is dependent on Lib1 and Lib2. It has no code (SceneDelegate, AppDelegate etc. is moved to Lib1).
Lib1 is a static library containing the AppDelegate and SceneDelegate (Lets not get into why they were moved here from the AppTarget).
Lib2 is a static library, dependent on Lib1. It extends the SceneDelegate class using swift extensions.
In order to get the above structure, I had to add, remove file references and set dependencies.
When I run the AppTarget, I get the following popup after build succeeds,
Pasting the above error as a text,
Details
Executable Path is a Directory
Domain: DVTMachOErrorDomain
Code: 5
Recovery Suggestion: /Users/<user_name>/Library/Developer/Xcode/DerivedData/<project_name>-bnytgzvocmpwyuajjxxjivpkymui/Build/Products/Debug-iphonesimulator/<project_name>.app is not a valid path to an executable file.
User Info: {
DVTErrorCreationDateKey = "2022-11-03 08:04:49 +0000";
}
I'm not sure why this happened. I didn't mess with the default executable path in Xcode->Preferences->Location tab.
There's an Apple forum post which describes a similar error (not the same).
The solution was to check for references of old files, which are not present now. I have verified the Target->Build Phases->Compile Sources of all 3 targets and things are as expected....Didn't see any 'faint files'.
What am I missing here? Any help will be greatly appreciated.
I'm using Xcode 14.0.1 and swift 5+.
One of the reasons for this can be if there are no sources in the app target. If there is no code, the executable does not get generated as expected. See if adding a dummy/sample source code works i.e. Just a swift file with an empty class should also do the trick.
What worked for me:
Delete app from simulator
Delete DerivedData folder -> ~/Xcode/DerivedData
Quit Xcode
Restart computer
Launch Xcode, clean project (command + k), clean build folder (shift+command+k)
From there I was able to run my app target successfully ✅
Exclude the arm64 arch when building for the Simulator. The reason is the Simulator is using X86 based architecture. When building for a real device, like an iPhone, you must remove the Architecture exclusion. The iPhone is using arm based arch.
See the snapshot here

How to include Audiokit 4 in a new project xcode 11 and swift 5.1?

I've recently tried to include Audiokit 4 in a new project using Xcode 11 and swift 5.1, but I get the error message No such module Audiokit, the closest I get to Audiokit is CoreAudiokit by following the instructions in (https://github.com/audiokit/AudioKit/blob/master/Frameworks/README.md).
Here're the steps I followed:
1) Create new single view project in xcode11
2) Project settings, General tab, Frameworks/Libraries added item Audiokit.framework
3) In the ContentView.swift file: import Audiokit or import AudioKit
I've doubled checked the release notes and it clearly states support for Xcode 11 (https://github.com/audiokit/AudioKit/releases)
Finally, tried to compile it myself but the same issue as stated above, module not found.
git clone https://github.com/audiokit/AudioKit.git
./build_frameworks.sh
I can see the AudioKit framework under frameworks:
Other linker flags is also set as instructed:
Updated to Xcode 11.4 (latest), same issue.
Also tested moving the audiokit dir, same issue, nothing seems to make it work, so not sure what other people been doing considering the comments in github which seems they use it with Xcode 11.4...
Try changing the "Embed & Sign" setting for the frameworks to "Do Not Embed". The built frameworks are static and while they need to be linked in your project, they should not be embedded since they can't be dynamically loaded.
After hours trying things, I found a solution!
Just have in mind before proceeding that I've updated to the latest (time of writing) Xcode 11.4 and swift 5.2.
I've moved the file from Frameworks / AudioKit.framework to the project:
And then, while selecting the AudioKit.framework in the show/hide inspector, I change the location to relative to project and target to the current project name as follows (the name of the project changed to test in comparison with the earlier or original post version):
Obs: I've also tested by modifying the build settings, removed all subdirectories to exclude in recursive searches extensions; and add the relative path where the audiokit.framework can be found to the framework search paths. The autocomplete works, but I still get the error No such module 'AudioKit'. So, this far the only option that works is the comment before.
--------------------- a few days later ------------------------
Just had a quick look at this and decided to update the report here.
Unfortunately, the fix above removes the "not found" error but the application crashes. Using cocoapods to install audiokit also seems to not cause the "module not found error".
-------------------- weeks later --------------------
Use cocoapods to include audio into your project as last stated and as follow:
platform :ios, '11.0'
target 'AKRecorder' do
use_frameworks!
pod 'AudioKit', '~> 4.9.5'
end

Xcode 11.1 Error: Multiple commands produce

I see that there are several other questions regarding this problem.
Like: Xcode 10 Error: Multiple commands produce
I am asking this a new because it is for Xcode 11.1 and not older version and I think that the other questions have too many responses and people easily can get lost in them. Here we can try to answer using newer information with quicker access.
After update to Xcode 11.1 and update of cocoa pods ( no pods were actually updated, only the pods project was regenerated ).
I started to get the following error with FBSDK:
Multiple commands produce '/Users/myUser/Library/Developer/Xcode/DerivedData/myProject-euqkymjpeftprkgkcjyqpnkbalbr/Build/Products/Debug-iphoneos/FBSDKCoreKit-iOS/FBSDKCoreKit.framework/PrivateHeaders/FBSDKRestrictiveDataFilterManager.h':
1) Target 'FBSDKCoreKit-iOS' (project 'Pods') has copy command from '/Users/myUser/Documents/Workspace/myProjectDir/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/AppEvents/Internal/FBSDKRestrictiveDataFilterManager.h' to '/Users/myUser/Library/Developer/Xcode/DerivedData/myProject-euqkymjpeftprkgkcjyqpnkbalbr/Build/Products/Debug-iphoneos/FBSDKCoreKit-iOS/FBSDKCoreKit.framework/PrivateHeaders/FBSDKRestrictiveDataFilterManager.h'
2) Target 'FBSDKCoreKit-iOS' (project 'Pods') has copy command from '/Users/myUser/Documents/Workspace/myProjectDir/Pods/FBSDKCoreKit/FBSDKCoreKit/FBSDKCoreKit/AppEvents/Internal/RestrictiveDataFilter/FBSDKRestrictiveDataFilterManager.h' to '/Users/myUser/Library/Developer/Xcode/DerivedData/myProject-euqkymjpeftprkgkcjyqpnkbalbr/Build/Products/Debug-iphoneos/FBSDKCoreKit-iOS/FBSDKCoreKit.framework/PrivateHeaders/FBSDKRestrictiveDataFilterManager.h'
I let you know my case. It was related to a Cocoapod Library installed.
The normal steps to install a Cocoapod is, after running the pod install, then you use to go at your "import library section" in your project, then add it.
I removed the library from there, and the problem disappeared instantaneouslly.
Anyway, to use the library still you need to import it as always in your files.
import YourLibrary
class your {
}
Shows the place where the library must be removed from.
In my case the problem was the that those files :
FBSDKRestrictiveDataFilterManager.h
FBSDKRestrictiveDataFilterManager.m
were added twice in the FBSDKCoreKit-iOS project. I deleted the older ones ( by comparing the actual SDK code from GitHub ). I don't know who is to blame Cocoa Pods or Facebook, but if you get that error or some kind of similar one regarding the same file, I suggest that you check for file duplicates.

Custom Module not found

I'm a beginner in iOS development. I cloned a repo containing working code. I opened up the project in xcode, but when I build the project I receive the error Module 'Subscriptions' not found.
In my build settings, the Subscriptions.framework framework is in Linked Frameworks and Libraries. From what I've researched about module not found errors in xcode, this should be the fix for my problem. However, this is not fixing my problem. This project should normally be able to be built and compiled. Is there something I'm missing here?
Update
Here is the xcode file tree view.
Main
|-Main
|-MainTests
|-Products
|-Frameworks
|-Subscriptions.xcodeproj
|-Subscriptions
|-Products
|-Subscriptions.framework
|-Frameworks
|-Pods
Pods
Ok. I finally figured out what was going on. I dove into the directory I thought that the Susbcriptions.framework was being installed in, and it wasn't there. The directory in the build products path was set to Products/Debug-iphoneos but the Subscriptions.framework was instead being installed into Products/Debug. This made me realize that somewhere in XCode I had the build setting set to build for MacOS instead of iOS. I found the setting and rebuilt my project for an iPhone XS simulator and the module was imported successfully.

Only in release build, clang: error: no such file or directory: '/Users/vagrant/Library/Developer/Xcode/DerivedData

I was building my project fine in debug mode, but started getting this error when I changed to Release
clang: error: no such file or directory:
'/Users/vagrant/Library/Developer/Xcode/DerivedData/myProject-afhcainiqkrasrazkmlyzpkzbhne/Build/Intermediates.noindex/ArchiveIntermediates/skimitarDevelopment/BuildProductsPath/Release-iphoneos/libRNGoogleSignIn.a'
No entirely sure why, libRNGoogleSignIn.a is linked in my Build Phases on all of my targets.
This is first time I came across the issue, tried cleaning my project, deleting DerivedData folder, completely quitting (restarting) XCode with no luck.
libRNGoogleSignIn.a file mentioned in the error refers to this projects Product (https://github.com/Asimetriq/rn-google-sign-in/tree/master/ios)
It is added to my main project as a library i.e. I right click Libraries -> Add files to my project -> I select RNGoogleSignIn.xcodeproj
Afterwards I go to Build Phases and add libRNGoogleSignIn.a under Linking step.
I'm not sure if this is related, but file is highlighted in red:
And file is clearly linked, I'm not sure why it is never appearing in DerivedData
Here is where the issue lies. My main project targets iOS 10.3, where as this library that was freshly created as cocoa touch static library was targeting ios 11+ by default.
As soon as I set libraries target to lower version i.e. 10 in my case it built correctly.
The default iOS Deployment Target for RNGoogleSignin is 7.0, change it to at least 8.0 should solve the problem
Another solution could be delete the Derived data directory and re-build

Resources