iOS or macOS project: duplicate interface definition for ViewController - ios

I am trying to build a common Xcode project for macOS and iOS. My project directory structure is
MyApp
Common
AAPLAppDelegate.h
AAPLAppDelegate.mm
AAPLRenderer.h
AAPLRenderer.mm
MyApp_iOS
AAPLViewController.h
AAPLViewController.mm
main.m
MyApp_macOS
AAPLViewController.h
AAPLViewController.mm
main.m
build gives Duplicate interface definition for class 'AAPLViewController'.
I have added AAPLViewController.h in Build Phases -> Headers of corresponding macOS and iOS schemes.
I have also assigned corresponding macOS and iOS target membership to all files in MyApp_iOS and MyApp_macOS folders.
I tried comparing my project to an working macOS and iOS project but couldn't find a clue to avoid the error.
here is the git repo of it; macOS code isn't complete yet but iOS target should be built without above error.

You need to correctly setup your headers search paths. First, set ALWAYS_SEARCH_USER_PATHS to YES. If that will not work - add only needed headers to USER_HEADER_SEARCH_PATHS setting.

Related

How can I properly share the Amplify framework with my Main App and my App Extension for an iOS app?

I have an iOS app using AWS amplify for the backend. I am using Xcode 13 and SwiftUI.
I previously added the Amplify framework using Cocoapods however I was unable to get the framework to work with the extension.
So I recently switched to Swift Package Manager. I added the package to my main project. Then I went to my Share Extension and in General - Frameworks and Libraries and manually added the libraries.
After doing this the app builds and runs and both the main app and extension work fine and are able to use the libraries.
The problem is that I cannot archive and upload the app to the App Store. I get the following error:
CFBundleIdentifier Collision. There is more than one bundle with the
CFBundleIdentifier value 'com.amazonaws.AWSAuthCore' under the iOS
application 'MyAPP.app'. With error code
STATE_ERROR.VALIDATION_ERROR...
I went on many forums and spent many hours trying to fix this but to no avail. The suggestions are to click 'do not embed' for the libraries but that option is not available for me.
I wonder if there is anyway to resolve this?
Below are my General and Build Phases for the Share Extension:
Just remove explicit Amplify dependency from extension, ie. next section should be empty
Make sure (it should be automatically, but anyway)
Link Frameworks Automatically parameter (in Build Settings) is true
Runpath Search Path parameter is related to main bundle
So as targets from SPM are built in same location as product and extension and automatic framework linking is enabled the imported modules in extension will available and linked automatically and due to run paths are set the frameworks will be found in run-time as well.
Note: of course in main app target all should be included
Tested with Xcode 13.1 / iOS 15.1

Why does Xcode want me to add "#available" checks when the Deployment Target is already at a higher version?

