0

No prior knowledge for using external library in Swift.

I was trying to include sf-proj-ios in my empty project named "Test". I followed instruction on the library GitHub, used commands on MacOS terminal.app:

(installed CocoaPods)

  1. brew install automake

  2. brew install libtool

  3. cd /Users/MYNAME/Documents/Test

  4. pod init

Podfile in project folder:

platform :ios, '15.0'
target 'Test' do

pod 'sf-proj-ios', '~> 6.0.3'
  use_frameworks!
  target 'TestTests' do
    inherit! :search_paths
  end
  target 'TestUITests' do
  end
end
  1. pod install

Notes: I did not make any changes to the bridging header build settings as I don't really understand where to import it as stated in the GitHub guide. i.e. where to put the line:

#import "sf-proj-ios-Bridging-Header.h"

Tried to add sf-proj-ios-Bridging-Header.h in Objective-C Bridging Header in project Build Settings but error prevailed.

  1. Opened Test.xcworkspace with Xcode and added test() function to ViewController
import UIKit
import proj_ios

class ViewController: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        test()
    }
    
    func test(){
            let projection1: PROJProjection = PROJProjectionFactory.projection(withAuthority: PROJ_AUTHORITY_EPSG, andIntCode: PROJ_EPSG_WEB_MERCATOR)
    }
}
  1. Built and ran Test, resulted in error Use of undeclared identifier 'nullptr' and 'crs.hpp' file not found with <angled> include; use "quotes" instead occurred at library file optargpm.h and proj.cpp .

enter image description here

enter image description here

  • Tried to fix the "angled" with "quotes" as suggested by the compiler but it did not help.

  • Tried comment and uncomment use_frameworks! in the podfile then re-install pod but also not helping.

  • Searched online and found out that nullptr is available after C++11. Checked Build Settings of the project but all Clang dialects are 17 or above.

Suspected that the problem was due to improper installation of the library. Please advice how should it be done correctly.

Project environment:

Mac Mini with M2 Chip
macOS: 14.0 (23A344)
Xcode: Version 15.4 (15F31d)

Attached project Test.zip

4
  • @Larme Just started learning. The line was there at the 3rd row in the podfile. Or am I missing some more? Commented Jun 23, 2024 at 5:45
  • Sorry, it was late, but I still don't know how I missed it. I will delete my comment as it's irrelevant. Commented Jun 23, 2024 at 9:26
  • nullptr is from C++. you need import it's headers inside #ifdef _cplusplus #endif block Commented Jun 24, 2024 at 10:54
  • Does this answer your question? Force Header Files to Compile as C++ in Xcode Commented Jun 24, 2024 at 10:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.