I am trying to build a framework in Xcode. Using Cocoapods as dependency manager and adding pod 'Alamofire' to the target.
Here are more details -
This project I have created using Xcode -> File -> New -> Project -> iOS -> Framework & Library -> Framework.
Since the project is having dependencies I am opening the xcworkspace file as per the instruction after running pod install command on terminal.
Added one Aggregate target to the same project under targets section.
Added a new run script from Project -> Targets -> Aggregate target -> Build Phases.
Added the steps to create xcframework instructed by apple to the run script.
Tried building the Aggregate target now.
Finally it is producing errors like - linker command failed or no such module Alamofire etc.
Tried lot many changes and instructions from internet but nothing helped so far.
I am using -
Xcode - 12.5.1
Swift - 5.0.
Macos - 11.5.
Is it a bug of Xcode or any special thing I need to take care during the process or I am doing it completely wrong?
Note - This one is a very simple project for testing out the xcframework build process with pods. Actually we have a project with multiple sub targets as frameworks which we are planning to build as xcframeworks and link with the main project target.
Try add this post install step to your Podfile:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end
end
And in your xcodebuild archive make sure to have:
SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES
Related
When I try to build my project, I get a compile time error saying that a "Module map file" for my pod cannot be found and that I am missing a "SwiftShimes" module.
This is weird because all my modulemap files are where they should be when I install my pods.
I am using Xcode 10.2 and Cocoapods 1.6.1.
I have tried the following ->
deintegrating cocoapods from my project
cleaning the project
deleted ModuleCache and DerivedData
restarting my computer
This is the type of error I am getting ->
Module map file '/Users/kaunamohammed/Library/Developer/Xcode/DerivedData/OutNow-gxdxvzwmnijmrlajtbtyclkhrgqs/Build/Products/Debug-iphoneos/CodableFirebase/CodableFirebase.modulemap' not found
I expect my project to build properly but this is not the case and I am not sure what else to do.
This is what my Podfile looks like
platform :ios, '10.0'
workspace 'OutNow'
target 'OutNow' do
use_modular_headers!
#Pods for OutNow
pod 'Instabug'
pod 'SwiftMessages'
pod 'CodableFirebase'
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Storage'
pod 'Firebase/Firestore'
pod 'Firebase/Messaging'
pod 'Firebase/DynamicLinks'
pod 'MarqueeLabel/Swift'
pod 'RxSwift', '4.4.2'
pod 'RxCocoa', '4.4.2'
pod 'Kingfisher', '5.3.1'
pod 'InstantSearchClient', '6.0'
pod 'CoordinatorLibrary', '1.0.5'
pod 'UIScrollView-InfiniteScroll', '1.1.0'
target 'OutNowTests' do
inherit! :search_paths
# Pods for testing
end
end
In case it helps anyone else, I was able to solve this issue a different way. I was accidentally opening up my .xcproject instead of my .xcworkspace. When I opened the correct file, the error went away.
I fixed this problem myself. I can tell you what I did. Not sure which steps did it exactly, but below are all steps:
Copy the contents of your Podfile somewhere safe
Run: pod cache clean --all
Remove "Podfile"-file from the dir.
Xcode: Product > Clean Build Folder
Run: pod init. A new "Podfile"-file is added to the dir
Start adding parts of your original Podfile to this file
Run: pod install
Try to build your project again
In my case, I think the row use_frameworks! in the "Podfile" did the trick.
Hope this help you guys out!
I had this issue only when I wanted to make an archive. On the other hand, debug worked fine. After a while I noticed that min iOS version was different between my Target, Project and Podfile min iOS version. After syncing them all to same value (iOS 11) Xcode offered me Validate Project Settings - Update to recommended settings option which I accepted and I was able to archive my project.
I spent a whole day trying to figure out how to solve this issue. I was facing issue in my project on M1 machine.
I enabled "Open using Rosetta" option in Xcode and worked for me.
Here is how you do that:
Open Finder --> Applications --> Right click "Xcode" --> Get Info --> check "Open using Rosetta"
I solve this issue by removing OTHER_SWIFT_FLAGS custom flag in Swift Compiler - Custom Flags
OTHER_SWIFT_FLAGS = "$(inherited) -D COCOAPODS -Xcc -fmodule-map-file=\"${PODS_ROOT}/modulePath/moduleName.modulemap\"";
I faced this same issue but with Fastlane using gym build_app.
I ensured that min iOS version was synched between my Target, Project, and Podfile as mentioned by Josip B. This allowed me to archive my app using XCode but it still failed using Fastlane.
After lots of searching, it was able to resolve my issue by ensuring the IPHONEOS_DEPLOYMENT_TARGET version for each of my installed Pods inherited the version from my Podfile using this Podfile post-install script:
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
end
end
end
Reference this post: https://stackoverflow.com/a/63489366/10211406
In case you are building on command line with xcodebuild, make sure you are using
xcodebuild -workspace ...
instead of just xcodebuild or
xcodebuild -project ...
I had this issue too, I'm not very familiar with XCode, but I opened the .xcodeworkspace file and then clicked build, which was successful!
It´ s a bit of a hack but try adding this in your podfile:
post_install do |installer|
installer.pods_project.targets.each do |target|
if (target.name&.eql?('FBReactNativeSpec'))
target.build_phases.each do |build_phase|
if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs'))
target.build_phases.move(build_phase, 0)
end
end
end
end
make sure you add it to your bridge file, and Try to add this at the end of your podfile:
post_install do |installer_representation|
installer_representation.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end
end
I'm trying to import Firebase after installing Cocoapods via terminal but i'm getting the following error message:
Could not build Objective-C module 'Firebase
Can someone help me out with this?
This is my Podfile content:
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'Login_test' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for Login_test
pod 'Firebase/Core'
end
Assuming that you have installed FireBase properly via CocoaPods. Try the following steps
Step 1 - Close Xcode
Step 2 - Clear your derived data. You can find your derived data in here
~/Library/Developer/Xcode/DerivedData
Step 3 - Open your .xcworkspace
Step 4 - Clean your project (⌘+Shift+K)
Step 5 - Build your project (⌘+B)
Hope this helps.
for beginners:
make sure you read the message after installing the Pod,
you need to close the xcode project and use the .xcworkspace for this project from now on.
For me the issue was simple. I have a new m1 mac and it has trouble loading cocoa pods sometimes. Simply click your pods project(blue pods)->Click all & build settings ->Excluded architectures -> add "arm64" to both debug and release -> set any SDK on left side -> do this on your main project folder too -> build it your good to go
See Example
After migrating to Swift 3.0, I am trying to import SwiftyJSON into my project. However, when I import the framework 'import SwiftyJSON' I get a No Such Module error.
If I remove the import statement, it does not recognize its classes.
Any advice as to why XCode might not be reading my imported framework?
See screenshots attached:
My problem was I was opening the project file and not the workspace file...
Try to check Targets-> Build Phases Link Binary With Libraries
There must be a link with SwiftyJSON
Updating my pod to reference the official SwiftyJSON gem worked for me! It updated from version 2.3.2 (what was installed by default via 'pod SwiftyJSON') to version 3.1.1.
So, in your Podfile, udpate your SwiftyJSON pod to:
pod 'SwiftyJSON', :git =>'https://github.com/SwiftyJSON/SwiftyJSON.git'
HTH
Clean your project and build again. Make sure you open project.xcworkspace.
pod 'SwiftyJSON'
remove import SwiftyJSON
to solve No such Module 'SwiftyJSON' on Swift 3.0
Swift can load the SwiftyJSON.swift by itself.
No need to specify it at import statement.
Ref: https://github.com/SwiftyJSON/SwiftyJSON/issues/49
Try this.
# Uncomment this line to define a global platform for your project
platform :ios, '10.0'
# Uncomment this line if you're using Swift
use_frameworks!
target 'Project names' do
pod 'SwiftyJSON', git: 'https://github.com/BaiduHiDeviOS/SwiftyJSON.git', branch: 'swift3'
end
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0'
end
end
end
If you have multiple targets, try building each of them. I had two targets - one would build and the other would not. This may help you trace the issue.
In my case I just nuked my dev target that was not working, duplicated the production target, made a few settings changes, and was back in action.
clean your project and than build and run your project and than not work so remove your swiftyjson cocoa library in u r cocoapods and reinstall it should surely work and this 100% work for me ..so u try this.
This solution helped me. Build the modules individually, and then build your project.
https://stackoverflow.com/a/37732248/4899943
//import SwiftyJSON comment out first then
pod install
and then agian add
import SwiftyJSON
and pod install
it work for me
In your Xcode project go to podfile and enter :
pod 'SwiftyJSON'
Save and close the Xcode.
Open terminal and go to project directory and enter :
pod install
Open the project and Import SwiftyJSON in which file you want to use.
I want to use JSQMessagesViewController as a dependency to my swift pod. When I build my example app I get the old non-modular header error related to the JSQSystemSoundPlayer but I don't know how to get around it with XCode 7.
Podspec:
s.dependency 'JSQSystemSoundPlayer'
s.dependency 'JSQMessagesViewController', '7.2.0' #Also tried 5.3.2
Errors:
This is a known issue with v7.2.0 of JSQMessagesViewController: https://github.com/jessesquires/JSQMessagesViewController/pull/1284
Check this pull-request: https://github.com/jessesquires/JSQMessagesViewController/pull/1284
Specifically, this comment from jessesquires (the author): https://github.com/jessesquires/JSQMessagesViewController/pull/1284#issuecomment-181132880
The fix will be part of v7.2.1 according to that thread.
It is not related to JSQSystemSoundPlayer.
Add this at the beginning of your Podfile:
platform :ios, '8.0'
use_frameworks!
So app will use frameworks instead of static libraries for the included projects.
Summary of changes to JSQMessagesViewController:
Change Podfile platform to iOS 8 (platform :ios, '8.0')
Change Podfile to use frameworks instead of static libraries (use_frameworks!)
Change project structure deployment target to iOS 8
Run pod install
Build & run the app
The issue is that Swift doesn't play nice with importing non-modular frameworks into frameworks. Essentially, you will only run into this problem when bundling a framework inside another. There is a simple solution, however it requires some work JSQSystemSoundPlayer as well as JSQMessagesViewController. Both projects will need to have the following Xcode project setting: DEFINES_MODULE = YES.
I am trying to add the Parse.com SDK to my Xcode 7 project. I have followed the getting started guide and I have managed to do it before in Xcode 6.
However this time I am being shown this error message when I try to build:
ld: framework not found Bolts
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Thanks
There seems to be an issue with Xcode 7 beta where the search path for manually added frameworks is missing.
To fix the issue add the search path by doing the following:
Select Project
Click on Targets
Click Build Settings
Search for: Framework Search Path
Add the following without the quotes: "$(PROJECT_DIR)" and choose recursive option.
The project should build now.
I suggest you integrate Parse using CocoaPods.
Cocoapods manages the library dependencies in a much better way.
The following is a sample PodFile:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '7.0'
inhibit_all_warnings!
target '**YourProjectName**' do
pod 'Parse', '~> 1.7.1'
pod 'AFNetworking', '2.2.3'
end