My SwiftUI project has its Deployment Target version set to 15.0. However, when I try to use the new Logger API, I'm still getting warnings about the SDK is only available for iOS 14 or above.
Could it be that an extension to UIImage requires something special? I have a few other files that I used the Logger and the compiler isn't complaining.
As suggested by Kiril, the problem happens because the Test Project was targeting 13.2.
Grep showed that project.pbxproj file has a 13.2 specified. After changing the xml file directly, the problem disappeared.
(I didn't notice this because the test Target doesn't have a place showing the "Deployment Info".

Swift 1.2 - Bridging-Header file not found message in Xcode 6.3.2 and Xcode 4

Building an app on Xcode 6.3.2, now updated to Xcode 4 but it's the same.
I need to import Facebook sdks and Parse sdks
Xcode tells me that the Bridging-Header.h file is not found. I made it this way:
highlighted in the project navigator the Supporting Files group
file/newFile/ios file/ header File
(I tried both checking and unchecking "targets")
named projectName-Bridging-Header.h
building Settings, select "targets" / objective -c bridging-header = "projectName/projectName-Bridging-Header.h"
build
error
According the build settings the header is expected to be in the subfolder Lug1 of the project folder. This specifies the physical folder on disk not any virtual folder in the side bar
If the name of the project is Lug1 the naming of the header is correct

after upgrading to xcode 6, OpenGLES/gltypes.h not found

I'm having an issue compiling my iOS code which was building with the earlier version of XCode.
I import UIKit/UIKit.h in my prefix header file, which with iOS 8 SDK cascades down to including CoreVideo/CVOpenGLESTexture.h, and from there OpenGLES/gltypes.h. In the preprocessor stage, XCode complains that the file gltypes.h is not found.
In the Search Paths for the Target, I've ensured that the Framework Search Paths and Header Search Paths are pointing to the location of the SDK installation. Also, "Always Search User Paths" is set to Yes.
Anyone else seen this issue? "Linked Framework and Libraries" has OpenGLES.framework above "CoreVideo.framework" or any other linked frameworks.
Update
XCode 6 was installed as an update from App Store. Also tried uninstalling XCode (by dragging app to trash), and re-installing from App Store. Did not help.
Update
I removed the prefix header file, and set "Precompile Prefix Header" to "No", deleted the cache where xcode would place the precompiled information. Still no give.
Now where ever UIKit/UIKit.h is imported, this error is thrown.
So here's what I did to get over this:
Quit XCode
Removed all reference to OpenGLES.framework from the .xcodeproj file
Restarted XCode, and opened the project
Deleted all derived data (Windows->Organizer->Projects->Derived
Data->Delete)
Let XCode re-index
I know this was asked some time ago, but I just had the same problem and fixed it.
I was working on an iOS app I inherited, and somehow they added the OpenGLES framework to the root of their source folder, and it was that version of OpenGLES framework that they added to the project as a linked framework instead of the one provided by the SDK.
So I removed that from the "Linked Frameworks and Libraries", and added the one supplied by the SDK. Stopped getting that error after doing so.

dyld: Library not loaded: #rpath/libswiftCore.dylib / Image not found

I am running my app from xcode to my iOS device and I get this and black screen on iOS device.
Console text:
dyld: Library not loaded: #rpath/libswiftCore.dylib
Referenced from: /private/var/mobile/Containers/Bundle/Application/10DB2FE8-EF09-4857-B4AC-0DB2E4419D6F/App-Name.app/App-Name
Reason: image not found
(lldb)
Try adding the following line to Runpath Search Paths of your target.
#executable_path/Frameworks
your_target -> Build Settings -> Linking -> Runpath Search Paths
I had this same issue. I ended up adding the framework in the following locations:
General > Embedded Binaries
General > Linked Frameworks and Libraries
Build Phases > Link Binaries with Libraries
The embedded binaries seemed to be the key for me.
For me helps adding #executable_path/Frameworks to the project Runpath Search Paths, not target.
your_project -> Build Settings -> Linking -> Runpath Search Paths
None of the other solutions helped me, but everything was fixed by deleting Xcode's Derived Data directory.
Oh yes. I've faced with that problem spending hours on solution.
You may try to set "Always Embed Swift Standard Libraries" to "Yes" under your Build Settings > Build Options
(don't forget to shift+cmd+K your project after)
I had to switch 'Embedded Content Contains Swift Code' to 'Yes' to get my Obj-C app to work after updating the Obj-C embedded framework with a Swift object.
In the Framework Target (not the app target), go to Build Settings > Build Options > Always Embed Standard Swift Libraries to YES.
This solved the issue for me!
I had this error in a command line project (Xcode 10.2 and macOS 10.14.3)
The solution was to update to macOS 10.14.4
Swift command line projects won’t run on macOS 10.14.3 and earlier unless you install the Swift 5 Runtime Support for Command Line Tools package. Without that package, Swift command line projects crash on launch with “dyld: Library not loaded” errors. (46824656)
From Swift 5 Release Notes for Xcode 10.2
In my case, This issue is coming in Objective-c project in which I am using a Swift framework (AirWatch SDK).
Solutions:
I have resolved this issue with Xcode 9.3 and 11.0.1 iOS as mentioned bellow steps :
Drag and drop your swift framework in your project and move in default Framework folder of your project.
Then add them as Embedded binaries as shown in screenshot.
Change your framework status from Required to Optional as shown in screenshot. (Build Phases > Link Binary with Library)
Set Always Embed Swift Standard Libraries to Yes in your build settings.
Set Subpath and select destination as Framework for your added framework in Build Phases> Embed frameworks
as shown in screenshot.
Hope it will help someone.
I have faced the same issue, setting the right code sign identity solved the problem(Build settings->Code Signing Identity).
As per Apple technical questions "All Enterprise and standard iOS developer certificates that are created after iOS 8 was released have the new Team ID field in the proper place to allow Swift language apps to run"
I fixed by deleting all from Xcode Derived Data directory:
~/Library/Developer/Xcode/DerivedData
Good luck all!
This error message can also occur when using a framework build in a different Swift version then the one currently being used, e.g. if you upgrade Xcode.
I had the same error message, that is how I solved it :
The issue came from the certificates generated automatically by Xcode. I had to revoke these certificates dans generate them back from developer.apple.com
The solution is then :
- Go to developer.apple.com / certificates --> Revoke certificates
OR go in Xcode > preferences > accounts > View details > select Sigining identities > clic setting whell > revoke
- Got to developper.apple.com and follow instructions to generate new certificates
- In Xcode in my project : go to Code Signing Identity and sign both Debug lines with the generated certificate
- Both release lines are set to "iOS Developer"
- Then project > clean
- Build and run on device
#Saikiran's answered worked.
My certificates were generated before iOS 8 was released. I revoked all my certificates and regenerated all provisioning profiles and it solved my problems immediately.
I don't have enough reputation to vote up #Saikiran's answer, but that definitely helped solving the problem.
For me has worked set the option
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES
to YES in Project -> Build Settings -> Build Options
(Namirial framework through Cocoapods)
None of the above solutions worked for me. I changed the iPhone Developer Certificate trust settings in Keychain. It should be Always Trust. Change it to Use System Defaults. Double click the certificate in Keychain to open the option screen
Discovered that from this blog
I had the same error message, this is how I solved it :
This is happening because i changed bundle identifier, so i just put old bundle id and it started to work again
I already had the Runpath Search Paths set correctly, but it still didn't work. #Justin Domnitz's answer put me on the right track: Setting "Always Embed Swift Standard Libraries" to Yes in my target's build settings did the trick for me.
Seems this issue was caused by the inclusion of Swift file into objective-c custom framework. Also unsure if related but my app target was built in objective-c as well. Also building to simulator in debug. Haven't verified for release or archive build yet.
Additionally Runpath Search Settings for the project target were set to "#executable_path/Frameworks", within the target settings for the framework they were set to: "#executable_path/Frameworks" and "#loader_path/Frameworks".
After having tried rebuilding custom framework and reattaching to app target, clearing derived data folder and a couple other suggestions, what ultimately worked for me was changing the build setting within Project target for the custom framework project (not app target): "Always Embed Swift Standard Libraries" to "YES". It appeared not to matter what the setting for the app target was set to. I verified this by resetting the simulator and rebuilding. This is similar to Daniele Ceglia's answer but I wasn't able to add a comment and wanted to provide more clarity.
For me Cleaning the project solve the issue!
I got such issue, too
All other ways could not help me,
so I have done it on stupid way
created new project and pod install from scratch
and after confirmed it is working correctly, I copied all class files and storyboard files, at last done!
I think it is the last way for it, maybe could help you
I had a similar problem in an Objective-C project where I started to include Swift files.
In my case, I created two targets in the main project, and I added a Swift empty file, that creates a bridging header file and some configurations, but I only marked it as a member of one target. The first target works properly, but the second not, and I noticed that the differences in build settings were this setting:
Runpath Search Paths -> $(inherited) and #executable_path/Frameworks
And I also needed to reference Objective-C Bridging Header to the file that was created before:
Objective-C Bridging Header -> pathTo/Target-Bridging-Header.h
After adding this two settings, the second target started to work properly.
Try cleaning the build folder, I was having the same problem and I solved it this way:
Product -> Clean Build Folder
For Me restart simulator solved this problem.
I tried a bunch of the cases above and it didn't seem to solve my issue. I use git and cocoapods for a project, and the error went away as soon as I made a new commit.
I had this problem before in iPod touch iOS 9.3. And I used all the methods mentioned in this post, but none of them worked.
I checked my project setting. And in the other link flag, I found I added -Wl,-sectcreate,__RESTRICT,__restrict,/dev/null.
This flag prevents dyld insert in the jailbroken phone. When I delete this flag, the app can be launched again. I am not sure why it worked. Because in iPhone se iOS 10 I don't have to delete this line. But it did work in iPod touch iOS 9.3. So check it if you have the same situation like me.
Please check the *.framework If there is a _CodeSignature signature framework directory.
If there is no _CodeSignature folder,
Navigate to the Build Phases ,click + to add New Copy File Phase to create Copy Files.
after that, reference *.framework and choose Code Sign On Copy

Resources