I want to use Firebase with Swift 5, but error message appears.
Could not build Objective-C module 'Firebase'
I tried all resolutions on below pages, but I can't solve it:
Error: Could not build Objective-C module 'Firebase'
https://github.com/firebase/quickstart-ios/issues/672
import UIKit
import Firebase
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
return true
}
}
I expect Build Success, but actually Build Failed.
Build error messages are:
'FirebaseCore/FirebaseCore.h' file not found
Could not build Objective-C module 'Firebase'
And, xcode shows Error message at
import Firebase
in AppDelegate.swift
My business partner solves this issue.
The resolution is below steps:
Quite xcode
Delete "ProjectName.xcworkspace", "Podfile.lock" and "Pods".
Delete project's temp files located at ~/Library/Developer/Xcode/DerivedData (Command + Shift + G in finder)
Run "pod install" from terminal.
Open "ProjectName.xcworkspace".
Add "$(inherited)" to "TARGET > Build Settings > Framework Search Paths".
Pod deintegrate.
Delete xcworkspace file.
Open terminal with Rosetta.
Install pods.
Related
I found this video How to add Firebase to a Service Worker - Chrome Extension Manifest Version MV3 created at 26 Jan 2021
Importing the files in the same way he did in the video I got the following error:
"SyntaxError: Unexpected token 'export'"
To try solve this I changed manifest.json to include "type"="module" (because firebase SDK version 9 uses es module)
"background": {
"service_worker": "firebase.js",
"type": "module"
},
And now the error is:
"importScripts() of new scripts after service worker installation is not allowed"
So I dowloaded to the extension https://www.gstatic.com/firebasejs/9.10.0/firebase-app.js to include Firebase static js files in the extension in a folder called firebase and try to import as follows.
import * as firebase from "../firebase/firebase-app.js";
...
firebase.initializeApp(firebaseConfig);
Also tried:
import { initializeApp } from "../firebase/firebase-app.js";
...
initializeApp(firebaseConfig);
But in both cases I get the following errors:
FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app).
DevTools failed to load source map: Could not load content for chrome-extension://hoopapahcqwsdaerotpablmamhgdbhga/firebase/firebase-app.js.map: System error: net::ERR_FILE_NOT_FOUND
Any advice?
I think I found the solution to the issue, at the end of firebase-app.js is the following:
//# sourceMappingURL=firebase-app.js.map
So I went to https://www.gstatic.com/firebasejs/9.10.0/firebase-app.js.map and copy its content in a file named firebase-app.js.map and place it in the same folder that firebase-app.js and now the code works ok.
I am trying to deploy an app to Vercel, and getting this error at build
14:13:58.168 Cloning github.com/ChrisB007/moodflics (Branch: main, Commit: 7a2acfe)
14:13:58.575 Cloning completed: 406.06ms
14:13:58.624 Analyzing source code...
14:13:59.946 Installing build runtime...
14:14:03.139 Build runtime installed: 3.193s
14:14:07.055 Build cache not provided
14:14:08.517 Installing dependencies...
14:14:09.142 npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion#1, but package-lock.json was generated for lockfileVersion#2. I'll try to do my best with it!
14:14:23.664 npm WARN moodflics#0.1.0 No repository field.
14:14:23.676 npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#2.3.2 (node_modules/fsevents):
14:14:23.677 npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
14:14:23.681 added 387 packages from 281 contributors in 14.582s
14:14:23.836 62 packages are looking for funding
14:14:23.836 run `npm fund` for details
14:14:23.861 Detected Next.js version: 10.2.0
14:14:23.864 Running "npm run build"
14:14:24.144 > moodflics#0.1.0 build /vercel/path0
14:14:24.144 > next build
14:14:24.557 warn - React 17.0.1 or newer will be required to leverage all of the upcoming features in Next.js 11. Read more: https://nextjs.org/docs/messages/react-version
14:14:24.912 info - Using webpack 5. Reason: no custom webpack configuration in next.config.js https://nextjs.org/docs/messages/webpack5
14:14:25.052 info - Checking validity of types...
14:14:25.068 Attention: Next.js now collects completely anonymous telemetry regarding usage.
14:14:25.068 This information is used to shape Next.js' roadmap and prioritize features.
14:14:25.068 You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
14:14:25.068 https://nextjs.org/telemetry
14:14:25.123 info - Creating an optimized production build...
14:14:29.905 Failed to compile.
14:14:29.906 ModuleNotFoundError: Module not found: Error: Can't resolve 'next-auth/client' in '/vercel/path0/pages'
14:14:29.906 > Build error occurred
14:14:29.907 Error: > Build failed because of webpack errors
14:14:29.907 at /vercel/path0/node_modules/next/dist/build/index.js:17:924
14:14:29.907 at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/telemetry/trace/trace.js:6:584)
14:14:29.946 npm ERR! code ELIFECYCLE
14:14:29.947 npm ERR! errno 1
14:14:29.951 npm ERR! moodflics#0.1.0 build: `next build`
14:14:29.951 npm ERR! Exit status 1
14:14:29.951 npm ERR!
14:14:29.951 npm ERR! Failed at the moodflics#0.1.0 build script.
14:14:29.951 npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
14:14:29.959 npm ERR! A complete log of this run can be found in:
14:14:29.959 npm ERR! /vercel/.npm/_logs/2021-05-10T18_14_29_952Z-debug.log
14:14:29.972 Error: Command "npm run build" exited with 1
Everything seems to be working fine locally, but when I tried deploying it to Vercel I got the above error message. Can you tell me how to fix it?
Sometimes Vercel acts wired that my codes run locally(npm run dev) but fail after upload. This happens when I use Github automatic deployment, i.e. I directly push to my Github repo then Vercel automatically build and update.
However, using Vercel CLI solved my problem. run vercel for preview then vercel --prod for deployment in production
It can't resolve next-auth/client
ModuleNotFoundError: Module not found: Error: Can't resolve 'next-auth/client' in '/vercel/path0/pages'
Ensure that next-auth is properly installed as a dependency and not a dev dependency. Also upgrade your version of react, it's throwing a warning about it not being 17.01 or higher. If you are using typescript, try module augmentation via the next-auth namespace as indicated in their documentation for typescript namespaces. For example, an #/types/next.d.ts file and an #/types/next-auth.d.ts file for module augmentation.
Locally, I use nextauth as well, and have the following in my #/types/next.d.ts file:
import type { NextComponentType, NextPageContext } from 'next';
import type { Session } from 'next-auth';
import type { Router } from 'next/router';
declare module 'next/app' {
type AppProps<P = Record<string, unknown>> = {
Component: NextComponentType<NextPageContext, any, P>;
router: Router;
__N_SSG?: boolean;
__N_SSP?: boolean;
pageProps: P & {
/** Initial session passed in from getServerSideProps or getInitialProps */
session?: Session;
};
};
}
As for the contents of my #/types/next-auth.d.ts file, it's for a custom headless wordpress auth flow, but you can customize the Session/User interfaces regardless of whether you're using a custom approach or not
import NextAuth, { User } from 'next-auth';
import { JWT } from 'next-auth/jwt';
import { WordpressUserPartialFragment } from '../graphql/generated/graphql';
declare module 'next-auth' {
interface Session extends WordpressUserPartialFragment {
response: {
accessToken: string;
id: string;
avatar: {
url: string;
};
description: string | null;
slug: string;
username: string;
email: string;
firstName: string;
lastName: string;
token_exp: string;
refresh_token: string;
locale: string;
};
}
}
Delete node_modules and run yarn install.
Then do yarn build.
If you use npm then do npm i and npm run build instead of yarn install and yarn build.
Then deploy
Check .vercelignore file for folders/files you are missing.
In my case, I have included folder and forgot.
Also double check what source files got synced to vercel, under project deployments, source tab.
I have followed the tutorial at https://www.djamware.com/post/5a629d9880aca7059c142976/build-ionic-3-angular-5-and-firebase-simple-chat-app to build an Ionic app using Firebase's realtime database.
It works perfectly locally via ionic serve. I have also used the Ionic DevApp and again, it works perfectly.
I have now pushed my code to Ionic but during the build I get this error and the build process terminates:
[11:20:31] typescript: src/pages/chat/chat.ts, line: 7
Cannot find module 'Firebase'.
L7: import * as firebase from 'Firebase';
Error: Failed to transpile program
at new BuildError (/usr/src/app/node_modules/#ionic/app-scripts/dist/util/errors.js:16:28)
at /usr/src/app/node_modules/#ionic/app-scripts/dist/transpile.js:159:20
at Promise ()
at transpileWorker (/usr/src/app/node_modules/#ionic/app-scripts/dist/transpile.js:107:12)
at Object.transpile (/usr/src/app/node_modules/#ionic/app-scripts/dist/transpile.js:64:12)
at /usr/src/app/node_modules/#ionic/app-scripts/dist/build.js:109:82
at
npm info lifecycle fanslide#0.0.1~build: Failed to exec build script
In chat.ts I have:
import * as firebase from 'Firebase';
Inside package.json I can see:
"firebase": "^4.8.0",
I am not sure what I have done wrong and why this works locally but not when the build takes place on Ionic's server.
I managed to overcome this issue and successfully complete a build in Ionic by changing:
import * as firebase from 'Firebase';
To:
import firebase from 'firebase';
This is what happens:
running on Xcode Version 7.3.1 (7D1014)
pod 'Firebase/Core'
import Firebase in the Class
unresolved on Database
Then I added the Database framework
pod 'Firebase/Core'
pod 'Firebase/Database'
unresolved on FirebaseApp
It seems that the 2 frameworks are in mutex mode. They cannot coexist.
I have tried everything: update, install, uninstall, recreate the project, recreate the workspace. All.
May you help me. Is there a bug on last Firebase release?
I had a similar issue.
Your import statement would be:
import Firebase
Make sure restart Xcode and to clean the build folder.
It's working for me & got rid of "Use of unresolved identifier FirebaseApp..." error
Update: For Swift 4.2: FirebaseApp.configure() does work. [FIRApp is renamed to FirebaseApp]
import FirebaseCore
Then you could use FirebaseApp.configure(). I'm using swift 4.
Sounds like you might be using an older version of Firebase. Try -
pod repo update
pod update
Double check Firebase 4.0 is being installed.
Also try importing the specific modules. So instead of
import Firebase use import FirebaseDatabaseor import FirebaseAuth.
use FIRApp.configure() instead of Firebase.configure()
sudo gem install cocoapods
pod update
Replace pod 'Firebase/Core' with pod 'Firebase'.
Then run pod repo update.
That work today for me:
1. in Xcode 9.1
import UIKit
import Firebase
import UserNotifications
import FirebaseInstanceID
import FirebaseMessaging
import FirebaseCrash
import FirebaseAnalytics
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
return true
}
2. My PodFile
pod 'Firebase'
pod 'Firebase/Core'
pod 'Firebase/Database'
pod 'Firebase/Crash'
pod 'Firebase/RemoteConfig'
pod 'Firebase/Storage'
pod 'FirebaseUI', '~> 4.0'
pod 'Firebase/Auth'
pod 'Firebase/Messaging'
3. finale:
pod repo update
pod update
4. restart xcode:
5. press: shift-alt-command-k (in xcode)
This will delete all of the products and intermediate files in the build folder.It's different from delete derive data.
6. an clean
done
In my case it I needed to import FirebaseCore instead of import Firebase or import FirebaseRemoteConfig.
I put in 'Firebase' along w/ 'Firebase/Core' in the podfile and it worked for me
It worked for me with
pod repo update
pod update
and then run this at the location of the pod file:
pod install
After rebuilding my app the error should be gone.
Use FIRApp.configure() instead of FirebaseApp.
For those facing the issue with RemoteConfig configuration, adding an extra import:
import FirebaseRemoteConfig
helped in my case
import FirebaseCore
Adding this to the top of the class resolved the issue for me.
FirebaseCore version: 6.29.0
This is probably too late but if you are sure your podfile is correct and your app has been building before.
When this error just comes out of the blue, remember that the other thing can go wrong is your Xcode's incremental build folder.
Try this:
Quite Xcode
Locate your Build folder and DerivedData folder in finder
Delete Build folder and DerivedData folder
Rebuild via Xcode
Hopefully you'd be fine then.
import UIKit
#UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
let googleMapsApiKey = "AIzaSyDc7eBtBwvAWucUaJcI6chyc9zNhbLQFao"
func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool {
GMSservices.provideAPIKey(googleMapsApiKey)
return true
}
}
I'm having this reoccurring issue where the GMServices error keeps on appearing, yet I have all the relevant framework etc. Any help will be greatly appreciated!
After you imported Google Maps iOS SDK, you need to have a bridge header defined, then the SDK will be recognized.
To create this bridge header, add an arbitrary Objective-C file(eg: a .m file) to your project. Xcode will prompt to ask you if to configure a bridge header for you.
Click Yes to continue.
A file ending with -Bridging-Header.h will be added to your project.
Simply add #import in the bridge header, and you are good to go!
Also, it's safe to delete that temporary Objective-C file now.
For more Information refer this link : http://dubinski.org/wpis/google-maps-sdk-with-swift-tutorial/
Add a temporary Objective-C file to your project. You may give it any name you like.
Select Yes to configure an Objective-C bridging header.
Delete the temporary Objective-C file you just created.
In the projectName-Bridging-Header.h file just created, add this line:
'#import < GoogleMaps/GoogleMaps.h >'
Edit the AppDelegate.swift file:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
GMSServices.provideAPIKey("AIza....") //iOS API key
return true
}
This happened to me just recently when I updated my cocoapods. Now I see:
Using GoogleMaps (1.10.3)
COCOAPODS: 0.39.0
The import in the bridging header, #import <GoogleMaps/GoogleMaps.h> used to work.
Now, to resolve the issue, I had to add import GoogleMaps to the Swift file that has the error.
Add these imports at the top of the file
import GoogleMaps
import GooglePlaces