Posts

Post not yet marked as solved
2 Replies
1.4k Views
I am building my macOS app for distribution outside the Mac App store using a shell script as shown below. When a user reports a crash, all I get is offsets and I can’t tell what is going on, where: Thread 3 Crashed: 0 Meteorologist 0x1026da778 0x10268c000 + 321400 1 Meteorologist 0x1026d6354 0x10268c000 + 303956 2 Meteorologist 0x1026d0a8c 0x10268c000 + 281228 3 Meteorologist 0x1026e8ae4 0x10268c000 + 379620 4 Meteorologist 0x1026f7501 0x10268c000 + 439553 5 Meteorologist 0x1026f6621 0x10268c000 + 435745 6 Meteorologist 0x1026f74f9 0x10268c000 + 439545 7 Meteorologist 0x1026f7509 0x10268c000 + 439561 If I understand correctly, I need to include a dSYM file in my executable. I have DWARF with dSYM File in my Build Options, Release value. I can see the dSYM in my .xcarchive file. How do I get it into my .app executable? I do include uploadSymbols=TRUE in my exportOptionsPlist file. If I manually copy the dSYM file, prior to the notarytool step, notarytool throws an error. If I insert the dSYM file after I notarize then it gets flagged when I open the app because it doesn't match what was notarized. #!/bin/bash #set -e #set -x TEMPLATE_DMG=dist/template.dmg # "working copy" names for the intermediate dmgs WC_DMG=wc.dmg WC_DIR=/Volumes/Meteorologist VERSION=`cat ../website/VERSION2` SOURCE_FILES="./Build/Release/Meteorologist.app ./dist/Readme.rtf" MASTER_DMG="./Build/Meteorologist-${VERSION}.dmg" # .altoolid = abc@icloud.com aka Developer Email # .altoolpw = abcd-efgh-ijkl-mnop aka App-specific password # .altooltm = ABCD123456 aka Team ID dev_account=$(cat ~/.altoolid) dev_passwd=$(cat ~/.altoolpw) dev_teamid=$(cat ~/.altooltm) mkdir ./Build rm -rf ./Build/* echo echo ........................ echo "------------------------ Storing Credentials -----------------------" echo xcrun notarytool store-credentials --apple-id \"$dev_account\" --team-id \"$dev_teamid\" --password \"$dev_passwd\" notary-scriptingosx xcrun notarytool store-credentials --apple-id "$dev_account" --team-id="$dev_teamid" --password "$dev_passwd" notary-scriptingosx > xcodebuild.log exit_status=$? if [ "${exit_status}" != "0" ] then cat xcodebuild.log exit 1 fi rm xcodebuild.log echo echo ........................ echo "------------------------ Building Project as an Archive -----------------------" echo xcodebuild -project Meteorologist.xcodeproj -scheme Meteorologist -configuration Release -derivedDataPath ./Build -allowProvisioningUpdates --options=runtime clean archive -archivePath ./Build/Meteorologist.xcarchive xcodebuild -project Meteorologist.xcodeproj -scheme Meteorologist -configuration Release -derivedDataPath ./Build -allowProvisioningUpdates --options=runtime clean archive -archivePath ./Build/Meteorologist.xcarchive > xcodebuild.log exit_status=$? if [ "${exit_status}" != "0" ] then cat xcodebuild.log exit 1 fi rm xcodebuild.log echo echo ........................ echo "------------------------ Creating exportOptions.plist -----------------------" echo \<?xml version=\"1.0\" encoding=\"UTF-8\"?\> > exportOptions.plist echo \<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"\> >> exportOptions.plist echo \<plist version=\"1.0\"\> >> exportOptions.plist echo \<dict\> >> exportOptions.plist echo \<key\>destination\</key\> >> exportOptions.plist echo \<string\>export\</string\> >> exportOptions.plist echo \<key\>signingStyle\</key\> >> exportOptions.plist echo \<string\>automatic\</string\> >> exportOptions.plist echo \<key\>method\</key\> >> exportOptions.plist echo \<string\>developer-id\</string\> >> exportOptions.plist echo \<key\>uploadSymbols\</key\> >> exportOptions.plist echo \<true/\> >> exportOptions.plist echo \</dict\> >> exportOptions.plist echo \</plist\> >> exportOptions.plist echo echo ........................ echo "------------------------ Exporting the Archive -----------------------" echo xcodebuild -exportArchive -archivePath ./Build/Meteorologist.xcarchive -exportOptionsPlist exportOptions.plist -exportPath ./Build/Release xcodebuild -exportArchive -archivePath ./Build/Meteorologist.xcarchive -exportOptionsPlist exportOptions.plist -exportPath ./Build/Release > xcodebuild.log exit_status=$? if [ "${exit_status}" != "0" ] then cat xcodebuild.log exit 1 fi rm xcodebuild.log echo echo ........................ echo "------------------------ Compressing the app -----------------------" echo /usr/bin/ditto -c -k --keepParent ./Build/Release/Meteorologist.app ./Build/Release/Meteorologist.zip /usr/bin/ditto -c -k --keepParent ./Build/Release/Meteorologist.app ./Build/Release/Meteorologist.zip if [ "${exit_status}" != "0" ] then echo "Compress (ditto) failed" exit 1 fi echo echo ........................ echo "------------------------ Notarizing the app -----------------------" echo xcrun notarytool submit ./Build/Release/Meteorologist.zip --keychain-profile=notary-scriptingosx --wait xcrun notarytool submit ./Build/Release/Meteorologist.zip --keychain-profile=notary-scriptingosx --wait if [ "${exit_status}" != "0" ] then echo "xcrun notarytool failed" exit 1 fi echo echo ........................ echo "------------------------ Stapling the app -----------------------" echo xcrun stapler staple "./Build/Release/Meteorologist.app" xcrun stapler staple "./Build/Release/Meteorologist.app" if [ "${exit_status}" != "0" ] then echo "xcrun stapler failed" exit 1 fi echo rm ./Build/Release/Meteorologist.zip
Posted
by EdwardD20.
Last updated
.
Post not yet marked as solved
0 Replies
604 Views
I'm using Xcode 14.3.1 I’m working on a macOS app that needs reverse geolocation. I have the following code: let thisLocation = CLLocation(latitude: lat, longitude: long) let geocoder = CLGeocoder() geocoder.reverseGeocodeLocation(thisLocation, completionHandler: { placeMarks, error in myLocality = (placeMarks?.first?.locality ?? "") + ", " + (placeMarks?.first?.administrativeArea ?? "") }) The geocoder.reverseGeocodeLocation call gets flagged with: Consider using asynchronous alternative function First off, it is async. myLocality doesn’t get filled in until long after the call has been issued. The use of a completitionHandler guarantees that. I tried an alternative geocoder.reverseGeocodeLocation call that really claims to be async, https://developer.apple.com/documentation/corelocation/clgeocoder/1423621-reversegeocodelocation. (This same page claims the call above is synchronous but with a completion handler. To me that’s an oxymoron, a completion handle by definition is not synchronous, https://developer.apple.com/documentation/swift/calling-objective-c-apis-asynchronously) Replacement code: let thisLocation = CLLocation(latitude: lat, longitude: long) let geocoder = CLGeocoder() let locationSemaphore = DispatchSemaphore(value: 0) Task { do { let placemark = try await geocoder.reverseGeocodeLocation(thisLocation) myLocality = (placemark.first?.locality ?? "") + ", " + (placemark.first?.administrativeArea ?? "") } catch { print(“Unable to Find Address for Location " + String(lat) + "," + String(long)) } locationSemaphore.signal() } // Task locationSemaphore.wait() In this second case, the semaphore.wait() call gets flagged the message: Instance method 'wait' is unavailable from asynchronous contexts; Await a Task handle instead; this is an error in Swift 6 Speaking from testing, the wait simply never gets resolved. I will add that my reverseGeocodeLocation call is nested in another async call. I guarantee that this is my max depth of 2. My semaphore logic works elsewhere in the code creating the first async call. My main question is how can I get the reverseGeocodeLocation synchronously, before moving on? How can I get a Task handle to wait on? Thanks all.
Posted
by EdwardD20.
Last updated
.
Post marked as solved
25 Replies
2.1k Views
I am working on an open source weather app for distribution outside the Mac App store: https://sourceforge.net/projects/heat-meteo The project builds and runs fine in Xcode. The batch build script was using ALTOOL which can’t/shouldn’t be used anymore. I am trying to set it up for notarytool. This is what I think is now happening. Again, all works fine in the Xcode debugger. In Xcode, the build is setup with Automatically manage signing for both Debug and Release. They are using my Apple Development account, 4V7…. What I have read if that if I want to distribute outside of the Mac App store, it must be signed with my Developer ID Application, 7VN…. I tried to do an xcodebuild then codesign to switch from 4V7 to 7VN. That actually worked. codesign -dv --verbose=4 shows the correct account. However when I do that, codesign --display --verbose shows I lost the hardened runtime and then notarytool fails because hardened runtime isn’t set. The hardened runtime flag IS set before the codesign command. I can physically turn off Automatically manage signing in Xcode for Release, but how to I select my Developer ID Application account? It does not appear to be a choice. If it matters, the application needs both WeatherKit and Location entitlements and they are set to YES in the entitlements file. I’m guessing, and this pure guessing, I need to adjust something in https://developer.apple.com/account but I don’t know what. Thanks in advance.

Ed
Posted
by EdwardD20.
Last updated
.
Post not yet marked as solved
1 Replies
487 Views
Is there a way on macOS with Wi-Fi turned off to get your location? Preferable based on your ethernet host network IP. According to the documentation, https://developer.apple.com/documentation/corelocation, it's supposed to work on macOS 10.6+. My code works fine if Wi-Fi is turned on, but when it's turned off, locationManager is always nil.
Posted
by EdwardD20.
Last updated
.
Post not yet marked as solved
3 Replies
689 Views
I work on an open source Mac app that uses multiple weather sources. I've added weatherKit to replace Dark Sky. I got past my signing issues (https://developer.apple.com/forums/thread/722378) but when I try to run on macOS 10.15 (I know weatherKit won't work) but it won't even launch. The actual Swift code for weatherKit is wrapped with if #available(macOS 13.0, *) I don't expect the weatherKit code to work before 13 but I would like the same code to run by selecting another weather source. The deployment target in Build Settings is set to macOS 10.15 along with the Minimum Deployment. Of course the app is signed for weatherKit. Is there another setting I need to get the code to run (without weatherKit support) on older OS's or are multiple versions now going to be required. Thanks. Ed
Posted
by EdwardD20.
Last updated
.
Post not yet marked as solved
2 Replies
884 Views
I work on an open source weather app for macOS. I would like to sign it for distribution. I used to do this with a shell script using xcodebuild, codesign and altool using this process: https://scriptingosx.com/2019/09/notarize-a-command-line-tool Obviously I now need to convert to use notarytool. I use the following steps: xcrun notarytool store-credentials xcodebuild -with -authenticationKeyID and -allowProvisioningUpdates xcrun codesign -s "$dev_teamid" --entitlements codesign -dv --verbose=4 /usr/bin/ditto -c -k --keepParent xcrun notarytool submit --wait --keychain-profile xcrun notarytool log xcrun stapler staple I ran with the credentials for Developer ID Application: (not Apple Development Certificate) All steps seem to run fine. The notarytool log shows: "statusSummary": "Ready for distribution” Yet when I try to run I get the message The application can’t be opened. When I click on the ? in the upper right corner, I get an empty window that pops up. Combing through the Console, these two messages jump out: Checking profile: Mac Team Provisioning Profile: com.heat.Meteorologist com.heat.Meteorologist: Unsatisfied entitlements: com.apple.developer.weatherkit What step have I missed? Thank you.
Posted
by EdwardD20.
Last updated
.
Post marked as solved
1 Replies
1.1k Views
I'm using the following code to access WeatherKit. All services (except for .hourly) are working. For .hourly, the time blocks are 243 hours starting at 10pm, regardless of the time of time the request is made. What am I doing wrong? let weather = try await weatherService.weather(for: thisLocation, including: .daily, .hourly, .current, .alerts) // 0, 1, 2, 3 is the order of the "including" above let dailyForecast = weather.0.forecast let hourlyForecast = weather.1.forecast let currentWeather = weather.2 var alertWeather = [WeatherAlert]() if (weather.3 != nil) { alertWeather = weather.3! }
Posted
by EdwardD20.
Last updated
.